Skip to content

Commit

Permalink
feat: Use tags in lowercase to filter without case sensitivity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cyaiox committed Oct 6, 2022
1 parent 85ec5ef commit 11f8f2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Collection/Collection.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class Collection extends Model<CollectionAttributes> {
: SQL``
: undefined,
itemTags
? SQL`(items.data::json->'tags')::jsonb ? ANY(${itemTags})`
? SQL`LOWER(items.data::json->>'tags')::jsonb ? ANY(${itemTags})`
: undefined,
].filter(Boolean)

Expand Down
6 changes: 3 additions & 3 deletions src/Collection/Collection.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ describe('Collection router', () => {
limit,
thirdPartyIds: [],
remoteIds: [],
itemTags: [itemTag, itemTag2],
itemTags: [itemTag.toLowerCase(), itemTag2.toLowerCase()],
})
})
})
Expand Down Expand Up @@ -2705,7 +2705,7 @@ describe('Collection router', () => {
limit,
thirdPartyIds: [],
remoteIds: [],
itemTags: [itemTag],
itemTags: [itemTag.toLowerCase()],
})
})
})
Expand Down Expand Up @@ -2765,7 +2765,7 @@ describe('Collection router', () => {
limit,
thirdPartyIds: [],
remoteIds: [],
itemTags: [itemTag, itemTag2],
itemTags: [itemTag.toLowerCase(), itemTag2.toLowerCase()],
})
})
})
Expand Down
8 changes: 4 additions & 4 deletions src/Collection/Collection.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ export class CollectionRouter extends Router {
remoteCollections.filter((r) => !r.isApproved).map((c) => c.id),
itemTags: tag
? Array.isArray(tag)
? (tag as string[])
: [tag as string]
? (tag as string[]).map((t) => t.toLowerCase())
: [(tag as string).toLowerCase()]
: undefined,
})

Expand Down Expand Up @@ -624,8 +624,8 @@ export class CollectionRouter extends Router {
remoteCollections.filter((r) => !r.isApproved).map((c) => c.id),
itemTags: tag
? Array.isArray(tag)
? (tag as string[])
: [tag as string]
? (tag as string[]).map((t) => t.toLowerCase())
: [(tag as string).toLowerCase()]
: undefined,
})

Expand Down

0 comments on commit 11f8f2b

Please sign in to comment.