Skip to content

Commit 9003a0f

Browse files
committed
small fix for future visits dates
1 parent 6587825 commit 9003a0f

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

server/controllers/public/visits.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,7 @@ async function visitsQuery(req) {
4343
} else if (req.query.future === "true") {
4444
match = {
4545
$expr: {
46-
$and: [
47-
{
48-
$or: [
49-
{ $eq: ["$startDate", null] },
50-
{ $gte: ["$startDate", "$$NOW"] }
51-
]
52-
}
53-
]
46+
$gt: ["$startDate", "$$NOW"]
5447
}
5548
};
5649
} else {

widgets/src/components/HomeVisitList.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,10 @@ export function HomeVisitList({ default_entries = 10 }) {
9797
}
9898

9999
const filterVisitsByDate = (visits, date) => {
100-
const today = new Date();
101-
today.setHours(0, 0, 0, 0);
102-
103100
if (date === "current") {
104-
return visits.filter((visit) => new Date(visit.startDate) <= today);
101+
return visits.filter((visit) => new Date(visit.startDate) <= new Date());
105102
} else if (date === "future") {
106-
return visits.filter((visit) => new Date(visit.startDate) > today);
103+
return visits.filter((visit) => new Date(visit.startDate) > new Date());
107104
} else {
108105
return visits;
109106
}

0 commit comments

Comments
 (0)