Add repo_statistics and gitserver_repos_statistics tables
Created by: mrnugget
This adds two statistics tables that are purely populated via database triggers:
-
repo_statistics
to hold information about therepo
table (that's why it'srepo_statistics
and notrepo*s*_statistics
, because consistency) -
gitserver_repos_statistics
to hold information about thegitserver_repos
table
Both tables allow us to cheaply query the number of cloned, cloning, not_cloned, soft_deleted, etc. repositories in a sourcegraph instance and we can even see how many repos are on which gitserver.
See this discussion for background: https://sourcegraph.slack.com/archives/C018CJQ5YBB/p1657276718654509
Demo video
https://user-images.githubusercontent.com/1185253/182858393-7b1b0d9e-b834-4a3d-bdbb-cc83a6dc62fb.mp4
Test plan
- Lots of manual testing
- Lots of testing in SQL REPL
- Automated tests added