X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=server%2Fmodels%2FProblem.js;h=2d29520fdce33002634d1b1cdc2a7a9bd9963f83;hb=2c5d7b20742b802d9c47916915c1114bcfc9a9c3;hp=bcbefc5f251300c0d2ea64a2be658f62434d97fe;hpb=68e19a449db7a12e0a168e99cd750d985c983ba1;p=vchess.git diff --git a/server/models/Problem.js b/server/models/Problem.js index bcbefc5f..2d29520f 100644 --- a/server/models/Problem.js +++ b/server/models/Problem.js @@ -33,12 +33,16 @@ const ProblemModel = { }); }, - getNext: function(cursor, cb) { + getNext: function(uid, onlyMine, cursor, cb) { + let condition = ""; + if (onlyMine) condition = "AND uid = " + uid + " "; + else if (!!uid) condition = "AND uid <> " + uid + " "; db.serialize(function() { const query = "SELECT * " + "FROM Problems " + "WHERE added < " + cursor + " " + + condition + "ORDER BY added DESC " + "LIMIT 20"; //TODO: 20 is arbitrary db.all(query, (err, problems) => {