[Backend] Implement Metrics Averaging GitHub Workflow
Closed this issue · 0 comments
samarth52 commented
Context
BEI wants to see patients' average gameplay statistics over the weeks. However, our routes only increment the game session statistics for a given week. We need a script that runs at the end of every week and averages out that week's statistics based on the number of sessions the users completed.
Work on #8 before this.
Requirements
GitHub Workflow to Schedule Metrics Averaging Jobs
Create a GitHub workflow /.github/workflows/average-metrics.yaml
. It should have the following specifications:
- Name: "Average Metrics"
- Trigger:
- Should be scheduled to run every Monday at 12:00 AM EDT
- Add a second trigger such that it can be ran manually as well
- It should create a job that runs on
ubuntu-latest
. The steps are as follow:- Checkout (actions/checkout@v4)
- POST request to
https://brain-exercise-initiative-analytics.netlify.app/api/patient/internal/average-stats
, attaching our GitHub environment variable called INTERNAL_AVERAGE_SECRET to the body of this request (this will have the same value asprocess.env.INTERNAL_AVERAGE_SECRET
. - This job should fail if the POST request's body has
success = false
.
For testing purposes, create a PR for #8 once you finish and test the route. Use the preview URL from this PR in the POST request of the workflow.
Acceptance Criteria
- The GitHub workflow runs every Monday at 12:00 AM EDT
- The GitHub workflow has a manual trigger
- The GitHub workflow sends a POST request to the route created in this PR
- The GitHub workflow fails if the POST request's response contains
success = false