Skip to content

Commit

Permalink
Auto update prod fall 2021 courses every hour (#436)
Browse files Browse the repository at this point in the history
* Add workflow to update prod courses

* test run on current branch

* Add python setup

* run on ubuntu latest

* Set working-direction for upload

* Update every hour. Reduce class cache to an hour

* Make semester publicly visible

* Rename to Semester Data Update
  • Loading branch information
123joshuawu authored Mar 31, 2021
1 parent 3174693 commit 9536027
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/prod-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Semester Data Update

on:
schedule:
- cron: "0 * * * *"
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest

strategy:
matrix:
semester: [fall-2021]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- uses: actions/setup-python@v2

- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-parser-${{ hashFiles('rpi_data/modules/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-parser
- name: Install parser dependencies
run: pip install -r requirements.txt
working-directory: rpi_data/modules

- name: Get course data
run: bash $SCRIPT_NAME
working-directory: rpi_data
env:
SCRIPT_NAME: get-${{ matrix.semester }}.sh

- name: Update prod
run: |
curl -X POST -H "Content-Type: multipart/form-data" -F "isPubliclyVisible=on" -F "file=@$FILE_NAME" $AUTH_ARGS $API_ENDPOINT
env:
FILE_NAME: ${{ matrix.semester }}.csv
AUTH_ARGS: ${{ secrets.AUTH_ARGS }}
API_ENDPOINT: ${{ secrets.UPDATE_API_ENDPOINT }}
working-directory: rpi_data
4 changes: 2 additions & 2 deletions src/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def apiroot():
# - data routes

@app.route('/api/class', methods=['GET'])
@cache.cached(timeout=Constants.DAY_IN_SECONDS, query_string=True)
@cache.cached(timeout=Constants.HOUR_IN_SECONDS, query_string=True)
def get_classes():
"""
GET /api/class?semester={}&search={}
Cached: 24 Hours
Cached: 1 Hour
"""
semester = request.args.get("semester", default=None)
search = request.args.get("search", default=None)
Expand Down

0 comments on commit 9536027

Please sign in to comment.