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 #292 from cnpm/issue291-all
Browse files Browse the repository at this point in the history
only return package name in /-/all and /-/all/since, fixed #291
  • Loading branch information
fengmk2 committed Mar 24, 2014
2 parents 7cb7a51 + c1c07cf commit 9cc84ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
15 changes: 12 additions & 3 deletions controllers/registry/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,12 @@ function parseModsForList(updated, mods, ctx) {

exports.listAllModules = function *() {
var updated = Date.now();
var mods = yield Module.listSince(0);
this.body = parseModsForList(updated, mods, this);
var mods = yield Module.listAllNames();
var result = { _updated: updated };
mods.forEach(function (mod) {
result[mod.name] = true;
});
this.body = result;
};

exports.listAllModulesSince = function *() {
Expand All @@ -921,7 +925,12 @@ exports.listAllModulesSince = function *() {
var startkey = Number(query.startkey) || 0;
var updated = Date.now();
var mods = yield Module.listSince(startkey);
this.body = parseModsForList(updated, mods, this);
var result = { _updated: updated };
mods.forEach(function (mod) {
result[mod.name] = true;
});

this.body = result;
};

exports.listAllModuleNames = function *() {
Expand Down
12 changes: 11 additions & 1 deletion proxy/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ LIST_SINCE_SQLS.push(multiline(function () {/*
*/}));
LIST_SINCE_SQLS.push(multiline(function () {/*
SELECT
name, package
distinct(name)
FROM
module
WHERE
Expand All @@ -467,6 +467,16 @@ exports.listSince = function (start, callback) {
});
};

var LIST_ALL_NAME_SQL = multiline(function () {/*
SELECT
distinct(name)
FROM
module;
*/});
exports.listAllNames = function (callback) {
mysql.query(LIST_ALL_NAME_SQL, [], callback);
};

var LIST_SHORT_SQL = multiline(function () {/*
SELECT
distinct(name)
Expand Down
1 change: 0 additions & 1 deletion test/controllers/registry/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ describe('controllers/registry/module.test.js', function () {
res.body._updated.should.be.a.Number;
var keys = Object.keys(res.body);
keys.length.should.be.above(1);
res.body[keys[1]].dist.tarball.should.include('/download/');
done();
});
});
Expand Down

0 comments on commit 9cc84ab

Please sign in to comment.