Commit 53aa54de authored by Girish Ramakrishnan's avatar Girish Ramakrishnan

order by lastSuccessfulSyncAt to give all projects a chance

parent 98a93c5b
......@@ -71,7 +71,8 @@ function projectsList(userId, callback) {
assert.strictEqual(typeof userId, 'string');
assert.strictEqual(typeof callback, 'function');
db.query('SELECT projects.*,releases.version,releases.createdAt FROM projects LEFT JOIN releases on releases.id = (SELECT releases.id FROM releases WHERE projectId=projects.id ORDER BY createdAt DESC LIMIT 1) WHERE userId=?', [ userId ], function (error, result) {
// we order by lastSuccessfulSyncAt so that if we hit API rate limits, each project gets a chance eventually
db.query('SELECT projects.*,releases.version,releases.createdAt FROM projects LEFT JOIN releases on releases.id = (SELECT releases.id FROM releases WHERE projectId=projects.id ORDER BY createdAt DESC LIMIT 1) WHERE userId=? ORDER BY lastSuccessfulSyncAt ASC', [ userId ], function (error, result) {
if (error) return callback(error);
result.forEach(projectPostprocess);
......
......@@ -189,10 +189,10 @@ function syncReleasesByUser(user, callback) {
assert.strictEqual(typeof user, 'object');
assert.strictEqual(typeof callback, 'function');
database.projects.list(user.id, function (error, result) {
database.projects.list(user.id, function (error, projects) {
if (error) return callback(error);
async.eachSeries(result, function (project, callback) {
async.eachSeries(projects, function (project, callback) {
syncReleasesByProject(user, project, callback);
}, function (error) {
if (error) console.error(error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment