Improve performance of updatecheck data aggregation
Created by: efritz
This PR improves the performance of the updatecheck client. Differences to current approach:
- We use @tsenart's approach from https://github.com/sourcegraph/sourcegraph/issues/10612 of doing a single query pass over the event logs table. This returns the total number of events, unique users, and latencies of a set of whitelisted events for the current day, week, and month (one each).
- We massage the aggregated events from the DB into a {CodeIntel/Search}UsageStatisticsObject to be serialized by the update check handler instead of doing 27+ individual queries to populate these objects. Keeping the update check structs the same means no other changes are necessary to the payload formats.
- We return data only for time periods equal to
DATE_TRUNC(now, 'month'|'week'|'day')
. In order to do multiple time periods, we would need to alter the query to bring back a richer set of data.
A next step will be to remove the code that's effectively dead after this change is validated and merged.
Closes https://github.com/sourcegraph/sourcegraph/issues/10612.