Skip to content

Repositories page specifies an incorrect DB query and only works because it is ignored #947

@kriswest

Description

@kriswest

Describe the bug
The repositories page route specifies a default query with a filter that is not correct for repositories (as they don't have the type field specified:

const query = {
type: 'push',
};
for (const k in req.query) {
if (!k) continue;
if (k === 'limit') continue;
if (k === 'skip') continue;
let v = req.query[k];
if (v === 'false') v = false;
if (v === 'true') v = true;
query[k] = v;
}
const qd = await db.getRepos(query);

Meanwhile the DB implementations ignore the query passed in, which is the only reason that the page displays any repos (as they all would have been hidden by the filter):

File DB client:

exports.getRepos = async (query = {}) => {
return new Promise((resolve, reject) => {
db.find({}, (err, docs) => {

Mongo:

exports.getRepos = async (query = {}) => {
const collection = await connect(cnName);
return collection.find().toArray();
};

Both errors should be fixed. The query parameter should be retained for future use in paginating and filtering results.

Expected behavior

  • The default query for the repos page should be empty so all results are returned
  • The DB client implementations should handle query parameters to support pagination etc. in future.

Additional context
I'll raise PR to correct this in the repos page and at least the file client, perhaps also mongo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions