Merge pull request #20 from ajayyy/experimental

Made downvote more powerful if there are some views or votes already
This commit is contained in:
Ajay Ramachandran
2019-08-18 17:57:32 -04:00
committed by GitHub

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 //update the votes table
if (row != undefined) { if (row != undefined) {
privateDB.prepare("UPDATE votes SET type = ? WHERE userID = ? AND UUID = ?").run(type, userID, UUID); 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); res.sendStatus(200);
}); });
}); });
});
//Endpoint when a sponsorTime is used up //Endpoint when a sponsorTime is used up
app.get('/api/viewedVideoSponsorTime', function (req, res) { app.get('/api/viewedVideoSponsorTime', function (req, res) {