Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
hofstede-matheus committed Oct 12, 2023
1 parent 8823405 commit ebac8a8
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ export class TypeOrmQueuesRepository implements QueueRepository {
queueId: string,
registrationId: string,
): Promise<PositionInQueueWithDesk> {
console.log('queueId', queueId);
console.log('registrationId', registrationId);

const clientsInQueueFromDatabase = await this.queuesRepository.query(
`
SELECT
Expand All @@ -344,6 +347,7 @@ export class TypeOrmQueuesRepository implements QueueRepository {
`,
[queueId],
);
console.log('clientsInQueueFromDatabase', clientsInQueueFromDatabase);

const lastClientCalledFromQueue = await this.queuesRepository.query(
`
Expand All @@ -366,6 +370,15 @@ export class TypeOrmQueuesRepository implements QueueRepository {
`,
[queueId],
);
console.log('lastClientCalledFromQueue', lastClientCalledFromQueue);
console.log(
'lastClientCalledFromQueue.length',
lastClientCalledFromQueue.length,
);
console.log(
'lastClientCalledFromQueue[0].registration_id',
lastClientCalledFromQueue[0].registration_id,
);

if (
lastClientCalledFromQueue.length > 0 &&
Expand All @@ -384,6 +397,8 @@ export class TypeOrmQueuesRepository implements QueueRepository {
`,
[lastClientCalledFromQueue[0].desk_id],
);
console.log('desk', desk);

return {
position: 0,
desk: {
Expand All @@ -410,16 +425,19 @@ export class TypeOrmQueuesRepository implements QueueRepository {
} as ClientInQueue;
},
);
console.log('clientsInQueue', clientsInQueue);

const position = clientsInQueue.findIndex(
(client) => client.registrationId === registrationId,
);
console.log('position', position);

if (position === -1) {
return {
position: -1,
};
}

return {
position: position + 1,
};
Expand Down

0 comments on commit ebac8a8

Please sign in to comment.