Skip to content

Commit 1a60308

Browse files
authored
Merge pull request #3 from ajayyy/experimental
Fixed issues caused by last pull request
2 parents 0e50314 + 03fcda5 commit 1a60308

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ app.get('/api/postVideoSponsorTimes', function (req, res) {
117117

118118
if (row == null) {
119119
//not a duplicate, execute query
120-
db.prepare("INSERT INTO sponsorTimes VALUES(?, ?, ?, ?, ?, ?, ?)").run(videoID, startTime, endTime, UUID, userID, hashedIP, timeSubmitted);
120+
db.prepare("INSERT INTO sponsorTimes VALUES(?, ?, ?, ?, ?, ?, ?, ?)").run(videoID, startTime, endTime, 0, UUID, userID, hashedIP, timeSubmitted);
121121

122122
res.sendStatus(200);
123123
} else {
@@ -241,7 +241,9 @@ function getVoteOrganisedSponsorTimes(sponsorTimes, votes, UUIDs) {
241241
}
242242

243243
//if there are too many indexes, find the best 4
244-
finalSponsorTimeIndexes = getWeightedRandomChoice(finalSponsorTimeIndexes, votes, 4).finalChoices;
244+
if (finalSponsorTimeIndexes.length > 4) {
245+
finalSponsorTimeIndexes = getWeightedRandomChoice(finalSponsorTimeIndexes, votes, 4).finalChoices;
246+
}
245247

246248
//convert this to a final array to return
247249
let finalSponsorTimes = [];

0 commit comments

Comments
 (0)