Skip to content

Commit ea01cb2

Browse files
authored
fix: fap reviewer filter sql bug (#1346)
2 parents ccccb9f + 6b6c3cd commit ea01cb2

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

apps/backend/src/datasources/postgres/ReviewDataSource.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,12 @@ export default class PostgresReviewDataSource implements ReviewDataSource {
360360
qb.where('user_id', userId);
361361
}
362362

363+
qb.join('proposals', {
364+
'proposals.proposal_pk': 'fap_reviews.proposal_pk',
365+
});
366+
363367
// sometimes the ID 0 is sent as a equivalent of all
364368
if (callId) {
365-
qb.join('proposals', {
366-
'proposals.proposal_pk': 'fap_reviews.proposal_pk',
367-
});
368369
qb.where('proposals.call_id', callId);
369370
}
370371

@@ -381,9 +382,6 @@ export default class PostgresReviewDataSource implements ReviewDataSource {
381382
}
382383

383384
if (active) {
384-
qb.join('proposals', {
385-
'proposals.proposal_pk': 'fap_reviews.proposal_pk',
386-
});
387385
qb.join('call', {
388386
'call.call_id': 'proposals.call_id',
389387
});
@@ -435,10 +433,10 @@ export default class PostgresReviewDataSource implements ReviewDataSource {
435433
.select('fap_reviews.*')
436434
.from('fap_reviews')
437435
.modify((qb) => {
436+
qb.join('proposals', {
437+
'proposals.proposal_pk': 'fap_reviews.proposal_pk',
438+
});
438439
if (callId) {
439-
qb.join('proposals', {
440-
'proposals.proposal_pk': 'fap_reviews.proposal_pk',
441-
});
442440
qb.where('proposals.call_id', callId);
443441
}
444442
if (instrumentId) {
@@ -454,9 +452,6 @@ export default class PostgresReviewDataSource implements ReviewDataSource {
454452
}
455453

456454
if (active) {
457-
qb.join('proposals', {
458-
'proposals.proposal_pk': 'fap_reviews.proposal_pk',
459-
});
460455
qb.join('call', {
461456
'call.call_id': 'proposals.call_id',
462457
});

0 commit comments

Comments
 (0)