Skip to content

Commit

Permalink
chore: return all logs if no collection specified
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoSilvestr committed Dec 13, 2023
1 parent 52b38c0 commit 389af57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
8 changes: 1 addition & 7 deletions docker/src/plugins/admin/routes/v1/entriesAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ const entriesAdmin = {
type: 'string',
description: 'Collection progress',
example: 'bioassays',
default: 'bioassays',
},
limit: {
type: 'number',
description: 'limit logs message',
example: 10,
default: 50,
default: '',
},
fields: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,24 @@ export async function entriesAdminHandler(request) {

let {
collectionToSearch = '',
limit = 0,
fields = 'state,seq,date,sources,logs',
fields = '_id,state,seq,dateStart,dateEnd,logs,sources',
} = request.query;
let connection;
try {
connection = new OctoChemConnection();
const collection = await connection.getCollection('admin');

debug.trace(JSON.stringify({ collectionToSearch }));
let formatedFields = getFields(fields);
if (formatedFields.logs) {
formatedFields.logs = { $slice: ['$logs', Number(limit)] };
let matchParameter = {};
if (collectionToSearch !== '') {
matchParameter = {
_id: `${collectionToSearch}_progress`,
};
}

const results = await collection
.aggregate([
{
$match: {
_id: `${collectionToSearch}_progress`,
},
$match: matchParameter,
},
{
$project: formatedFields,
Expand Down

0 comments on commit 389af57

Please sign in to comment.