Raise category change requirement

This commit is contained in:
Ajay Ramachandran
2020-10-27 18:58:21 -04:00
committed by GitHub
parent c462323dd5
commit 06fa6eb874

View File

@@ -179,7 +179,7 @@ function categoryVote(UUID, userID, isVIP, category, hashedIP, res) {
// See if the submissions category is ready to change // See if the submissions category is ready to change
let currentCategoryInfo = db.prepare("get", "select votes from categoryVotes where UUID = ? and category = ?", [UUID, currentCategory.category]); let currentCategoryInfo = db.prepare("get", "select votes from categoryVotes where UUID = ? and category = ?", [UUID, currentCategory.category]);
let submissionInfo = db.prepare("get", "SELECT userID, timeSubmitted FROM sponsorTimes WHERE UUID = ?", [UUID]); let submissionInfo = db.prepare("get", "SELECT userID, timeSubmitted, votes FROM sponsorTimes WHERE UUID = ?", [UUID]);
let isSubmissionVIP = submissionInfo && isUserVIP(submissionInfo.userID); let isSubmissionVIP = submissionInfo && isUserVIP(submissionInfo.userID);
let startingVotes = isSubmissionVIP ? 10000 : 1; let startingVotes = isSubmissionVIP ? 10000 : 1;
@@ -198,7 +198,7 @@ function categoryVote(UUID, userID, isVIP, category, hashedIP, res) {
//TODO: In the future, raise this number from zero to make it harder to change categories //TODO: In the future, raise this number from zero to make it harder to change categories
// VIPs change it every time // VIPs change it every time
if (nextCategoryCount - currentCategoryCount >= 0 || isVIP) { if (nextCategoryCount - currentCategoryCount >= (submissionInfo ? Math.max(Math.ciel(submissionInfo.votes / 2), 1) : 1) || isVIP) {
// Replace the category // Replace the category
db.prepare('run', "update sponsorTimes set category = ? where UUID = ?", [category, UUID]); db.prepare('run', "update sponsorTimes set category = ? where UUID = ?", [category, UUID]);
} }