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

Shorter end of election rescrape interval #82

Merged
merged 2 commits into from
Aug 27, 2021
Merged

Conversation

samliew
Copy link
Owner

@samliew samliew commented Aug 26, 2021

#74 - Bot should rescrape election page for winners during election end

Added cancel cron jobs if election dates were changed. Still need to create a function to check date changes (#80)

return;
}

// After rescraping, the election is over but we do not have winners yet
else if(election.phase === 'ended' && !election.arrWinners.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just noting for myself - should probably abstract this away into a hasWinners() : boolean instance method on the Election class

else if (election.phase === 'ended' && election.prev.arrWinners.length != election.arrWinners.length && election.arrWinners.length > 0) {
await announceWinners(election);

// No more need to scrape the election or greet the room
BotConfig.scrapeIntervalMins = 999999;
Copy link
Collaborator

@Oaphi Oaphi Aug 26, 2021

Choose a reason for hiding this comment

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

👍 What do you think of making it -1 instead, though? 999999 makes me a little uncomfortable (like the z-index inflation) that it's actually possible to happen under some unstable condition. Not sure it it's worth thinking about, though

Copy link
Owner Author

@samliew samliew Aug 27, 2021

Choose a reason for hiding this comment

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

I'm not convinced a negative number will work https://stackoverflow.com/q/8430966

We could even set it back to the default of 10 mins and it will be ok.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, sorry, I was unclear about what I mean - I didn't want to make it -1 and then pass that unconditionally to setTimeout but rather make it a special value that is then guarded against before setting the timeout. It would also be idiomatic since lastMessageTime also uses -1 as a special value. In any case, this is just a note that we could maybe think about after more pressing matters

@samliew samliew merged commit edb091b into master Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features and enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bot should rescrape election page for winners during election end
2 participants