From 67a9fa5ddaea8c8c70cebc64ebc7628ae645818f Mon Sep 17 00:00:00 2001 From: Jon Massey Date: Fri, 17 May 2024 11:54:53 +0100 Subject: [PATCH] Add task to fetch and store codespaces metrics --- metrics/tasks/codespaces.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 metrics/tasks/codespaces.py diff --git a/metrics/tasks/codespaces.py b/metrics/tasks/codespaces.py new file mode 100644 index 00000000..2a9b14f1 --- /dev/null +++ b/metrics/tasks/codespaces.py @@ -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())