From 47af6d919a0bef4f073271468370b4edafb185ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=E1=BA=A1m=20H=E1=BB=93ng=20Ph=C3=BAc?= Date: Sun, 31 Mar 2024 16:52:28 +0700 Subject: [PATCH] [SHR-29] enhance: add field organization rating to get campaign detail API (#179) --- backend/src/core/modules/campaign/campaign.repository.js | 8 ++++++-- .../core/modules/donation/donation-record.repository.js | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/core/modules/campaign/campaign.repository.js b/backend/src/core/modules/campaign/campaign.repository.js index 63c74ee..991c65d 100644 --- a/backend/src/core/modules/campaign/campaign.repository.js +++ b/backend/src/core/modules/campaign/campaign.repository.js @@ -20,9 +20,13 @@ class Repository extends DataRepository { { registerLink: 'campaigns.register_link' }, { donationRequirement: 'campaigns.donation_requirement' }, 'campaigns.coordinate', - { organizationName: 'organizations.name' }, { organizationId: 'campaigns.organization_id' }, - { organizationAvatar: 'organizations.avatar' } + { organization: connection.raw(`json_build_object( + 'name', organizations.name, + 'avatar', organizations.avatar, + 'id', campaigns.organization_id, + 'rating', 4.9 + )`)} ]); } diff --git a/backend/src/core/modules/donation/donation-record.repository.js b/backend/src/core/modules/donation/donation-record.repository.js index 5c0a12c..378020f 100644 --- a/backend/src/core/modules/donation/donation-record.repository.js +++ b/backend/src/core/modules/donation/donation-record.repository.js @@ -138,7 +138,6 @@ class Repository extends DataRepository { } findAllDonationsByUserId(userId) { - console.log(userId) return this.query() .where('donation_records.donor_id', '=', userId) .join('campaigns', 'donation_records.campaign_id', 'campaigns.id')