Made downvote more powerful if there are some views or votes already.

This commit is contained in:
Ajay Ramachandran
2019-08-18 17:57:13 -04:00
parent 6b88719cf6
commit a0bbffaf91

View File

@@ -219,6 +219,13 @@ app.get('/api/voteOnSponsorTime', function (req, res) {
}
}
//check if the increment amount should be multiplied (downvotes have more power if there have been many views)
db.prepare("SELECT votes, views FROM sponsorTimes WHERE UUID = ?").get(UUID, function(err, row) {
if (row != null && (row.votes > 3 || row.views > 4) && incrementAmount < 0) {
//multiply the power of this downvote
incrementAmount *= 4;
}
//update the votes table
if (row != undefined) {
privateDB.prepare("UPDATE votes SET type = ? WHERE userID = ? AND UUID = ?").run(type, userID, UUID);
@@ -234,6 +241,7 @@ app.get('/api/voteOnSponsorTime', function (req, res) {
res.sendStatus(200);
});
});
});
//Endpoint when a sponsorTime is used up
app.get('/api/viewedVideoSponsorTime', function (req, res) {