Skip to content

Migrate to REST API - #220

Merged
psvenk merged 36 commits into
masterfrom
rest
Feb 16, 2021
Merged

psvenk merged 36 commits into
masterfrom
rest

Conversation

@psvenk

@psvenk psvenk commented Dec 19, 2020 •

Copy link
Copy Markdown
Member

Closes #184, #90, #163, #113, and #170. This pull request migrates from scraping the Aspen website to making use of Aspen's REST API, fixing many scraping bugs in the process.

Some notes about testing the code: some of the build framework had to be changed to accommodate a new TypeScript scraper, but you should just be able to run npm start as usual. Please remember to run npm install to load necessary dependencies after checking out the rest branch.

Known issues / to-do list:

  • The frontend code for the "Reports" tab currently expects every file to have a distinct name from the others. For the time being, there is a workaround in the backend to make sure that file names are unique (see 2d0ee1b - "Fix bugs with Reports tab"), but this is hardly ideal.
    • Maybe write a function to guess the dates/quarters?
  • restart-serve.sh (for the production server) as well as README.md and start.bat need to be updated to run npm start insecure or to run tsc directly.
  • Statistics currently do not work because the frontend expects access to a session ID and an Apache token (while the new scraper handles Aspen sessions on its own). We need a new function in the scraper to fetch statistics for an assignment which handles session creation and destruction; this will probably borrow some code from the existing scrape.js implementation because it does not seem that the REST API exposes the assignment statistics.
  • Most (eventually all) of scrape.js is now dead code and should be removed.
  • The new code seems to be significantly slower; we should investigate this.
  • The schedule endpoint throws an "Invalid login" error a significant portion of the time; investigate this.
  • Recent attendance needs to be implemented in the new scraper.

@psvenk

psvenk commented Dec 24, 2020

Copy link
Copy Markdown
Member Author
  • The new code seems to be significantly slower; we should investigate this.

Fixed in 9378b0e.

@psvenk

psvenk commented Dec 25, 2020

Copy link
Copy Markdown
Member Author
  • Recent attendance needs to be implemented in the new scraper.

Fixed in d22a118. I also added support for "grades posted" events, so it may be a good idea to (partially) revert #166 and show these events (even if actual recent activity is not shown). We could also show this information in some other format.

@psvenk

psvenk commented Dec 26, 2020

Copy link
Copy Markdown
Member Author

I also added support for "grades posted" events

I have reversed this in 6974ed6 because reviving the "recent activity" would entail bringing back an area that would be blank most of the time and making the "grades posted" events easy to miss, defeating the purpose. I have made a separate issue (#232) for displaying this information.

@psvenk

psvenk commented Dec 27, 2020

Copy link
Copy Markdown
Member Author
  • restart-serve.sh (for the production server) as well as README.md and start.bat need to be updated to run npm start insecure or to run tsc directly.

Fixed in #233.

@psvenk
psvenk force-pushed the rest branch 2 times, most recently from a308633 to 413a5eb Compare December 28, 2020 01:21
@psvenk psvenk modified the milestones: 2.6.2, 2.7.0 Jan 25, 2021
@kdk1616

kdk1616 commented Feb 10, 2021

Copy link
Copy Markdown
Collaborator

We should enable loading the previous year using the dropdown menu and the new API (for other years after that you can import JSON/Use transcript when that's ready)

@psvenk

psvenk commented Feb 10, 2021

Copy link
Copy Markdown
Member Author

@kdk1616 I don't see how this is related directly to the new API. We already have #99 for tracking progress on getting grades from the previous year, which will be addressed once the new API code is done. As for the transcript, that is tracked separately in #54.

src/scrape.ts is for the new (REST-based) scraper. I added some code for
testing the scraper; it can be run by `npm run scrape $username
$password` but currently does not do much.
Implement a function in scrape.ts to scrape assignment statistics from
Aspen
These are necessary for assignment statistics.
Update the frontend to comply with the API changes in assignment
statistics as a result of the new implementation.
Stop frontend JS (under /public/js/) from being ignored
scrape.js is now dead code and can be removed, along with cheerio.
@psvenk

psvenk commented Feb 16, 2021

Copy link
Copy Markdown
Member Author
  • Statistics currently do not work because the frontend expects access to a session ID and an Apache token (while the new scraper handles Aspen sessions on its own). We need a new function in the scraper to fetch statistics for an assignment which handles session creation and destruction; this will probably borrow some code from the existing scrape.js implementation because it does not seem that the REST API exposes the assignment statistics.

Fixed in f2eeaca, 30009cf, and 8292df2.

  • Most (eventually all) of scrape.js is now dead code and should be removed.

Fixed in b804953.

Instead of assuming that PDF file names will be unique, add a new
attribute `data-value` to the dropdown UI elements which corresponds to
the unique `value` attributes of the `<option>` elements in the
`<select>`.
@psvenk

psvenk commented Feb 16, 2021

Copy link
Copy Markdown
Member Author
  • The frontend code for the "Reports" tab currently expects every file to have a distinct name from the others. For the time being, there is a workaround in the backend to make sure that file names are unique (see 2d0ee1b - "Fix bugs with Reports tab"), but this is hardly ideal.

Fixed in 7dc386a.

@psvenk
psvenk marked this pull request as ready for review February 16, 2021 14:35
@psvenk

psvenk commented Feb 16, 2021

Copy link
Copy Markdown
Member Author

I have requested review from @notrodes, @jadebuckwalter, @kdk1616, and @tektaxi. Given the major nature of these changes, I would like to have as many people as possible review this PR before it is merged. The reviews of anyone else from these four people are, of course, also welcomed and appreciated.

@jadebuckwalter jadebuckwalter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part, this looks good! However, there are a few minor fixes (which may or may not be worth implementing):

The assignments for a given class are listed from oldest to newest (oldest at the top, newest at the bottom) rather than from newest to oldest, as they are in Aspen. This is not a major issue; it's just a bit of an inconvenience.

The dropdown in the Reports tab extends very far down the page. Though it's great that the new API can scrape all of the reports rather than just the most recent ones, I'm wondering if this is the best front-end design. It might be better if the dropdown shows a certain number of recent reports with an option to show older reports rather than showing them all at once; after all, it's not too often that people go back and look at their middle school report cards. This is a front-end issue and has nothing to do with the API itself, so it could be something that we fix later on.

@tektaxi

tektaxi commented Feb 16, 2021

Copy link
Copy Markdown
Collaborator

@jadebuckwalter I agree that we should definitely fix the assignments issue. I feel like that would be a big help and it's much more convenient to have recent assignments first

Use the same sorting used in Aspen to sort assignments.
@psvenk

psvenk commented Feb 16, 2021

Copy link
Copy Markdown
Member Author

@jadebuckwalter @tektaxi I fixed the assignments issue in 9e12fb2. As for the reports issue, I think that would require some fairly substantial changes to the dropdown code, so I am in favor of moving it to a separate issue.

@jadebuckwalter jadebuckwalter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@psvenk
psvenk merged commit aee2286 into master Feb 16, 2021
@psvenk
psvenk deleted the rest branch February 16, 2021 19:37

@tektaxi tektaxi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants