feat: Add ratings to insights (#14687)

This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2024-04-26 11:58:06 +01:00
1 parent d004815a68
commit 0650898302
17 files changed
+1061 -24

No files matched your search

@@ -0,0 +1,34 @@
CREATE OR REPLACE VIEW public."BookingTimeStatus"
AS
SELECT
"Booking".id,
"Booking".uid,
"Booking"."eventTypeId",
"Booking".title,
"Booking".description,
"Booking"."startTime",
"Booking"."endTime",
"Booking"."createdAt",
"Booking".location,
"Booking".paid,
"Booking".status,
"Booking".rescheduled,
"Booking"."userId",
et."teamId",
et.length AS "eventLength",
CASE
WHEN "Booking".rescheduled IS TRUE THEN 'rescheduled'::text
WHEN "Booking".status = 'cancelled'::"BookingStatus" AND "Booking".rescheduled IS NULL THEN 'cancelled'::text
WHEN "Booking"."endTime" < now() THEN 'completed'::text
WHEN "Booking"."endTime" > now() THEN 'uncompleted'::text
ELSE NULL::text
END AS "timeStatus",
et."parentId" AS "eventParentId",
"u"."email" AS "userEmail",
"u"."username" AS "username",
"Booking"."ratingFeedback",
"Booking"."rating",
"Booking"."noShowHost"
FROM "Booking"
LEFT JOIN "EventType" et ON "Booking"."eventTypeId" = et.id
LEFT JOIN users u ON u.id = "Booking"."userId";
+22 -19
View File
@@ -1123,25 +1123,28 @@ enum AccessScope {
}
view BookingTimeStatus {
id Int @unique
uid String?
eventTypeId Int?
title String?
description String?
startTime DateTime?
endTime DateTime?
createdAt DateTime?
location String?
paid Boolean?
status BookingStatus?
rescheduled Boolean?
userId Int?
teamId Int?
eventLength Int?
timeStatus String?
eventParentId Int?
userEmail String?
username String?
id Int @unique
uid String?
eventTypeId Int?
title String?
description String?
startTime DateTime?
endTime DateTime?
createdAt DateTime?
location String?
paid Boolean?
status BookingStatus?
rescheduled Boolean?
userId Int?
teamId Int?
eventLength Int?
timeStatus String?
eventParentId Int?
userEmail String?
username String?
ratingFeedback String?
rating Int?
noShowHost Boolean?
}
model CalendarCache {
+16
View File
@@ -6,6 +6,18 @@ import dayjs from "@calcom/dayjs";
import { hashPassword } from "@calcom/features/auth/lib/hashPassword";
import { BookingStatus } from "@calcom/prisma/enums";
function getRandomRatingFeedback() {
const feedbacks = [
"Great chat!",
"Okay-ish",
"Quite Poor",
"Excellent chat!",
"Could be better",
"Wonderful!",
];
return feedbacks[Math.floor(Math.random() * feedbacks.length)];
}
const shuffle = (
booking: any,
year: number,
@@ -62,6 +74,10 @@ const shuffle = (
console.log("This should not happen");
}
booking.rating = Math.floor(Math.random() * 5) + 1; // Generates a random rating from 1 to 5
booking.ratingFeedback = getRandomRatingFeedback(); // Random feedback from a predefined list
booking.noShowHost = Math.random() < 0.5;
return booking;
};