Skip to content

Commit 09914f1

Browse files
Show panini observations for the current day instead of past 24 hours
1 parent e5d67ee commit 09914f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

services/panini.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ export const cachedPaninis = unstable_cache(
1515
},
1616
);
1717

18+
/**
19+
* Function to get a new date that is midnight of the current day.
20+
*/
21+
export function getMidnightDate(date: Date = new Date()) {
22+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
23+
}
24+
1825
export const cachedRecentlySeenPaninis = unstable_cache(
1926
async () =>
2027
await prisma.panini.findMany({
2128
where: {
2229
observations: {
2330
some: {
2431
time: {
25-
gte: new Date(Date.now() - 1000 * 60 * 60 * 24),
32+
gte: getMidnightDate(),
2633
},
2734
},
2835
},
@@ -39,7 +46,7 @@ export const cachedRecentlySeenPaninis = unstable_cache(
3946
observations: {
4047
where: {
4148
time: {
42-
gte: new Date(Date.now() - 1000 * 60 * 60 * 24),
49+
gte: getMidnightDate(),
4350
},
4451
},
4552
},

0 commit comments

Comments
 (0)