Skip to content

Commit

Permalink
Fix user course progress log links
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoerlitz committed May 20, 2024
1 parent a8ff671 commit 7ee71a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function getInformation(request: Request, response: Response, next: NextFu
},
{
association: User.associations.training_sessions,
attributes: ["uuid", "completed", "date"],
attributes: ["id", "uuid", "completed", "date"],
where: {
course_id: course_id,
},
Expand All @@ -101,7 +101,7 @@ async function getInformation(request: Request, response: Response, next: NextFu
association: User.associations.training_logs,
attributes: ["uuid"],
through: {
attributes: ["id", "user_id", "passed"],
attributes: ["id", "training_session_id", "user_id", "passed"],
},
},
],
Expand Down
11 changes: 2 additions & 9 deletions backend/src/models/extensions/TrainingSessionExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,21 @@ function userCanCreateLogs(this: TrainingSession, user: User): boolean {
* (for passing the training on)
*/
async function getAvailableMentorGroups(this: TrainingSession): Promise<MentorGroup[]> {
// TODO: Test if we can limit the attributes, without breaking the includes.

const trainingSession = await TrainingSession.findOne({
where: {
uuid: this.uuid,
},
include: [
{
association: TrainingSession.associations.course,
through: {
attributes: [],
},
include: [
{
association: Course.associations.mentor_groups,
through: {
attributes: [],
},
include: [
{
association: MentorGroup.associations.users,
through: {
attributes: [],
},
},
],
},
Expand Down

0 comments on commit 7ee71a8

Please sign in to comment.