You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
genre_distribution: genre shares for the whole library
New analytics.genre_distribution(db) answers "what fraction of the
library is each genre" over Calibre's genre-as-hierarchical-tags
convention. Every dot-path node rolls up its subtree (Fic.Fantasy.Epic
contributes to Fic, Fic.Fantasy, and itself), shares are fractions of
every book in the library, and a book counts once per node even when
several of its tags share an ancestor. Multi-genre books therefore land
in several roots and the shares can legitimately sum over 1.0; the
docstring says so where renderers will read it. Nodes come back
depth-first (parents before children, siblings share-descending then
name) so both a top-level headline slice and a full tree render are
plain dict walks; books with no tags count under "untagged", last.
Deliberately not a duplicate of get_tag_counts (flat per-tag link
counts): the rollup, the denominator, and the untagged bucket are the
delta the analytics module's scope rule demands. CalibreQuarry's --analytics genres (3.27.0) is the first renderer.