Skip to content

Commit

Permalink
Fix empty projects
Browse files Browse the repository at this point in the history
  • Loading branch information
N2D4 committed Sep 1, 2024
1 parent 49724b4 commit 703e6ea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/backend/src/app/api/v1/users/crud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export const getUserLastActiveAtMillis = async (userId: string, fallbackTo: numb

// same as userIds.map(userId => getUserLastActiveAtMillis(userId, fallbackTo)), but uses a single query
export const getUsersLastActiveAtMillis = async (userIds: string[], fallbackTo: (number | Date)[]): Promise<number[]> => {
if (userIds.length === 0) {
// Prisma.join throws an error if the array is empty, so we need to handle that case
return [];
}

const events = await prismaClient.$queryRaw<Array<{ userId: string, lastActiveAt: Date }>>`
SELECT data->>'userId' as "userId", MAX("createdAt") as "lastActiveAt"
FROM "Event"
Expand Down

0 comments on commit 703e6ea

Please sign in to comment.