mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-06-06 13:29:55 +00:00
fix: Fix Endpoints not giving the correct card with a speicific id (#196)
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
eecbee9194
commit
c2ea960801
@ -80,10 +80,10 @@ export default class Card implements LocalCard {
|
||||
const res = (require(`../../../generated/${lang}/cards.json`) as Array<SDKCard>).find((c) => {
|
||||
return objectLoop(params, (it, key) => {
|
||||
if (key === 'set' && typeof it === 'string') {
|
||||
return (
|
||||
lightCheck(c['set'].id, it) || lightCheck(c['set'].name, it)
|
||||
)
|
||||
console.log("set", c['set'].id, it, lightCheck(c['set'].id, it))
|
||||
return (c['set'].id === it || lightCheck(c['set'].name, it))
|
||||
}
|
||||
console.log("other field", key, c[key as 'localId'], it, lightCheck(c[key as 'localId'], it))
|
||||
return lightCheck(c[key as 'localId'], it)
|
||||
})
|
||||
})
|
||||
|
@ -31,6 +31,7 @@ export default class Serie implements LocalSerie {
|
||||
public static find(lang: SupportedLanguages, params: Partial<Record<keyof SDKSerie, any>> = {}, pagination?: Pagination) {
|
||||
let list = (require(`../../../generated/${lang}/series.json`) as Array<SDKSerie>)
|
||||
.filter((c) => objectLoop(params, (it, key) => {
|
||||
if (key === 'id') return c[key] === it
|
||||
return lightCheck(c[key as 'id'], it)
|
||||
}))
|
||||
if (pagination) {
|
||||
@ -43,7 +44,10 @@ export default class Serie implements LocalSerie {
|
||||
public static findOne(lang: SupportedLanguages, params: Partial<Record<keyof Serie, any>> = {}): Serie | undefined {
|
||||
const res = (require(`../../../generated/${lang}/series.json`) as Array<SDKSerie>)
|
||||
.find((c) => {
|
||||
return objectLoop(params, (it, key) => lightCheck(c[key as 'id'], it))
|
||||
return objectLoop(params, (it, key) => {
|
||||
if (key === 'id') return c[key] === it
|
||||
return lightCheck(c[key as 'id'], it)
|
||||
})
|
||||
})
|
||||
if (!res) {
|
||||
return undefined
|
||||
|
@ -49,7 +49,11 @@ export default class Set implements LocalSet {
|
||||
public static find(lang: SupportedLanguages, params: Partial<Record<keyof SDKSet, any>> = {}, pagination?: Pagination) {
|
||||
let list = (require(`../../../generated/${lang}/sets.json`) as Array<SDKSet>)
|
||||
.filter((c) => objectLoop(params, (it, key) => {
|
||||
|
||||
if (key === 'id' || key === 'name') {
|
||||
return c[key as 'id'].toLowerCase() === it.toLowerCase()
|
||||
} else if (typeof it === 'string') {
|
||||
return c[key as 'id'].toLowerCase().includes(it.toLowerCase())
|
||||
}
|
||||
return lightCheck(c[key as 'id'], it)
|
||||
}))
|
||||
if (pagination) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user