Skip to content

Commit

Permalink
Hotfix: Fix inconsistent feedback query (#424)
Browse files Browse the repository at this point in the history
* temporary fixing query

* fixed query

* better query
  • Loading branch information
nik-dange authored Apr 2, 2024
1 parent 5a48e05 commit c3d599c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions repositories/FeedbackRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ export class FeedbackRepository extends BaseRepository<FeedbackModel> {
return this.getBaseFindQuery({}).where({ uuid }).getOne();
}

public async getAllFeedbackForUser(user: UserModel): Promise<FeedbackModel[]> {
return this.getBaseFindQuery({}).where({ user }).getMany();
// temporary fix for getting feedback for a user for an event
public async getStandardUserFeedback(user: UserModel, options: FeedbackSearchOptions): Promise<FeedbackModel[]> {
let query = this.getBaseFindQuery(options);
query = query.andWhere('feedback.user = :user', { user: user.uuid });

return query.getMany();
}

public async getAllFeedbackForUser(user: UserModel, options: FeedbackSearchOptions): Promise<FeedbackModel[]> {
return this.getBaseFindQuery(options).where({ user }).getMany();
}

public async upsertFeedback(feedback: FeedbackModel,
Expand Down
2 changes: 1 addition & 1 deletion services/FeedbackService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class FeedbackService {
.map((fb) => fb.getPublicFeedback());
}

const userFeedback = await feedbackRepository.getAllFeedbackForUser(user);
const userFeedback = await feedbackRepository.getStandardUserFeedback(user, options);
return userFeedback.map((fb) => fb.getPublicFeedback());
});
}
Expand Down
2 changes: 1 addition & 1 deletion tests/feedback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('feedback submission', () => {
const feedbackController = ControllerFactory.feedback(conn);
await feedbackController.submitFeedback(buildFeedbackRequest(feedback1), member1);
await feedbackController.submitFeedback(buildFeedbackRequest(feedback2), member2);
const user1Feedback = await feedbackController.getFeedback({}, member1);
const user1Feedback = await feedbackController.getFeedback({ user: member1.uuid }, member1);

expect(user1Feedback.feedback).toHaveLength(1);

Expand Down

0 comments on commit c3d599c

Please sign in to comment.