Skip to content

Commit ccb771d

Browse files
committed
fix
1 parent bbe44cb commit ccb771d

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

web/src/utils.ts

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,23 @@ export async function getWaitingOpening(userLogin: string) {
8181
where: {
8282
date: null,
8383
code: { not: null },
84-
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
85-
borrow: {
86-
OR: [
87-
null,
88-
{ createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) } },
89-
],
90-
},
84+
AND: [
85+
{
86+
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
87+
},
88+
{
89+
OR: [
90+
{
91+
borrow: null,
92+
},
93+
{
94+
borrow: {
95+
createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) },
96+
},
97+
},
98+
],
99+
},
100+
],
91101
},
92102
...OPENING_INCLUDE_BEFORE_FORMATTING,
93103
});
@@ -98,13 +108,23 @@ export async function getWaitingOpeningWithValidCode(userLogin: string) {
98108
const opening = await prisma.opening.findFirst({
99109
where: {
100110
...prismaUtils.validOpening,
101-
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
102-
borrow: {
103-
OR: [
104-
null,
105-
{ createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) } },
106-
],
107-
},
111+
AND: [
112+
{
113+
OR: [{ borrow: { userLogin } }, { return: { userLogin } }],
114+
},
115+
{
116+
OR: [
117+
{
118+
borrow: null,
119+
},
120+
{
121+
borrow: {
122+
createdAt: { gte: new Date(Date.now() - BORROW_TIMEOUT) },
123+
},
124+
},
125+
],
126+
},
127+
],
108128
},
109129
...OPENING_INCLUDE_BEFORE_FORMATTING,
110130
});

0 commit comments

Comments
 (0)