-
Notifications
You must be signed in to change notification settings - Fork 2
ZYancey/CSBot/413/TSNativeRoomfinder #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…-CS-Discord/CSBot into zyancey/CSBot/413/TSNativeRoomfinder
AverageHelper
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still going through this, but I found a few things to start with:
| */ | ||
| async function getRoomInfo(yearTerm: string, building: string, room: string): Promise<RoomInfo> { | ||
| const html = await openOrDownloadFile(yearTerm, `${building}-${room}.html`, async () => { | ||
| const response = await axios.post( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can avoid the additional dependency on axios if we use the built-in fetch API instead
|
|
||
| ### /scraperooms | ||
|
|
||
| **[Admin Only]** Manually triggers the room finder data scraper to update the database with current semester schedule information. This is useful for forcing an immediate update without waiting for the automatic Sunday schedule. Takes 10-15 minutes to complete and runs in the background. Shows real-time progress if a scrape is already running. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| **[Admin Only]** Manually triggers the room finder data scraper to update the database with current semester schedule information. This is useful for forcing an immediate update without waiting for the automatic Sunday schedule. Takes 10-15 minutes to complete and runs in the background. Shows real-time progress if a scrape is already running. | |
| **[Admin Only by default]** Manually triggers the room finder data scraper to update the database with current semester schedule information. This is useful for forcing an immediate update without waiting for the automatic Sunday schedule. Takes 10-15 minutes to complete and runs in the background. Shows real-time progress if a scrape is already running. |
| - **between** - Find rooms available during a time range on specific day(s) | ||
| - **when** - Check when a specific room is next available | ||
|
|
||
| The room finder automatically updates its database every Sunday at 2 AM to stay current with the semester schedule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The room finder automatically updates its database every Sunday at 2 AM to stay current with the semester schedule. | |
| The room finder automatically updates its database every Sunday at 2 AM to stay current with the semester schedule. Use [`/scraperooms`](#scraperooms) to update the database manually. |
| .setFooter({ | ||
| text: 'BYU Room Finder', | ||
| // Going to locally host this on my server soon, I'll make that change when I come back and add thumbnails for the building searches | ||
| text: 'BYU Room Finder (Native)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normal users don't usually care about this implementation detail, imo
| text: 'BYU Room Finder (Native)', | |
| text: 'BYU Room Finder', |
| SlashCommandSubcommandBuilder, | ||
| SlashCommandStringOption, | ||
| SlashCommandNumberOption, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| SlashCommandSubcommandBuilder, | |
| SlashCommandStringOption, | |
| SlashCommandNumberOption, | |
| type SlashCommandSubcommandBuilder, | |
| type SlashCommandStringOption, | |
| type SlashCommandNumberOption, |
Ports https://github.com/ZYancey/BYU-Room-Finder-Python-Backend From Postgresql to sqlite to be compatible with our bot's existing DB and ports the entire codebase from Python to Typescript. This was a pain to do but I've done a bunch of testing and the accuracy of the roomfinder actually went up quite a bit as a result of the port.

The scraper is also functional but in an effort to not spam BYU servers, you can seed the scraper folder with this pre-scraped data and it will seed the DB as expected.
scraper.zip
Additionally, now that the scraper lives in CSBot code I added a simple cron to run the scraper at 2am on Sundays, if it is still the same term as the last scrape, it won't pull any new files unless rooms have been added to the schedule. That being said, I also added an admin only scrape command that fires off the scraper manually.
