Skip to content

Commit

Permalink
Revert debugging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan2u committed Sep 24, 2024
1 parent a4e4d5d commit d61fd62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
9 changes: 0 additions & 9 deletions src/init-dependencies/event-store/events-from-rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
);
22 changes: 7 additions & 15 deletions src/init-dependencies/event-store/get-all-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down

0 comments on commit d61fd62

Please sign in to comment.