Skip to content

Commit

Permalink
Fix elastic mapping for collections
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Jan 18, 2024
1 parent 5b15d5f commit 790fde0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/modules/nftCollections/collections-getter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,14 @@ export class CollectionsGetterService {
}

private async mapCollection(collection: any): Promise<Collection> {
const ownerAddress = new Address(collection.owner);
const ownerAddress = new Address(collection.currentOwner);

Check warning on line 316 in src/modules/nftCollections/collections-getter.service.ts

View check run for this annotation

Codecov / codecov/patch

src/modules/nftCollections/collections-getter.service.ts#L316

Added line #L316 was not covered by tests
if (ownerAddress.isContractAddress()) {
const artist = await this.smartContractArtistService.getOrSetArtistForScAddress(collection.owner);
const artist = await this.smartContractArtistService.getOrSetArtistForScAddress(collection.currentOwner);

Check warning on line 318 in src/modules/nftCollections/collections-getter.service.ts

View check run for this annotation

Codecov / codecov/patch

src/modules/nftCollections/collections-getter.service.ts#L318

Added line #L318 was not covered by tests
const followersCount = await this.idService.getFollowersCount(artist?.value?.owner);
return Collection.fromCollectionElastic(collection, artist?.value?.owner, followersCount?.count);
}
const followersCount = await this.idService.getFollowersCount(collection.owner);
return Collection.fromCollectionElastic(collection, collection.owner, followersCount?.count);
const followersCount = await this.idService.getFollowersCount(collection.currentOwner);

Check warning on line 322 in src/modules/nftCollections/collections-getter.service.ts

View check run for this annotation

Codecov / codecov/patch

src/modules/nftCollections/collections-getter.service.ts#L322

Added line #L322 was not covered by tests
return Collection.fromCollectionElastic(collection, collection.currentOwner, followersCount?.count);
}

private async mapCollectionNfts(localCollections: Collection[]) {
Expand Down Expand Up @@ -424,7 +424,7 @@ export class CollectionsGetterService {
return ElasticQuery.create()

Check warning on line 424 in src/modules/nftCollections/collections-getter.service.ts

View check run for this annotation

Codecov / codecov/patch

src/modules/nftCollections/collections-getter.service.ts#L424

Added line #L424 was not covered by tests
.withMustNotExistCondition('identifier')
.withMustMultiShouldCondition([NftTypeEnum.NonFungibleESDT, NftTypeEnum.SemiFungibleESDT], (type) => QueryType.Match('type', type))

Check warning on line 426 in src/modules/nftCollections/collections-getter.service.ts

View check run for this annotation

Codecov / codecov/patch

src/modules/nftCollections/collections-getter.service.ts#L426

Added line #L426 was not covered by tests
.withPagination({ from: 0, size: constants.getCollectionsFromElasticBatchSize })
.withPagination({ from: 0, size: 20 })
.withSort([
{ name: 'api_isVerified', order: ElasticSortOrder.descending },
{ name: 'timestamp', order: ElasticSortOrder.descending },
Expand Down
5 changes: 1 addition & 4 deletions src/modules/nftCollections/models/Collection.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ export class Collection {

static fromCollectionElastic(collectionElastic: any, artistAddress?: string, followersCount?: number) {
if (!collectionElastic) return null;
if (!collectionElastic.currentOwner) {
console.log({ collectionElastic });
}
console.log();

return new Collection({

Check warning on line 128 in src/modules/nftCollections/models/Collection.dto.ts

View check run for this annotation

Codecov / codecov/patch

src/modules/nftCollections/models/Collection.dto.ts#L128

Added line #L128 was not covered by tests
collection: collectionElastic.token,
artistAddress: artistAddress,
Expand Down

0 comments on commit 790fde0

Please sign in to comment.