Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): appointment metadata #633

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app/web/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,50 @@ export async function getAppointmentsClient(client: User) {
return appointments;
}

export async function getAppointmentMetadata(user: User) {
const appointments = await db.appointment.findMany({
where: {
OR: [
{
proUsrName: user.username,
},
{
clientUsrName: user.username,
},
],
},
});

const apptMetadata = [];
for (let appt of appointments) {
const contactUsername =
appt.clientUsrName === user.username
? appt.proUsrName
: appt.clientUsrName;

const contactList = await getUsrList("username", contactUsername);
if (contactList && contactList.length === 1) {
apptMetadata.push({
apptId: appt.id,
apptDate: appt.time.valueOf(), // ms since epoch
contact: contactList.at(0),
});
} else {
apptMetadata.push({
apptId: appt.id,
apptDate: appt.time.valueOf(), // ms since epoch
contact: {
username: "unknown-user",
email: "unknown@unknown.com",
givenName: "Unknown",
familyName: "User",
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added issue: #634 for week 9

}
}
return apptMetadata;
}

export async function getVideoCount(id: number) {
return await db.video.count({
where: {
Expand Down
Loading