diff --git a/src/init-dependencies/event-store/events-from-rows.ts b/src/init-dependencies/event-store/events-from-rows.ts index fdbcc4df..eed33bac 100644 --- a/src/init-dependencies/event-store/events-from-rows.ts +++ b/src/init-dependencies/event-store/events-from-rows.ts @@ -21,15 +21,6 @@ export const eventsFromRows = (rows: EventsTable['rows']) => pipe( rows, E.traverseArray(reshapeRowToEvent), - E.chain(a => { - for (const x of a) { - if (E.isLeft(DomainEvent.decode(x))) { - console.log('Failed to decode'); - console.log(x); - } - } - return E.right(a); - }), E.chain(t.readonlyArray(DomainEvent).decode), E.mapLeft(internalCodecFailure('Failed to get events from DB')) ); diff --git a/src/init-dependencies/event-store/get-all-events.ts b/src/init-dependencies/event-store/get-all-events.ts index e722e5cf..aa67095a 100644 --- a/src/init-dependencies/event-store/get-all-events.ts +++ b/src/init-dependencies/event-store/get-all-events.ts @@ -18,30 +18,22 @@ export const getAllEvents = () => pipe( TE.tryCatch( - () => { - console.log('Getting all events...'); - const result = dbClient.execute({ + () => + dbClient.execute({ sql: "SELECT * FROM events WHERE event_type != 'EquipmentTrainingQuizResult'", args: {}, - }); - console.log('Got all events'); - return result; - }, + }), failureWithStatus( 'Failed to query database', StatusCodes.INTERNAL_SERVER_ERROR ) ), - TE.chainEitherK(raw => { - console.log('Decoding events table'); - const result = flow( + TE.chainEitherK( + flow( EventsTable.decode, E.mapLeft(internalCodecFailure('Failed to decode DB table')) - )(raw); - console.log('Decoded result'); - console.log(result); - return result; - }), + ) + ), TE.map(table => table.rows), TE.chainEitherK(eventsFromRows) );