Skip to content

Commit bfa646f

Browse files
committed
fix(structures): Current name can to be in the future /4
1 parent 83827b7 commit bfa646f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/api/commons/queries/current-name.query.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
export default [
22
{
3-
$project: {
4-
names: {
3+
$set: {
4+
filteredNames: {
55
$filter: {
66
input: '$names',
7-
as: 'name',
8-
cond: {
9-
$and: [
10-
{ $or: [{ $ifNull: ['$$name.startDate', true] }, { $lte: ['$$name.startDate', '$$NOW'] }] },
11-
{ $or: [{ $ifNull: ['$$name.endDate', true] }, { $gte: ['$$name.endDate', '$$NOW'] }] },
12-
],
13-
},
7+
cond: { $lte: [{ $toDate: '$$this.startDate' }, '$$NOW'] },
148
},
159
},
1610
},
@@ -19,7 +13,7 @@ export default [
1913
$set: {
2014
currentName: {
2115
$reduce: {
22-
input: '$names',
16+
input: '$filteredNames',
2317
initialValue: null,
2418
in: {
2519
$cond: [
@@ -35,7 +29,7 @@ export default [
3529
currentName: {
3630
$ifNull: ['$currentName', {
3731
$reduce: {
38-
input: '$names',
32+
input: '$filteredNames',
3933
initialValue: null,
4034
in: {
4135
$cond: [

0 commit comments

Comments
 (0)