Instead of aggregating the metrics on a building level, we now keep a tally table where each record corresponds to an individual. Tally dataframe is calculated once. Whenever a bounding box of the map or a filter is changed, the metrics are recalculated from tally table. This is done in the backend. Fortunately, metric calculation is only about filtering on the tally table, it is fast.
Instead of aggregating the metrics on a building level, we now keep a tally table where each record corresponds to an individual. Tally dataframe is calculated once. Whenever a bounding box of the map or a filter is changed, the metrics are recalculated from tally table. This is done in the backend. Fortunately, metric calculation is only about filtering on the tally table, it is fast.