Skip to content

Commit

Permalink
feat(GoalCriteria): change relation type between goal and criteria da…
Browse files Browse the repository at this point in the history
…ta tables
  • Loading branch information
LamaEats committed Nov 24, 2023
1 parent 29f8ede commit d07f48c
Showing 1 changed file with 8 additions and 40 deletions.
48 changes: 8 additions & 40 deletions trpc/router/goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,26 +1214,10 @@ export const goal = router({
}),
]);

const actualGoal = await prisma.goal.findUnique({
where: { id: input.goalId },
include: {
state: true,
goalAchiveCriteria: {
include: {
criteriaGoal: {
include: { state: true },
},
},
},
},
});

if (actualGoal) {
await recalculateCriteriaScore(actualGoal.id)
.recalcCurrentGoalScore()
.recalcAverageProjectScore()
.run();
}
await recalculateCriteriaScore(input.goalId)
.recalcCurrentGoalScore()
.recalcAverageProjectScore()
.run();
}
} catch (error: any) {
throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: String(error.message), cause: error });
Expand Down Expand Up @@ -1266,26 +1250,10 @@ export const goal = router({
},
});

const actualGoal = await prisma.goal.findUnique({
where: { id: actualCriteria.goalId },
include: {
state: true,
goalAchiveCriteria: {
include: {
criteriaGoal: {
include: { state: true },
},
},
},
},
});

if (actualGoal) {
await recalculateCriteriaScore(actualGoal.id)
.recalcCurrentGoalScore()
.recalcAverageProjectScore()
.run();
}
await recalculateCriteriaScore(actualCriteria.goalId)
.recalcCurrentGoalScore()
.recalcAverageProjectScore()
.run();
} catch (error: any) {
throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: String(error.message), cause: error });
}
Expand Down

0 comments on commit d07f48c

Please sign in to comment.