Skip to content

Commit

Permalink
Feat/fuzzy search (#718)
Browse files Browse the repository at this point in the history
* feat: Add support for fuzzy search for /collections endpoint (#710)

* feat: Add support for fuzzy search for /collections endpoint

* feat: add if isPublished is "true" check

* chore: remove commented line

* Update src/Collection/Collection.router.spec.ts

Co-authored-by: Lautaro Petaccio <1120791+LautaroPetaccio@users.noreply.github.com>
Signed-off-by: Juanma Hidalgo <juanma06@gmail.com>

---------

Signed-off-by: Juanma Hidalgo <juanma06@gmail.com>
Co-authored-by: Lautaro Petaccio <1120791+LautaroPetaccio@users.noreply.github.com>

* feat: use node:18.17.1-alpine

---------

Signed-off-by: Juanma Hidalgo <juanma06@gmail.com>
Co-authored-by: Lautaro Petaccio <1120791+LautaroPetaccio@users.noreply.github.com>
  • Loading branch information
juanmahidalgo and LautaroPetaccio committed Sep 28, 2023
1 parent e5b9e4c commit abd1e68
Show file tree
Hide file tree
Showing 5 changed files with 455 additions and 189 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG RUN

FROM node:18-alpine3.16 as builder
FROM node:18.17.1-alpine as builder

WORKDIR /app

Expand All @@ -18,7 +18,7 @@ COPY . /app

RUN npm run build

FROM node:18-alpine3.16
FROM node:18.17.1-alpine

WORKDIR /app

Expand Down
13 changes: 13 additions & 0 deletions migrations/1695119925617_add-trgm-extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate'

export const shorthands: ColumnDefinitions | undefined = undefined

export async function up(pgm: MigrationBuilder): Promise<void> {
pgm.addExtension('pg_trgm', { ifNotExists: true })
pgm.sql('SET pg_trgm.similarity_threshold = 0.5')
}

export async function down(pgm: MigrationBuilder): Promise<void> {
pgm.dropExtension('pg_trgm')
}
2 changes: 1 addition & 1 deletion src/Collection/Collection.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class Collection extends Model<CollectionAttributes> {
const isInRemoteIds = SQL`collections.contract_address = ANY(${remoteIds})`
const sameStatusAndInTheBlockchain = SQL`(collection_curations.status = ${status} AND (${isInRemoteIds} OR (${isThirdParty})))`
const conditions = [
q ? SQL`collections.name ILIKE '%' || ${q} || '%'` : undefined,
q ? SQL`collections.name % ${q} ` : undefined,
assignee ? SQL`collection_curations.assignee = ${assignee}` : undefined,
address
? thirdPartyIds?.length
Expand Down
Loading

0 comments on commit abd1e68

Please sign in to comment.