diff --git a/src/api/helpers/nftHelpers.ts b/src/api/helpers/nftHelpers.ts index e67aacd..3d971af 100644 --- a/src/api/helpers/nftHelpers.ts +++ b/src/api/helpers/nftHelpers.ts @@ -104,9 +104,9 @@ export async function populateNFTIpfs(NFT: INFT): Promise { const response = await fetchTimeout( fetchUrl, null, - Number(process.env.IPFS_REQUEST_TIMEOUT) || 8000 + Number(process.env.IPFS_REQUEST_TIMEOUT) || 2000 ).catch((_e) => { - L.error("fetch error:" + _e); + L.error("Fetch error:" + _e); throw new Error("Could not retrieve NFT data from " + NFT.nftIpfs); }); if (response) { diff --git a/src/api/services/nft.ts b/src/api/services/nft.ts index d48de09..f5ebf07 100644 --- a/src/api/services/nft.ts +++ b/src/api/services/nft.ts @@ -160,8 +160,8 @@ export class NFTService { totalOwnedListedInMarketplaceByRequestingUser: number, smallestPrice: string }> { - const marketplaceId = query.filter.marketplaceId ?? null; - const owner = query.filter.owner ?? null; + const marketplaceId = query.filter?.marketplaceId ?? null; + const owner = query.filter?.owner ?? null; try { const [totalRequest, totalListedRequest, totalFilteredRequest, totalListedInMarketplaceRequest, totalOwnedByRequestingUserRequest, totalOwnedListedByRequestingUserRequest, totalOwnedListedInMarketplaceByRequestingUserRequest, smallestPriceRequest] = await Promise.all([ @@ -424,7 +424,7 @@ export class NFTService { try { const aggregateQuery = [{ $group: { _id: "$serieId", totalLikes: { $sum: 1 } } }] const aggregate = NftLikeModel.aggregate(aggregateQuery); - const data = await NftLikeModel.aggregatePaginate(aggregate, {page: query.pagination.page, limit: query.pagination.limit, sort:{totalLikes: -1}}) + const data = await NftLikeModel.aggregatePaginate(aggregate, {page: query.pagination.page, limit: query.pagination.limit, sort:{totalLikes: -1, _id: -1}}) const seriesSorted = data.docs.map(x => x._id) const queryNfts = {filter:{series: seriesSorted}} const gqlQuery = QueriesBuilder.distinctNFTs(queryNfts); @@ -455,7 +455,7 @@ export class NFTService { try { const aggregateQuery = [{ $group: { _id: "$viewedSerie", totalViews: { $sum: 1 } } }] const aggregate = NftViewModel.aggregate(aggregateQuery); - const data = await NftViewModel.aggregatePaginate(aggregate, {page: query.pagination.page, limit: query.pagination.limit, sort:{totalViews: -1}}) + const data = await NftViewModel.aggregatePaginate(aggregate, {page: query.pagination.page, limit: query.pagination.limit, sort:{totalViews: -1, _id: -1}}) const seriesSorted = data.docs.map(x => x._id) const queryNfts = {filter:{series: seriesSorted}} const gqlQuery = QueriesBuilder.distinctNFTs(queryNfts); diff --git a/src/api/services/user.ts b/src/api/services/user.ts index fd238f4..01b036f 100644 --- a/src/api/services/user.ts +++ b/src/api/services/user.ts @@ -135,7 +135,7 @@ export class UserService { try{ const aggregateQuery = [{ $group: { _id: "$followed", totalViews: { $sum: 1 } } }] const aggregate = FollowModel.aggregate(aggregateQuery); - const res = await FollowModel.aggregatePaginate(aggregate, {page: query.pagination.page, limit: query.pagination.limit, sort:{totalViews: -1}}) + const res = await FollowModel.aggregatePaginate(aggregate, {page: query.pagination.page, limit: query.pagination.limit, sort:{totalViews: -1, _id: -1}}) const walletIdsSorted = res.docs.map(x => x._id) const filterDbUser = {walletIds: walletIdsSorted} const resDbUsers = await fetch(`${TERNOA_API_URL}/api/users/?filter=${JSON.stringify(filterDbUser)}`) diff --git a/src/interfaces/IUser.ts b/src/interfaces/IUser.ts index c553657..50e3c69 100644 --- a/src/interfaces/IUser.ts +++ b/src/interfaces/IUser.ts @@ -1,8 +1,6 @@ export interface IUser { _id: string; walletId: string; - nbFollowers?: number; - nbFollowing?: number; likedNFTs?: { serieId: string, nftId: string, walletId?: string }[]; viewsCount?: number; twitterName?: string;