X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fmodels%2FProblem.js;h=2d29520fdce33002634d1b1cdc2a7a9bd9963f83;hp=bcbefc5f251300c0d2ea64a2be658f62434d97fe;hb=84fc0f02d3d399af66c40b3e9994f67b415ffd0e;hpb=68ff39135865a7b68d36b9f0be2633f5296ab091 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) => {