Skip to content
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

Add quick action to check whether the CS building is open #112

Open
CarrotManMatt opened this issue Dec 11, 2023 · 7 comments
Open

Add quick action to check whether the CS building is open #112

CarrotManMatt opened this issue Dec 11, 2023 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@CarrotManMatt
Copy link
Member

Using either webscraping or the API (if it gets developed) of https://iscsopen.com TeXBot should provide information on whether the CS building is open.

A credits message should also be added to mention that the information is retrieved from https://iscsopen.com.

Suggestions/reasons on whether or not to include this feature are welcomed.

@CarrotManMatt CarrotManMatt added the enhancement New feature or request label Dec 11, 2023
@codemicro
Copy link
Member

codemicro commented Dec 11, 2023

Matt you do not need an API for this.

var currentTime = new Date();
var currentHour = currentTime.getHours();
var currentDay = currentTime.getDay();

var isOpen = false;

if (studentType === 'non-taught' || (studentType === 'taught' && (currentHour >= 9 && currentHour < 23 && currentDay >= 1 && currentDay <= 5) || (currentHour >= 9 && currentHour < 17 && (currentDay === 0 || currentDay === 6)))) {
    isOpen = true
}

@sapphyree
Copy link
Contributor

Matt you do not need an API for this.

var currentTime = new Date();
var currentHour = currentTime.getHours();
var currentDay = currentTime.getDay();

var isOpen = false;

if (studentType === 'non-taught' || (studentType === 'taught' && (currentHour >= 9 && currentHour < 23 && currentDay >= 1 && currentDay <= 5) || (currentHour >= 9 && currentHour < 17 && (currentDay === 0 || currentDay === 6)))) {
    isOpen = true
}

Whilst I agree here, I'd recommend the removal of magic numbers + the consolidation of these conditionals to constants that are defined outside of the main conditional for clarity.

i.e: IS_NON_TAUGHT_STUDENT = studentType === 'non-taught'

@CarrotManMatt
Copy link
Member Author

Matt you do not need an API for this.

var currentTime = new Date();
var currentHour = currentTime.getHours();
var currentDay = currentTime.getDay();

var isOpen = false;

if (studentType === 'non-taught' || (studentType === 'taught' && (currentHour >= 9 && currentHour < 23 && currentDay >= 1 && currentDay <= 5) || (currentHour >= 9 && currentHour < 17 && (currentDay === 0 || currentDay === 6)))) {
    isOpen = true
}

Admittedly the solution is not very complex, however I do not want to have to deal with updating the rules for edge-cases & holidays, especially when an existing solution exists (https://iscsopen.com), which is actively maintained by someone else

@codemicro
Copy link
Member

No offence to Dak, but I highly doubt that iscsopen is going to be accurate long-term.

@CarrotManMatt
Copy link
Member Author

However, I expect get_effort(DAK) > get_effort(MATT). So for the mid-term it would be?

@FrozenDude101
Copy link
Contributor

Any version of this isn't going to be accurate long term.
There isn't an API/website for this that isn't manually updated to include open/close dates.

@CarrotManMatt
Copy link
Member Author

Any version of this isn't going to be accurate long term. There isn't an API/website for this that isn't manually updated to include open/close dates.

Agreed. Therefore I would be more willing to rely on a developer, whose sole focus is ensuring the opening-times accuracy, rather than a developer that has many other issues to deal with (🥲).

@CarrotManMatt CarrotManMatt added the good first issue Good for newcomers label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants