generated from opensafely-core/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add task to fetch and store codespaces metrics
- Loading branch information
1 parent
27d7e38
commit b33bf6c
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import sys | ||
|
||
import structlog | ||
|
||
from metrics.github.github import get_codespaces | ||
from metrics.github.metrics import get_codespaces_metrics | ||
from metrics.timescaledb import db, tables | ||
|
||
|
||
log = structlog.get_logger() | ||
|
||
|
||
def main(): | ||
log.info("Getting codespaces") | ||
codespaces = get_codespaces(org="opensafely") | ||
log.info(f"Got {len(codespaces)} codespaces") | ||
|
||
metrics = get_codespaces_metrics(codespaces) | ||
log.info("Got metrics") | ||
|
||
log.info("Writing data") | ||
db.upsert(tables.GitHubCodespaces, metrics) | ||
log.info("Written data") | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |