File tree Expand file tree Collapse file tree
packages/features/insights/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ class EventsInsights {
8080 whereConditional : Prisma . BookingTimeStatusDenormalizedWhereInput ,
8181 startDate : Dayjs ,
8282 endDate : Dayjs ,
83- dateRanges : DateRange [ ]
83+ dateRanges : DateRange [ ] ,
84+ timeZone : string
8485 ) : Promise < AggregateResult > => {
8586 const formattedStartDate = dayjs ( startDate ) . format ( "YYYY-MM-DD HH:mm:ss" ) ;
8687 const formattedEndDate = dayjs ( endDate ) . format ( "YYYY-MM-DD HH:mm:ss" ) ;
@@ -96,14 +97,14 @@ class EventsInsights {
9697 } [ ]
9798 > `
9899 SELECT
99- DATE("createdAt") as "date",
100+ "date",
100101 CAST(COUNT(*) AS INTEGER) AS "bookingsCount",
101102 CAST(COUNT(CASE WHEN "isNoShowGuest" = true THEN 1 END) AS INTEGER) AS "noShowGuests",
102103 "timeStatus",
103104 "noShowHost"
104105 FROM (
105106 SELECT
106- "createdAt",
107+ DATE( "createdAt" AT TIME ZONE ${ timeZone } ) as "date ",
107108 "a"."noShow" AS "isNoShowGuest",
108109 "timeStatus",
109110 "noShowHost"
@@ -116,7 +117,7 @@ class EventsInsights {
116117 AND ${ Prisma . raw ( whereClause ) }
117118 ) AS bookings
118119 GROUP BY
119- DATE("createdAt") ,
120+ "date" ,
120121 "timeStatus",
121122 "noShowHost"
122123 ORDER BY
Original file line number Diff line number Diff line change @@ -489,7 +489,8 @@ export const insightsRouter = router({
489489 whereConditional ,
490490 dayjs ( startDate ) ,
491491 dayjs ( endDate ) ,
492- dateRanges
492+ dateRanges ,
493+ ctx . user . timeZone
493494 ) ;
494495
495496 const result = dateRanges . map ( ( { formattedDate } ) => {
You can’t perform that action at this time.
0 commit comments