Skip to content

Commit

Permalink
fix: case changes, purge function for templates, use queries
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasFalkowsky committed Jan 22, 2024
1 parent 7bb6eed commit 6f1b233
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 79 deletions.
6 changes: 5 additions & 1 deletion common/achievement/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ export enum TemplateSelectEnum {
// string == metricId, group
const achievementTemplates: Map<TemplateSelectEnum, Map<string, Achievement_template[]>> = new Map();

export function purgeAchievementTemplates() {
achievementTemplates.clear();
}

async function getAchievementTemplates(select: TemplateSelectEnum): Promise<Map<string, Achievement_template[]>> {
if (!achievementTemplates.has(select) || !achievementTemplates[select]) {
if (!achievementTemplates.has(select)) {
achievementTemplates.set(select, new Map());

const templatesFromDB = await prisma.achievement_template.findMany({
Expand Down
2 changes: 0 additions & 2 deletions common/achievement/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export async function getBucketContext(userID: string, relation?: string): Promi

let matches = [];
if (!relationType || relationType === 'match') {
whereClause[`${userType}Id`] = id;
matches = await prisma.match.findMany({
where: { ...whereClause, [`${userType}Id`]: id },
select: {
Expand All @@ -63,7 +62,6 @@ export async function getBucketContext(userID: string, relation?: string): Promi

let subcourses = [];
if (!relationType || relationType === 'subcourse') {
delete whereClause[`${userType}Id`];
const userClause =
userType === 'student'
? { subcourse_instructors_student: { some: { studentId: id } } }
Expand Down
Loading

0 comments on commit 6f1b233

Please sign in to comment.