From d01b81494090d3f999313e3dc6daa6cb10622a4d Mon Sep 17 00:00:00 2001 From: Joakim Larsson Date: Mon, 26 Aug 2024 13:19:14 +0200 Subject: [PATCH] picked/unpicked event logging --- src/events/eventlogging-notifications.ts | 6 ++++-- src/events/mongo-event-log/mongo-event-log-service.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/events/eventlogging-notifications.ts b/src/events/eventlogging-notifications.ts index 97fbe46..eefb5cf 100644 --- a/src/events/eventlogging-notifications.ts +++ b/src/events/eventlogging-notifications.ts @@ -47,8 +47,10 @@ export const createEventLoggingNotifications = ( advertWasReturnedOwner: async () => undefined, advertWaitlistAvailable: async () => undefined, advertWasPicked: async () => undefined, - advertWasPickedOwner: async () => undefined, - advertWasUnpickedOwner: async () => undefined, + advertWasPickedOwner: (to, by, advert) => + log('advert-was-picked', { by, advert }), + advertWasUnpickedOwner: (to, by, advert) => + log('advert-was-unpicked', { by, advert }), advertCollectWasRenewed: (to, by, quantity, advert) => log('advert-collect-was-renewed', { by, quantity, advert }), advertCollectWasRenewedOwner: async () => undefined, diff --git a/src/events/mongo-event-log/mongo-event-log-service.ts b/src/events/mongo-event-log/mongo-event-log-service.ts index 923737b..a7a1afb 100644 --- a/src/events/mongo-event-log/mongo-event-log-service.ts +++ b/src/events/mongo-event-log/mongo-event-log-service.ts @@ -14,12 +14,13 @@ export const createMongoEventLogService = ({ event, }) }, - getEvents: async ({ from, to }) => { + getEvents: async ({ from, to, advertId }) => { const collection = await getCollection() const cursor = collection.find({ $and: [ from && { 'event.at': { $gte: from.toISOString() } }, to && { 'event.at': { $lte: to.toISOString() } }, + advertId && { 'event.advertId': advertId }, ].filter(v => v), } as Filter)