biggr_models.queries.summary_queries#

Read precomputed whole-database counts for the front page and statistics.

The counts are written by the cobradb ETL (cobradb.summary_loading), which runs as the final step of bin/load_db. Every run appends a snapshot, so the table is both the current totals and the history of how the database has grown. Reading it costs one indexed query instead of a COUNT(*) per card on every request.

Attributes#

Functions#

get_summary_counts(→ Dict[str, int])

Return {entity_type: count} for the front page cards.

get_summary_history(→ Dict[str, List[Dict]])

Return {entity_type: [{"date": ..., "count": ...}, ...]} oldest first.

Module Contents#

biggr_models.queries.summary_queries.SUMMARY_ENTITY_TYPES = ('collections', 'models', 'metabolites', 'reactions', 'genomes', 'compartments')#
biggr_models.queries.summary_queries.get_summary_counts(session) Dict[str, int]#

Return {entity_type: count} for the front page cards.

Never raises. If the summary table is missing (an ETL that predates this feature) or empty, an empty dict is returned and the front page simply omits the counts.

biggr_models.queries.summary_queries.get_summary_history(session) Dict[str, List[Dict]]#

Return {entity_type: [{“date”: …, “count”: …}, …]} oldest first.

Never raises; an empty dict lets the statistics page explain that no history has been collected yet instead of returning a 500.