Skip to content

Commit

Permalink
Merge pull request #793 from tutors-sdk/fix/analytic-time-issues
Browse files Browse the repository at this point in the history
Fix if a person is not logged in
  • Loading branch information
edeleastar authored Sep 13, 2024
2 parents 9bca098 + 70a6c09 commit a82c0dd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/services/utils/supabase-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export async function getDurationTotal(key: string, table: string, id: string):
}

export async function insertOrUpdateCalendar(studentId: string, courseId: string) {
if(!studentId || !courseId) return;
const durationPromise = getCalendarDuration(formatDate(new Date()), studentId, courseId);
const countPromise = getCalendarCount(formatDate(new Date()), studentId, courseId);
const [timeActive, pageLoads] = await Promise.all([durationPromise, countPromise]);
Expand Down Expand Up @@ -205,12 +206,12 @@ export const updateCalendarDuration = async (id: string, studentId: string, cour

export async function storeStudentCourseLearningObjectInSupabase(course: Course, loid: string, lo: Lo, userDetails: User) {
// const loTitle = getLoTitle(params)
if (userDetails?.user_metadata.full_name === "Anon") return;
if (userDetails?.user_metadata?.full_name === "Anon") return;
// await insertOrUpdateCourse(course);
// await addOrUpdateStudent(userDetails);
// await addOrUpdateLo(loid, lo, lo.title);
await handleInteractionData(course.courseId, userDetails.user_metadata.user_name, loid, lo);
await insertOrUpdateCalendar(userDetails.user_metadata.user_name, course.courseId);
await handleInteractionData(course.courseId, userDetails?.user_metadata?.user_name, loid, lo);
await insertOrUpdateCalendar(userDetails?.user_metadata?.user_name, course.courseId);
}

export async function handleInteractionData(courseId: string, studentId: string, loId: string, lo: Lo) {
Expand Down

0 comments on commit a82c0dd

Please sign in to comment.