Skip to content

Commit

Permalink
Set up cron tasks
Browse files Browse the repository at this point in the history
We want to configure our tasks with slightly more of an environment than
a direct invocation gives us so this sets up a directory of shell
scripts for each, currently used, cron invocation.

In particular we want the GitHub and Slack ingestors to look for data
from yesterday so we get a full days data and that needs access to
`date`.
  • Loading branch information
ghickman committed Nov 9, 2023
1 parent f0b076b commit 9293a25
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"cron": [
{
"command": "cron/daily.sh",
"schedule": "@daily"
},
{
"command": "cron/weekly.sh",
"schedule": "@weekly"
}
]
}
27 changes: 27 additions & 0 deletions cron/daily.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -euo pipefail

# we want to get data for a full day, an easy way to do this is to always look
# at yesterday's data.
# the yesterday variable is here to make it easier for commands to do that, but
# there's no requirement that they do.
yesterday=$(date -d "1 day ago" '+%F')

# ebmdatalab PR stats
python -m metrics github pr-queue ebmdatalab "$yesterday"
python -m metrics github pr-queue ebmdatalab "$yesterday" --days-threshold=2
python -m metrics github pr-queue ebmdatalab "$yesterday" --days-threshold=10
python -m metrics github pr-queue ebmdatalab "$yesterday" --days-threshold=30
python -m metrics github pr-queue ebmdatalab "$yesterday" --days-threshold=60
python -m metrics github pr-throughput ebmdatalab "$yesterday"

# opensafely PR stats
python -m metrics github pr-queue opensafely "$yesterday"
python -m metrics github pr-queue opensafely "$yesterday" --days-threshold=2
python -m metrics github pr-queue opensafely "$yesterday" --days-threshold=10
python -m metrics github pr-queue opensafely "$yesterday" --days-threshold=30
python -m metrics github pr-queue opensafely "$yesterday" --days-threshold=60

# slack
python -m metrics slack tech-support "$yesterday"
8 changes: 8 additions & 0 deletions cron/weekly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -euo pipefail

yesterday=$(date -d "1 day ago" '+%F')

python -m metrics github pr-throughput ebmdatalab "$yesterday" --days=7
python -m metrics github pr-throughput opensafely "$yesterday" --days=7

0 comments on commit 9293a25

Please sign in to comment.