# `Laev.Stats`
[🔗](https://github.com/alexdont/laev/blob/main/lib/laev/stats.ex#L1)

What you've watched, totalled.

The position files are the record: one per film or episode, holding either
the second you reached or `"done"`. That is enough to say *what* was
watched but not *how long* — a finished film leaves only the word "done" —
so runtimes come from TMDB and are cached in `runtimes.json`, one lookup per
film and one per *show* rather than per episode.

Time comes in two kinds, kept apart because they are known to very
different degrees:

  * **in laev** — played here. Either measured second by second by the mpv
    script, or taken as the runtime of something laev watched you finish.
  * **off laev** — marked watched by hand with ctrl-w. You watched it; laev
    has no idea how much of it, or when, so it assumes the full runtime and
    never pretends that figure was observed.

Anime is counted apart, and from MyAnimeList rather than TMDB: a mark there is
one anime's episode (`mal-1425-e12`), and MAL reports how long an episode of
that anime runs — which TMDB frequently doesn't for anime at all. So anime
hours are its own figure, derived from its own source, and sit beside films and
shows instead of inside them.

Nothing is invented. An entry whose runtime can't be established is counted
as watched but left out of the time, and reported separately, so the total
is only ever made of durations that were actually known.

# `all_time`

All-time totals: seconds watched, how many films and episodes, and the
titles you've given the most time to.

Returns `%{seconds:, in_laev:, off_laev:, films:, episodes:, shows:, titles:
[%Title{}], unknown:, skipped:, measured:, anime:, other:}` with `titles`
sorted by time spent, and `anime`/`other` holding the same counts for the two
halves of what you watch. `seconds` is the two buckets added together. `skipped` counts only
plays laev measured, so it starts at nothing and grows from here.

# `duration`

Seconds as `12h 04m`, or `48m` under an hour.

# `for_title`

What one title holds: seconds watched and how many saved entries it spans.

Asked before erasing it, so the question "remove this?" can say what is
actually at stake — a film is a couple of hours, a show can be thirty.

# `known_runtimes`

The runtime cache as it stands — seconds per film, per typical episode, per
whole series — read from disk with nothing fetched. For callers that want to
reason about lengths without earning a lookup.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
