Skip to content

Commit

Permalink
add qfround attributes to donation export
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Jul 26, 2023
1 parent 683833e commit f24b7b2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/server/adminJs/adminJs-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface AdminJsDonationsQuery {
currency?: string;
transactionNetworkId?: string;
isProjectVerified?: string;
qfRoundId?: string;
}

// headers defined by the verification team for exporting
Expand Down Expand Up @@ -95,4 +96,6 @@ export const donationHeaders = [
'createdAt',
'referrerWallet',
'isTokenEligibleForGivback',
'qfRoundId',
'qfRoundUserScore',
];
4 changes: 2 additions & 2 deletions src/server/adminJs/adminJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 28 additions & 1 deletion src/server/adminJs/tabs/donationTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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,
Expand Down Expand Up @@ -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 || '',
};
});

Expand All @@ -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,
},
Expand Down Expand Up @@ -452,6 +470,15 @@ export const donationTab = {
new: false,
},
},
qfRoundUserScore: {
isVisible: {
list: false,
filter: false,
show: true,
edit: false,
new: false,
},
},
tokenAddress: {
isVisible: false,
},
Expand All @@ -466,7 +493,7 @@ export const donationTab = {
},
toWalletAddress: {
isVisible: {
list: true,
list: false,
filter: true,
show: true,
edit: false,
Expand Down

0 comments on commit f24b7b2

Please sign in to comment.