Skip to content

Commit

Permalink
Merge a39b4e7 into 94c6290
Browse files Browse the repository at this point in the history
  • Loading branch information
fzavalia committed Jun 21, 2023
2 parents 94c6290 + a39b4e7 commit 96d23b3
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions src/Collection/Collection.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@ export class CollectionRouter extends Router {
toRemoteWhereCondition({ status: status as CurationStatusFilter })
)

const tags = tag
? Array.isArray(tag)
? (tag as string[]).map((t) => t.toLowerCase())
: [(tag as string).toLowerCase()]
: undefined

const allCollectionsWithCount = await this.service.getCollections({
q: q as string,
assignee: assignee as string,
Expand All @@ -615,11 +621,7 @@ export class CollectionRouter extends Router {
: // if the status is not passed, we still want to prioritize the not approved. It won't filter by them, it'll just use them for the sort.
// We filter at this level and not in the query because we need all the collections so they can be consolidated later on.
remoteCollections.filter((r) => !r.isApproved).map((c) => c.id),
itemTags: tag
? Array.isArray(tag)
? (tag as string[]).map((t) => t.toLowerCase())
: [(tag as string).toLowerCase()]
: undefined,
itemTags: tags,
})

const totalCollections =
Expand All @@ -629,15 +631,32 @@ export class CollectionRouter extends Router {
omit<CollectionAttributes>(collectionWithCount, ['collection_count'])
)

const consolidated = (
await Bridge.consolidateAllCollections(dbCollections, remoteCollections)
).map((collection) => collection.contract_address!)
let consolidated = await Bridge.consolidateAllCollections(
dbCollections,
remoteCollections
)

if (tags?.includes('pride23')) {
consolidated = consolidated.filter((c) => {
// If it has not been reviewed we don't care about filtering it.
if (!c.reviewed_at) {
return true
}

// Will not return any pride items that were updated after being reviewed.
return c.updated_at <= c.reviewed_at
})
}

const addresses = consolidated.map(
(collection) => collection.contract_address!
)

const RES_MAX_AGE = 300 // 5 mins
addCustomMaxAgeCacheControlHeader(res, RES_MAX_AGE)

return page && limit
? generatePaginatedResponse(consolidated, totalCollections, limit, page)
: consolidated
? generatePaginatedResponse(addresses, totalCollections, limit, page)
: addresses
}
}

0 comments on commit 96d23b3

Please sign in to comment.