Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #117 from fengmk2/list-since
Browse files Browse the repository at this point in the history
select ids from tag
  • Loading branch information
fengmk2 committed Dec 20, 2013
2 parents d88ecba + 67d3adb commit 460e7f4
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions proxy/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,35 +227,23 @@ exports.listByName = function (name, callback) {
};

var LIST_SINCE_SQLS = [
'SELECT distinct(name) AS name FROM module WHERE publish_time > ?;',
'SELECT module_id FROM tag WHERE tag="latest" AND name IN (?);',
'SELECT module_id FROM tag WHERE tag="latest" AND gmt_modified>?',
'SELECT name, package FROM module WHERE id IN (?);'
];
exports.listSince = function (start, callback) {
var ep = eventproxy.create();
ep.fail(callback);
mysql.query(LIST_SINCE_SQLS[0], [start], ep.done(function (rows) {
mysql.query(LIST_SINCE_SQLS[0], [new Date(start)], ep.done(function (rows) {
if (!rows || rows.length === 0) {
return callback(null, []);
}
ep.emit('names', rows.map(function (r) {
return r.name;
ep.emit('ids', rows.map(function (r) {
return r.module_id;
}));
}));

ep.once('names', function (names) {
mysql.query(LIST_SINCE_SQLS[1], [names], ep.done(function (rows) {
if (!rows || rows.length === 0) {
return callback(null, []);
}
ep.emit('ids', rows.map(function (r) {
return r.module_id;
}));
}));
});

ep.once('ids', function (ids) {
mysql.query(LIST_SINCE_SQLS[2], [ids], callback);
mysql.query(LIST_SINCE_SQLS[1], [ids], callback);
});
};

Expand Down

0 comments on commit 460e7f4

Please sign in to comment.