Skip to content

Commit

Permalink
fix number of NFTS purchased by a scout on their own profile (#4803)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcasey authored Oct 14, 2024
1 parent f88ab7b commit 4812aba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function ScoutProfile({ userId, isMobile }: { userId: string; isMob
getScoutedBuilders({ scoutId: userId })
]);

const nftsPurchasedThisSeason = scoutedBuilders.reduce((acc, builder) => acc + (builder.nftsSold || 0), 0);
const nftsPurchasedThisSeason = scoutedBuilders.reduce((acc, builder) => acc + (builder.nftsSoldToScout || 0), 0);

return (
<Stack gap={1}>
Expand Down
1 change: 1 addition & 0 deletions apps/scoutgame/lib/builders/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export type BuilderInfo = BasicUserInfo &
BuilderMetrics & {
nftImageUrl?: string | null;
boughtNftsCount?: number;
nftsSoldToScout?: number;
};
5 changes: 5 additions & 0 deletions apps/scoutgame/lib/scouts/getScoutedBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export async function getScoutedBuilders({ scoutId }: { scoutId: string }): Prom
scoutId
},
select: {
tokensPurchased: true,
builderNFT: {
select: {
builderId: true
Expand Down Expand Up @@ -72,6 +73,9 @@ export async function getScoutedBuilders({ scoutId }: { scoutId: string }): Prom
});

return builders.map((builder) => {
const nftsSoldToScout = nftPurchaseEvents
.filter((event) => event.builderNFT.builderId === builder.id)
.reduce((acc, event) => acc + event.tokensPurchased, 0);
return {
id: builder.id,
nftImageUrl: builder.builderNfts[0]?.imageUrl,
Expand All @@ -81,6 +85,7 @@ export async function getScoutedBuilders({ scoutId }: { scoutId: string }): Prom
builderPoints: builder.userSeasonStats[0]?.pointsEarnedAsBuilder ?? 0,
gemsCollected: builder.userWeeklyStats[0]?.gemsCollected ?? 0,
nftsSold: builder.userSeasonStats[0]?.nftsSold ?? 0,
nftsSoldToScout,
isBanned: builder.builderStatus === 'banned',
price: builder.builderNfts[0]?.currentPrice ?? 0,
boughtNftsCount: undefined
Expand Down

0 comments on commit 4812aba

Please sign in to comment.