Syntax fixes to pass tests.

This commit is contained in:
Andrew Lee
2020-04-25 17:11:44 -04:00
parent 35fa384a5b
commit ba555c0a7c

View File

@@ -112,8 +112,11 @@ async function autoModerateSubmission(submission, callback) {
return "Sponsor segment is over 80% of the video."; return "Sponsor segment is over 80% of the video.";
} else { } else {
let overlap = false; let overlap = false;
nb_predictions = fetch("https://ai.neuralblock.app/api/getSponsorSegments?vid=" + submission.videoID).then().then(); http = await fetch("https://ai.neuralblock.app/api/getSponsorSegments?vid=" + submission.videoID);
for (nb_seg in nb_predictions.sponsorSegments){ if (http.status === 500) return false;
nb_predictions = await http.json();
for (const nb_seg of nb_predictions.sponsorSegments){
let head = 0; let head = 0;
let tail = 0; let tail = 0;
// If there's an overlap, find the percentage of overlap. // If there's an overlap, find the percentage of overlap.
@@ -121,13 +124,13 @@ async function autoModerateSubmission(submission, callback) {
head = Math.max(submission.startTime, nb_seg[0]); head = Math.max(submission.startTime, nb_seg[0]);
tail = Math.min(submission.endTime, nb_seg[1]); tail = Math.min(submission.endTime, nb_seg[1]);
} }
if ((tail-head)/(nb_seg[1]-nb_seg[0]) > 0.65){ if ((tail-head)/(nb_seg[1]-nb_seg[0]) >= 0.65){
overlap = true; overlap = true;
break; break;
} }
} }
if (overlap){ if (overlap){
return "Sponsor segment has passed checks."; return false;
} else{ } else{
return "Sponsor segment doesn't have at least 65% match."; return "Sponsor segment doesn't have at least 65% match.";
} }