aggie-coding-club / Rev-Registration

Automatic class scheduler for Texas A&M written with Python+Django and React+Typescript
http://revregistration.com
GNU General Public License v3.0
25 stars 5 forks source link

Add a "last updated at" indicator somewhere on the website for course information #336

Closed gannonprudhomme closed 3 years ago

gannonprudhomme commented 4 years ago

We should add some an indicator somewhere on the site (maybe on the navbar?) that says when the course information was last updated.

An easy way of doing this would probably be to just have a table with a single row / column that says when scrape_courses was last ran. The route would then just retrieve this value and the frontend would display it accordingly

Add the model to the backend

So I'm not really sure how we want to handle this, but my thought process would be that the easiest way to do it would be to have a model that just stores a term and date, and it's ID / primary key is the term. So it'll basically just show when the data was last updated for each term.

To do this, you'll need to:

1) Create the model

Save/update these models in scrape_courses

Now that the model is created, you'll need to actually save them whenever scrape_courses is ran.

Add a route that returns the respective model on the backend

We'll probably want to set this on a per-term basis? Or maybe a per-semester basis (since all locations are scraped each semester)

You should create a route like api/get_last_updated which takes a term query parameter. A potential query would look something like api/get_lasted_updated?term=202031

1) Create the API view in views.py

Add the component on the frontend + make it fetch the data

You'll then want to add a component on the frontend (and make it display in the navbar) that fetches the last updated data and displays it

We'll also probably want to have some mechanism for updating this, since in peak times we hope to scrape the data every 15 minutes. Maybe we can try to update this value every minute? Whatever you think is best really

Add frontend tests

You'll need to create some basic tests on the frontend. Since these are UI tests, you'll want to put them in autoscheduler/frontend/src/tests/ui/LastUpdated.test.tsx or something like that. When you get around to this message in Discord and we'll find a good example test.

Add backend tests

The tests should be relatively straightforward. There are a lot of examples in autoscheduler/scraper/tests/api_tests.py (which is also in the folder where you'll be making these tests)

gannonprudhomme commented 3 years ago

Updated this with information on how to do it - let me know if you have any questions!

If you think it's too much work for one issue, we can always split it up into a backend + frontend task (in case you want to do one side but not the other). Just looking at the text makes it seem like it's a lot of work, but it should actually be a lot more straightforward than it looks.