Skip to content

Commit

Permalink
feat: add retrieve cars planning
Browse files Browse the repository at this point in the history
  • Loading branch information
haroldcohen committed Oct 18, 2023
1 parent 4643b75 commit b3029c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class RetrieveCarsPlanning {
actorId: query.actor.id,
});

return await this.carReadRepository.getCarsPlanning({
return this.carReadRepository.getCarsPlanning({
startDate: query.startDate,
endDate: query.endDate,
limit: query.limit,
Expand Down
5 changes: 3 additions & 2 deletions src/core/useCases/common/cursors/encodeDecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const encodeCursor = (cursor: string, order: string): string => {
if (cursor === ''){
return '';
}
return btoa(`${order == 'gte' ? 'next' : 'prev'}___${cursor}`);
return btoa(`${order === 'gte' ? 'next' : 'prev'}___${cursor}`);
}

export const decodeCursor = (cursor: string): DecodedCursor => {
Expand All @@ -20,11 +20,12 @@ export const decodeCursor = (cursor: string): DecodedCursor => {
address: ''
}
}
// eslint-disable-next-line prefer-regex-literals
const cursorMatch = atob(cursor).match(new RegExp('^(?<order>(next|prev))___(?<address>[\\w\'-]+)$')) as RegExpMatchArray;
const groups = cursorMatch.groups as any;

return {
order: groups.order == 'next' ? 'gte' : 'lte',
order: groups.order === 'next' ? 'gte' : 'lte',
address: groups.address as string,
}
}
2 changes: 2 additions & 0 deletions src/driven/repositories/inMemory/car/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export default class InMemoryCarReadRepository implements CarReadRepositoryInter
return false;
}
retrievedCars.push(car);

return car;
});
const planning = {
cars: {},
Expand Down

0 comments on commit b3029c0

Please sign in to comment.