Skip to content

Commit

Permalink
fix: Add emotes missing where query (#84)
Browse files Browse the repository at this point in the history
* chore: Upgrade @dcl/schemas package

* fix: Add missing emote fields hasGeometry and hasSound into the query
  • Loading branch information
cyaiox committed Feb 13, 2024
1 parent b5dd245 commit f5f8800
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 11 deletions.
163 changes: 156 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@covalenthq/client-sdk": "^0.6.4",
"@dcl/schemas": "^8.2.2",
"@dcl/schemas": "^10.2.0",
"@well-known-components/env-config-provider": "^1.1.1",
"@well-known-components/http-server": "^1.1.6",
"@well-known-components/interfaces": "^1.2.0",
Expand Down
14 changes: 13 additions & 1 deletion src/ports/catalog/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ export const getEmotePlayModeWhere = (filters: CatalogFilters) => {
: SQL`metadata_emote.loop = ${filters.emotePlayMode === EmotePlayMode.LOOP}`
}

export const getEmoteHasGeometryWhere = () => {
return SQL`metadata_emote.has_geometry = true`
}

export const getEmoteHasSoundWhere = () => {
return SQL`metadata_emote.has_sound = true`
}

export const getSearchWhere = (filters: CatalogFilters) => {
if (filters.category === NFTCategory.EMOTE || filters.category === NFTCategory.WEARABLE) {
return SQL`word % ${filters.search}`
Expand Down Expand Up @@ -369,6 +377,8 @@ export const getCollectionsQueryWhere = (filters: CatalogFilters) => {
filters.wearableGenders?.length ? getWearableGenderWhere(filters) : undefined,
filters.emoteCategory ? getEmoteCategoryWhere(filters) : undefined,
filters.emotePlayMode?.length ? getEmotePlayModeWhere(filters) : undefined,
filters.emoteHasGeometry ? getEmoteHasGeometryWhere() : undefined,
filters.emoteHasSound ? getEmoteHasSoundWhere() : undefined,
filters.contractAddresses?.length ? getContractAddressWhere(filters) : undefined,
filters.minPrice ? getMinPriceWhere(filters) : undefined,
filters.maxPrice ? getMaxPriceWhere(filters) : undefined,
Expand Down Expand Up @@ -503,7 +513,9 @@ const addMetadataJoins = (schemaVersion: string, filters: CatalogQueryFilters) =
emote.category,
emote.body_shapes,
emote.name,
emote.loop
emote.loop,
emote.has_geometry,
emote.has_sound
FROM `
.append(schemaVersion)
.append('.emote AS emote JOIN ')
Expand Down
2 changes: 2 additions & 0 deletions src/ports/catalog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export type CollectionsItemDBResult = {
rarity: string
name: string
loop?: boolean
hasGeometry?: boolean
hasSound?: boolean
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/ports/catalog/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ export function fromCollectionsItemDbResultToCatalogItem(dbItem: CollectionsItem
break
}
case FragmentItemType.EMOTE_V1: {
const { name: emoteName, body_shapes, description, loop, category: emoteCategory } = dbItem.metadata || {}
const { name: emoteName, body_shapes, description, loop, category: emoteCategory, hasGeometry, hasSound } = dbItem.metadata || {}
;(name = emoteName), (category = NFTCategory.EMOTE)
data = {
emote: {
description,
category: emoteCategory.toLocaleLowerCase() as EmoteCategory, // toLocaleLowerCase used since they were indexed in uppercase.
bodyShapes: body_shapes as BodyShape[],
rarity: dbItem.rarity as Rarity,
loop: !!loop
loop: !!loop,
hasGeometry: !!hasGeometry,
hasSound: !!hasSound
}
}
break
Expand Down

0 comments on commit f5f8800

Please sign in to comment.