Skip to content

Commit 55e19a8

Browse files
committed
fix: condition query
1 parent 5798085 commit 55e19a8

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

back/api/application/controllers/application.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,33 @@ module.exports = {
6868
const applications = await strapi.services.application.find(
6969
{
7070
id,
71-
status: ['validated', 'confirmed'],
7271
},
7372
[
7473
'id',
74+
'creation_title',
75+
'company',
7576
],
7677
)
7778

79+
const application = applications.length > 0 ? applications[0] : null
80+
81+
if (!application) {
82+
return { count: 0 }
83+
}
84+
85+
const applicationsCount = await strapi.services.application.find(
86+
{
87+
creation_title: application.creation_title,
88+
company: application.company.id,
89+
status_in: ['validated', 'confirmed'],
90+
},
91+
[
92+
'id',
93+
'creation_title',
94+
'company',
95+
],
96+
)
7897

79-
return { count: applications?.length || 0 }
98+
return { count: applicationsCount?.length || 0 }
8099
},
81100
}

0 commit comments

Comments
 (0)