Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbanSdl committed May 15, 2024
1 parent bbe44cb commit ccb771d
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,23 @@ export async function getWaitingOpening(userLogin: string) {
where: {
date: null,
code: { not: null },
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
borrow: {
OR: [
null,
{ createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) } },
],
},
AND: [
{
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
},
{
OR: [
{
borrow: null,
},
{
borrow: {
createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) },
},
},
],
},
],
},
...OPENING_INCLUDE_BEFORE_FORMATTING,
});
Expand All @@ -98,13 +108,23 @@ export async function getWaitingOpeningWithValidCode(userLogin: string) {
const opening = await prisma.opening.findFirst({
where: {
...prismaUtils.validOpening,
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
borrow: {
OR: [
null,
{ createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) } },
],
},
AND: [
{
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
},
{
OR: [
{
borrow: null,
},
{
borrow: {
createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) },
},
},
],
},
],
},
...OPENING_INCLUDE_BEFORE_FORMATTING,
});
Expand Down

0 comments on commit ccb771d

Please sign in to comment.