From f24b7b2c44827a746943d0df8251605b8c0300cc Mon Sep 17 00:00:00 2001 From: Carlos Date: Wed, 26 Jul 2023 02:19:34 -0500 Subject: [PATCH] add qfround attributes to donation export --- src/server/adminJs/adminJs-types.ts | 3 +++ src/server/adminJs/adminJs.ts | 4 ++-- src/server/adminJs/tabs/donationTab.ts | 29 +++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/server/adminJs/adminJs-types.ts b/src/server/adminJs/adminJs-types.ts index 2d99a0eb1..254890507 100644 --- a/src/server/adminJs/adminJs-types.ts +++ b/src/server/adminJs/adminJs-types.ts @@ -44,6 +44,7 @@ export interface AdminJsDonationsQuery { currency?: string; transactionNetworkId?: string; isProjectVerified?: string; + qfRoundId?: string; } // headers defined by the verification team for exporting @@ -95,4 +96,6 @@ export const donationHeaders = [ 'createdAt', 'referrerWallet', 'isTokenEligibleForGivback', + 'qfRoundId', + 'qfRoundUserScore', ]; diff --git a/src/server/adminJs/adminJs.ts b/src/server/adminJs/adminJs.ts index 7e5cac197..c47e51fa3 100644 --- a/src/server/adminJs/adminJs.ts +++ b/src/server/adminJs/adminJs.ts @@ -76,8 +76,8 @@ export const getAdminJsRouter = async () => { export const extractAdminJsReferrerUrlParams = (req: ActionContext) => { const queryStrings = {}; - const refererUrlHeaderIndex = req.rawHeaders.indexOf('Referer'); - if (refererUrlHeaderIndex < 0) return {}; + const refererUrlHeaderIndex = req?.rawHeaders?.indexOf('Referer'); + if (!refererUrlHeaderIndex || refererUrlHeaderIndex < 0) return {}; const refererUrl = new URL(req.rawHeaders[refererUrlHeaderIndex + 1]); const searchParams = refererUrl.searchParams; diff --git a/src/server/adminJs/tabs/donationTab.ts b/src/server/adminJs/tabs/donationTab.ts index 94b355702..e7e5af86c 100644 --- a/src/server/adminJs/tabs/donationTab.ts +++ b/src/server/adminJs/tabs/donationTab.ts @@ -185,6 +185,7 @@ export const buildDonationsQuery = ( const query = Donation.createQueryBuilder('donation') .leftJoinAndSelect('donation.user', 'user') .leftJoinAndSelect('donation.project', 'project') + .leftJoinAndSelect('donation.qfRound', 'qfRound') .where('donation.amount > 0') .addOrderBy('donation.createdAt', 'DESC'); @@ -198,6 +199,11 @@ export const buildDonationsQuery = ( projectId: queryStrings.projectId, }); + if (queryStrings.qfRoundId) + query.andWhere('donation.qfRoundId = :qfRoundId', { + qfRoundId: queryStrings.qfRoundId, + }); + if (queryStrings.userId) query.andWhere('donation.userId = :userId', { userId: queryStrings.userId, @@ -320,6 +326,8 @@ const sendDonationsToGoogleSheet = async ( createdAt: donation?.createdAt.toISOString(), referrerWallet: donation?.referrerWallet || '', isTokenEligibleForGivback: Boolean(donation?.isTokenEligibleForGivback), + qfRoundId: donation?.qfRound?.id || '', + qfRoundUserScore: donation?.qfRoundUserScore || '', }; }); @@ -343,6 +351,16 @@ export const donationTab = { new: false, }, }, + qfRoundId: { + type: Number, + isVisible: { + list: false, + filter: true, + show: true, + edit: false, + new: false, + }, + }, nonce: { isVisible: false, }, @@ -452,6 +470,15 @@ export const donationTab = { new: false, }, }, + qfRoundUserScore: { + isVisible: { + list: false, + filter: false, + show: true, + edit: false, + new: false, + }, + }, tokenAddress: { isVisible: false, }, @@ -466,7 +493,7 @@ export const donationTab = { }, toWalletAddress: { isVisible: { - list: true, + list: false, filter: true, show: true, edit: false,