diff --git a/src/eventlog.js b/src/eventlog.js index 1ca070d9a..e41d7cebe 100644 --- a/src/eventlog.js +++ b/src/eventlog.js @@ -4,7 +4,7 @@ exports = module.exports = { add, upsertLoginEvent, get, - getAllPaged, + listPaged, cleanup, _clear: clear, @@ -147,7 +147,7 @@ async function get(id) { return postProcess(result[0]); } -async function getAllPaged(actions, search, page, perPage) { +async function listPaged(actions, search, page, perPage) { assert(Array.isArray(actions)); assert(typeof search === 'string' || search === null); assert.strictEqual(typeof page, 'number'); diff --git a/src/notifications.js b/src/notifications.js index ad7ba2fb5..2df1030ef 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -195,7 +195,7 @@ async function backupFailed(eventId, taskId, errorMessage) { await add(eventId, 'Backup failed', `Backup failed: ${errorMessage}. Logs are available [here](/logs.html?taskId=${taskId}).`); // only send mail if the past 3 automated backups failed - const backupEvents = await eventlog.getAllPaged([eventlog.ACTION_BACKUP_FINISH], null /* search */, 1, 20); + const backupEvents = await eventlog.listPaged([eventlog.ACTION_BACKUP_FINISH], null /* search */, 1, 20); let count = 0; for (const event of backupEvents) { if (!event.data.errorMessage) return; // successful backup (manual or cron) diff --git a/src/routes/eventlog.js b/src/routes/eventlog.js index 396173c22..55e569092 100644 --- a/src/routes/eventlog.js +++ b/src/routes/eventlog.js @@ -33,7 +33,7 @@ async function list(req, res, next) { const actions = req.query.actions ? req.query.actions.split(',').map(function (s) { return s.trim(); }) : []; if (req.query.action) actions.push(req.query.action); - const [error, eventlogs] = await safe(eventlog.getAllPaged(actions, req.query.search || null, page, perPage)); + const [error, eventlogs] = await safe(eventlog.listPaged(actions, req.query.search || null, page, perPage)); if (error) return next(BoxError.toHttpError(error)); next(new HttpSuccess(200, { eventlogs })); diff --git a/src/test/eventlog-test.js b/src/test/eventlog-test.js index ff8ae19fe..6347f1f1c 100644 --- a/src/test/eventlog-test.js +++ b/src/test/eventlog-test.js @@ -47,8 +47,8 @@ describe('Eventlog', function () { expect(result).to.be(null); }); - it('getAllPaged succeeds', async function () { - const results = await eventlog.getAllPaged([], null, 1, 1); + it('listPaged succeeds', async function () { + const results = await eventlog.listPaged([], null, 1, 1); expect(results).to.be.an(Array); expect(results.length).to.be(1); @@ -58,8 +58,8 @@ describe('Eventlog', function () { expect(results[0].data).to.be.eql({ appId: 'thatapp' }); }); - it('getAllPaged succeeds with source search', async function () { - const results = await eventlog.getAllPaged([], '1.2.3.4', 1, 1); + it('listPaged succeeds with source search', async function () { + const results = await eventlog.listPaged([], '1.2.3.4', 1, 1); expect(results).to.be.an(Array); expect(results.length).to.be(1); expect(results[0].id).to.be(eventId); @@ -68,8 +68,8 @@ describe('Eventlog', function () { expect(results[0].data).to.be.eql({ appId: 'thatapp' }); }); - it('getAllPaged succeeds with data search', async function () { - const results = await eventlog.getAllPaged([], 'thatapp', 1, 1); + it('listPaged succeeds with data search', async function () { + const results = await eventlog.listPaged([], 'thatapp', 1, 1); expect(results).to.be.an(Array); expect(results.length).to.be(1); expect(results[0].id).to.be(eventId); @@ -122,7 +122,7 @@ describe('Eventlog', function () { const id = await eventlog.add('some.event', { ip: '1.2.3.4' }, { appId: 'thatapp' }); await eventlog.cleanup({ creationTime: new Date(Date.now() - 1000) }); // 1 second ago - let results = await eventlog.getAllPaged([], null, 1, 100); + let results = await eventlog.listPaged([], null, 1, 100); expect(results.length).to.be(1); expect(results[0].id).to.be(id);