Skip to content

Improvements to analytics summary API#691

Merged
GUI merged 14 commits intomainfrom
analytics-cache
Jan 30, 2026
Merged

Improvements to analytics summary API#691
GUI merged 14 commits intomainfrom
analytics-cache

Conversation

@GUI
Copy link
Member

@GUI GUI commented Jan 30, 2026

Various fixes for the summary analytics endpoint to prevent returning incomplete data or returning no data at all when things become uncached. The complete data is now cached indefinitely until new, complete data can replace the cache. Various improvements also made to the performance of gathering the aggregated data out of postgresql.

GUI added 14 commits January 27, 2026 20:36
The analytics summary endpoint could start returning no data if the 2
day cache expires and new data hasn't been generated by then. While this
points to some underlying issue, we'd prefer to keep returning the last
cached value (even if it's stale), rather than having this error.

As part of this, also make the timeouts configurable so we can try to
better tune this as needed.
- Fetch the pieces of data out of the analytics JSONB and store them as
  normal columns for faster, more direct access.

- Eliminate custom `array_accum` function usage for better performance
  of aggregating.

- Include organization name in cache key so the cache items are more
  obvious.

- Include other items in the cache key that may affect the cache results
  so that when these settings are tweaked, the cache is regenerated.

- Fix newer pg_dump versions including `\restrict` and `\unrestrict` in
  dump which we don't want for our own schema SQL file.
The unnesting of the user ids in the changes from bb756db was causing
other stuff to be summed up incorrectly. This revamps things again,
but matching the summing original logic (with test coverage of how
multiple user IDs are handled now), but still performs better.
AWS `search.max_buckets` is limited to 10,000. So use a composite
aggregation query so that these can be paginated to fetch all of the
unique user ids.
This verifies that not only is the latest data present, but that all of
the months/days are also populated.
@GUI GUI merged commit 1cb2bd5 into main Jan 30, 2026
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant