mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-06-07 13:49:54 +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) => {
|
const res = (require(`../../../generated/${lang}/cards.json`) as Array<SDKCard>).find((c) => {
|
||||||
return objectLoop(params, (it, key) => {
|
return objectLoop(params, (it, key) => {
|
||||||
if (key === 'set' && typeof it === 'string') {
|
if (key === 'set' && typeof it === 'string') {
|
||||||
return (
|
console.log("set", c['set'].id, it, lightCheck(c['set'].id, it))
|
||||||
lightCheck(c['set'].id, it) || lightCheck(c['set'].name, 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)
|
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) {
|
public static find(lang: SupportedLanguages, params: Partial<Record<keyof SDKSerie, any>> = {}, pagination?: Pagination) {
|
||||||
let list = (require(`../../../generated/${lang}/series.json`) as Array<SDKSerie>)
|
let list = (require(`../../../generated/${lang}/series.json`) as Array<SDKSerie>)
|
||||||
.filter((c) => objectLoop(params, (it, key) => {
|
.filter((c) => objectLoop(params, (it, key) => {
|
||||||
|
if (key === 'id') return c[key] === it
|
||||||
return lightCheck(c[key as 'id'], it)
|
return lightCheck(c[key as 'id'], it)
|
||||||
}))
|
}))
|
||||||
if (pagination) {
|
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 {
|
public static findOne(lang: SupportedLanguages, params: Partial<Record<keyof Serie, any>> = {}): Serie | undefined {
|
||||||
const res = (require(`../../../generated/${lang}/series.json`) as Array<SDKSerie>)
|
const res = (require(`../../../generated/${lang}/series.json`) as Array<SDKSerie>)
|
||||||
.find((c) => {
|
.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) {
|
if (!res) {
|
||||||
return undefined
|
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) {
|
public static find(lang: SupportedLanguages, params: Partial<Record<keyof SDKSet, any>> = {}, pagination?: Pagination) {
|
||||||
let list = (require(`../../../generated/${lang}/sets.json`) as Array<SDKSet>)
|
let list = (require(`../../../generated/${lang}/sets.json`) as Array<SDKSet>)
|
||||||
.filter((c) => objectLoop(params, (it, key) => {
|
.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)
|
return lightCheck(c[key as 'id'], it)
|
||||||
}))
|
}))
|
||||||
if (pagination) {
|
if (pagination) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user