Skip to content

Latest commit

 

History

History
66 lines (43 loc) · 2 KB

README.md

File metadata and controls

66 lines (43 loc) · 2 KB

This is the portal with the statistics of the Italian Olympiads of Informatics!

How it works

The rankings of all the years are stored in a Google Spreadsheet (yeah, excel-as-a-database!). Inside utils/make_db there is a script that fetches this spreadsheet and build the actual data store, which is a collection of JSON files. You can find the data at ./data.

The frontend is written with Next.js and at build time it reads all the JSON files and produces a statically generated site (SSG). The result of the export is then put inside a Docker container with nginx for serving it, and then deployed on Kubernetes.

How to work on the frontend

  1. Clone this repository
$ git clone https://github.com/algorithm-ninja/oii-stats.git
  1. Enter the frontend/ directory
$ cd frontend
  1. Start the dev Next.js server
$ yarn dev
  1. Any changes should trigger an automatic page reload thanks to Next.js

How to update the data/ directory

The data/ directory should never be updated by hand, any change will be overwritten by the scripts.

  1. Get the ID of the Google Spreadsheet with the rankings. In the OII folder the file name starts with Classifiche delle nazionali. You can find the ID from the file URL: https://docs.google.com/spreadsheets/d/$SPREADSHEET_ID/edit

  2. Enter the utils/make_db directory

$ cd utils/make_db
  1. Login to gcloud with
$ gcloud auth application-default login --scopes=openid,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/spreadsheets
$ gcloud auth application-default set-quota-project A_GCP_PROJECT_ID
  1. Create a virtual environment
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
  1. Generate the new database by running
$ ./run.py $SPREADSHEET_ID ../../data --drop