Skip to content

Commit

Permalink
Merge pull request #119 from P4-Games/feature/20240310-2
Browse files Browse the repository at this point in the history
merge feature/20240310-2 into develop
  • Loading branch information
dappsar authored Oct 3, 2024
2 parents 2a1ab80 + 25a5588 commit 338258c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
33 changes: 18 additions & 15 deletions src/app/api/_data/data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,35 +116,31 @@ export async function getWalletNfts(wallet: string): Promise<INFT[] | undefined>
metadata: 1,
timestamp: 1,
original: 1,
total_of_this: 1,
copy_of: 1,
copy_order: 1,
total_of_this: 1
copy_of_original: 1,
copy_order_original: 1
}
},
{
$addFields: {
original: {
$cond: {
if: { $eq: ['$original', null] },
then: true,
else: '$original'
}
},
// Considerar que copy_order puede ser nulo, si es nulo lo reemplazamos por 1
copy_order: {
$ifNull: ['$copy_order', 1]
},
// Obtener el campo copy_of, si es nulo lo dejamos como nulo
copy_of: {
$ifNull: ['$copy_of', null]
},
// Obtener el campo copy_of_original, si es nulo lo dejamos como nulo
copy_of_original: {
$ifNull: ['$copy_of_original', null]
}
}
},
{
// Realizar un lookup para obtener el total_of_this del registro original relacionado
// Realizar un lookup para obtener el total_of_this
// del registro original relacionado
$lookup: {
from: SCHEMA_NFTS,
localField: 'copy_of',
localField: 'copy_of_original',
foreignField: 'id',
as: 'original_nft'
}
Expand All @@ -153,7 +149,7 @@ export async function getWalletNfts(wallet: string): Promise<INFT[] | undefined>
$addFields: {
total_of_original: {
$cond: {
if: { $ne: ['$copy_of', null] },
if: { $ne: ['$copy_of_original', null] },
then: {
$arrayElemAt: ['$original_nft.total_of_this', 0]
},
Expand Down Expand Up @@ -255,6 +251,13 @@ export async function getWalletNft(wallet: string, nftId: string): Promise<INFT
channel_user_id: nft.channel_user_id,
wallet: nft.wallet,
trxId: nft.trxId,
timestamp: nft.timestamp,
original: nft.original,
tota_of_this: nft.tota_of_this,
copy_of: nft.copy_of,
copy_order: nft.copy_order,
copy_of_original: nft.copy_of_original,
copy_order_original: nft.copy_order_original,
metadata: nft.metadata
}

Expand Down
2 changes: 1 addition & 1 deletion src/sections/nfts/nft-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function NftItem({ nft }: Props) {
return t('nfts.item.original')
}
const copyText = t('nfts.item.copy-of')
.replace('{X}', String(nft.copy_order) || '1')
.replace('{X}', String(nft.copy_order_original) || '1')
.replace('{Z}', String(nft.total_of_original) || '1')
return copyText
}
Expand Down
10 changes: 6 additions & 4 deletions src/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ export type INFT = {
channel_user_id: string
wallet: string
trxId: string
original?: boolean
timestamp: Date
original: boolean
tota_of_this: number
copy_of?: string
copy_order?: number
tota_of_this?: number
timestamp?: Date
copy_order: number
copy_of_original?: string
copy_order_original: number
total_of_original?: number
metadata: INFTMetadata
}
Expand Down

0 comments on commit 338258c

Please sign in to comment.