Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Fix inconsistent feedback query #424

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading