Skip to content

Commit

Permalink
fix: consider updated at from the graph (#111)
Browse files Browse the repository at this point in the history
When considering the latest updated at from parcels and estates only
consider the values received from the graph call and not the one of the
merge tiles
  • Loading branch information
Melisa Anabella Rossi authored Nov 17, 2023
1 parent 5cdd04f commit aa805d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/modules/api/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ export async function createApiComponent(components: {
const currentTile = tilesByTokenId[tokenId]
return {
...currentTile,
updatedAt: Math.max(currentTile.updatedAt, rentalListing.updatedAt),
updatedAt: Math.max(
currentTile.updatedAt,
rentalListing.updatedAt
),
rentalListing: isRentalListingOpen(rentalListing)
? convertRentalListingToTileRentalListing(rentalListing)
: undefined,
Expand Down Expand Up @@ -454,9 +457,12 @@ export async function createApiComponent(components: {
}

// tiles already have the updateAt value in ms
const tilesLastUpdatedAt = batch.tiles.reduce<number>(
(updatedAt, tile) => Math.max(updatedAt, tile.updatedAt),
0
const tilesLastUpdatedAt = fromSecondsToMilliseconds(
parcels.reduce<number>(
(updatedAt, parcel) =>
Math.max(updatedAt, parseInt(parcel.updatedAt, 10)),
0
)
)

// using estes from graph so we need to convert the updatedAt in ms as they come in seconds
Expand Down
4 changes: 2 additions & 2 deletions tests/modules/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ describe('when fetching update data', () => {
],
parcels: [updatedDefaultParcelNFT],
estates: [],
updatedAt: date,
updatedAt: defaultParcelTile.updatedAt,
})
})
})
Expand Down Expand Up @@ -1387,7 +1387,7 @@ describe('when fetching update data', () => {
defaultSndParcelEstateNFT,
],
estates: [fstEstateNFT],
updatedAt: fstEstateRentalListing.updatedAt,
updatedAt: Math.min(fstEstateRentalListing.updatedAt, fromSecondsToMilliseconds(parseInt(fstEstate.updatedAt, 10))),
})
})
})
Expand Down

0 comments on commit aa805d8

Please sign in to comment.