Skip to content

Commit

Permalink
feat: add logic for emotes 2.0 for prices endpoint (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi authored Sep 14, 2023
1 parent 61e368f commit e6cccdd
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 8 deletions.
14 changes: 7 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 @@ -26,7 +26,7 @@
"printWidth": 80
},
"dependencies": {
"@dcl/schemas": "^9.5.0",
"@dcl/schemas": "^9.6.0",
"@well-known-components/env-config-provider": "^1.2.0",
"@well-known-components/http-requests-logger-component": "^2.1.0",
"@well-known-components/http-server": "^1.1.6",
Expand Down
4 changes: 4 additions & 0 deletions src/adapters/handlers/prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export function createPricesHandler(
const maxDistanceToPlaza = params.getNumber('maxDistanceToPlaza')
const maxEstateSize = params.getNumber('maxEstateSize')
const minEstateSize = params.getNumber('minEstateSize')
const emoteHasSound = params.getBoolean('emoteHasSound')
const emoteHasGeometry = params.getBoolean('emoteHasGeometry')

return asJSON(
async () => ({
Expand All @@ -78,6 +80,8 @@ export function createPricesHandler(
maxDistanceToPlaza,
maxEstateSize,
minEstateSize,
emoteHasGeometry,
emoteHasSound
}),
}),
{
Expand Down
36 changes: 36 additions & 0 deletions src/ports/nfts/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,40 @@ describe('#getFetchQuery', () => {
})
})
})

describe('when emoteHasSound is true', () => {
describe('and category is emote', () => {
it('should search for emotes with sound', () => {
expect(
getFetchQuery({ category: NFTCategory.EMOTE, emoteHasSound: true }, '', () => '')
).toEqual(expect.stringContaining('searchEmoteHasSound: true'))
})
})

describe('and category is not emote', () => {
it('should not add the has sound filter', () => {
expect(
getFetchQuery({ category: NFTCategory.ENS, emoteHasSound: true }, '', () => '')
).toEqual(expect.not.stringContaining('searchEmoteHasSound: true'))
})
})
})

describe('when emoteHasGeometry is true', () => {
describe('and category is emote', () => {
it('should search for emotes with geometry', () => {
expect(
getFetchQuery({ category: NFTCategory.EMOTE, emoteHasGeometry: true }, '', () => '')
).toEqual(expect.stringContaining('searchEmoteHasGeometry: true'))
})
})

describe('and category is not emote', () => {
it('should not add the has geometry filter', () => {
expect(
getFetchQuery({ category: NFTCategory.ENS, emoteHasGeometry: true }, '', () => '')
).toEqual(expect.not.stringContaining('searchEmoteHasGeometry: true'))
})
})
})
})
10 changes: 10 additions & 0 deletions src/ports/nfts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export function addEmoteCategoryAndRaritiesFilters(
| 'emoteGenders'
| 'emotePlayMode'
| 'itemRarities'
| 'emoteHasGeometry'
| 'emoteHasSound'
>,
where: string[]
) {
Expand Down Expand Up @@ -137,6 +139,14 @@ export function addEmoteCategoryAndRaritiesFilters(
.join(',')}]`
)
}

if (filters.emoteHasSound) {
where.push('searchEmoteHasSound: true')
}

if (filters.emoteHasGeometry) {
where.push('searchEmoteHasGeometry: true')
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/ports/prices/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export type PriceFilters = {
| 'maxDistanceToPlaza'
| 'minEstateSize'
| 'maxEstateSize'
| 'emoteHasGeometry'
| 'emoteHasSound'
>

export type PriceFragment = {
Expand Down

0 comments on commit e6cccdd

Please sign in to comment.