sourcegraph/internal/adminanalytics
Stefan Hengl 590b7e2b01
chore(frontend): use explicit cache for admin analytics (#64077)
Relates to #64041

This refactors the `adminanalytics` package to set the cache explicitly
instead of implicitly relying on the global `redispool.Store`. The
global store obfuscated the dependency and also made testing a bit
awkward.

Test plan:
- new unit test
- I ran a local instance and checked for panics in the logs from the
worker job that updates the cache on startup.
- Checked that the following GQL query returned results 

```GQL
query {
  site {
    analytics {
      search(dateRange: LAST_MONTH, grouping: WEEKLY) {
        searches {
          nodes {
            date
            count
          }
          summary {
            totalCount
            totalUniqueUsers
            totalRegisteredUsers
          }
        }
      }
    }
  }
}
```
- I deleted the cache and ran the GQL query again and verified that
cache had the following new entries
```
1) "adminanalytics:Search:Searches:LAST_MONTH:WEEKLY:nodes"
2) "adminanalytics:Search:Searches:LAST_MONTH:WEEKLY:summary"
```
2024-07-26 10:14:56 +02:00
..
batchchanges.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
BUILD.bazel chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
cache_test.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
cache.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
codeinsights.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
codeintel.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
codeintelbylanguage.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
codeinteltoprepositories.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
extensions.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
fetcher.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
notebooks.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
repos.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
search.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
users_test.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
users.go chore(frontend): use explicit cache for admin analytics (#64077) 2024-07-26 10:14:56 +02:00
utils_test.go [fix] fixes for mau calculations in product analytics (#52581) 2023-05-30 13:59:39 +02:00
utils.go [fix] fixes for mau calculations in product analytics (#52581) 2023-05-30 13:59:39 +02:00