Open dillondesilva opened 5 months ago
Thanks for this! Maybe @GoodGameRuler can comment on this too?
I have a few comments on this @dillondesilva. I am quite impressed with the alternative solution.
Firstly, we have to remember that first and foremost UniTrack will be a degree planning service. That means the requirement of keeping track of exact unit information isn't necessary. This means that we can have outdated information.
Secondly, I would prefer not to do client-side requests as that may cause issues (especially when making mistakes with react hooks). I am sure USYD handles this well, but it also isn't too hard to fetch all this data once and store it. It would also make it easier down the line when we do data scraping.
With the above two points, I think the most optimal solution would be to write a script that runs through this endpoint on COMP, INFO, SOFT, DATA, and ISYS as the input query, and convert them into a series of SQL insert queries, that we can just run once. We are currently working on integrating Vercel Postgres which also introduces various optimisation benefits I believe. What are your thoughts @dillondesilva?
I will point out that I had a look at the network queries for an individual unit page, and as far as I can see there is no endpoint to be exploited there. So to get detailed unit information like pre-reqs, we will have to data scrape. However, this is a very viable solution until we think about scraping further down the line.
Hey @GoodGameRuler
Yeah all of the above sounds like a great idea! I had to go back and quickly refresh my knowledge on fetching requests, CORS, etc and I can see why client-side request isn't a great idea. I agree having our own endpoint to handle this stuff seems like the go - what do you think about using NextJS API routes?
For the long term, using Vercel Postgres sounds like a good idea (especially for something like a pre-req tree). I also noticed that actual UoS pages such as this one are server-side rendered so web scraping is something that needs to happen eventually and it wouldn't hurt to start it now.
EDIT: Just checkout the major-postgresSetup
branch which is using API routes :P I'll close this issue for now as it sounds more like the next step is API development related
Some updates. Have accomplished a basic sketch of what you suggested.
While this is completely functional at the moment and with minimal work I could display the Unit Titles, and redirect to the unit page, this is a select type input not a text type, which means I'll need to change a bit.
Usage
Some updates. Have accomplished a basic sketch of what you suggested.
While this is completely functional at the moment and with minimal work I could display the Unit Titles, and redirect to the unit page, this is a select type input not a text type, which means I'll need to change a bit.
That works! Could you reuse the styling we already have and just convert it to a select option?
That works! Could you reuse the styling we already have and just convert it to a select option?
Unfortunately we want to be able to search for multiple units at the same time. So pressing enter should display all matching units. The select doesn't allow for that at the moment.
With selects you can't search you have to select.
Some updates. Have accomplished a basic sketch of what you suggested.
While this is completely functional at the moment and with minimal work I could display the Unit Titles, and redirect to the unit page, this is a select type input not a text type, which means I'll need to change a bit.
Looks great!
Stale issue message - 7 days till automatic close
On the route /units, I am unable to utilise the search bar functionality feature. Would love to see this implemented!
I did some analysis (Via Dev Tools -> Network) on https://www.sydney.edu.au/units page to see if I could obtain the REST API endpoint and response body for querying information about a unit.
When I query "COMP" into the search bar, I notice a request is made to the following resource:
https://www.sydney.edu.au/s/search.html?query=COMP&collection=Sydney-Curriculum_UOS&profile=_default_preview&form=custom-json&start_rank=1
.The corresponding response body is of the form:
I've omitted the request/response headers from this post as they are quite lengthy but happy to include them in comments if necessary.
This endpoint seems fairly simple to call and it is publicly accessible. A client-side fetch request should suffice for completing the unit search feature but there may be other approaches as well.
Hopefully this information gives enough of a jump start for working on the feature!