Merge pull request #92 from Joe-Dowd/mysql-conv

Added ability to query a mysql database
This commit is contained in:
Ajay Ramachandran
2020-07-25 19:01:57 -04:00
committed by GitHub
21 changed files with 180 additions and 113 deletions

View File

@@ -121,9 +121,10 @@ function handleGetSegments(req, res) {
for (const category of categories) {
const categorySegments = db
.prepare(
'SELECT startTime, endTime, votes, UUID, shadowHidden FROM sponsorTimes WHERE videoID = ? and category = ? ORDER BY startTime'
'all',
'SELECT startTime, endTime, votes, UUID, shadowHidden FROM sponsorTimes WHERE videoID = ? and category = ? ORDER BY startTime',
[videoID, category]
)
.all(videoID, category)
.filter(segment => {
if (segment.votes < -1) {
return false; //too untrustworthy, just ignore it
@@ -136,9 +137,7 @@ function handleGetSegments(req, res) {
}
if (shadowHiddenSegments === undefined) {
shadowHiddenSegments = privateDB
.prepare('SELECT hashedIP FROM sponsorTimes WHERE videoID = ?')
.all(videoID);
shadowHiddenSegments = privateDB.prepare('all', 'SELECT hashedIP FROM sponsorTimes WHERE videoID = ?', [videoID]);
}
//if this isn't their ip, don't send it to them