biggr_models.queries.summary_queries
====================================

.. py:module:: biggr_models.queries.summary_queries

.. autoapi-nested-parse::

   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
----------

.. autoapisummary::

   biggr_models.queries.summary_queries.SUMMARY_ENTITY_TYPES


Functions
---------

.. autoapisummary::

   biggr_models.queries.summary_queries.get_summary_counts
   biggr_models.queries.summary_queries.get_summary_history


Module Contents
---------------

.. py:data:: SUMMARY_ENTITY_TYPES
   :value: ('collections', 'models', 'metabolites', 'reactions', 'genomes', 'compartments')


.. py:function:: 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.


.. py:function:: 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.


