Migrate away from item translations for item search
This commit is contained in:
parent
62531cfe34
commit
c455617362
1 changed files with 6 additions and 5 deletions
|
@ -308,7 +308,9 @@ function buildItemSearchConditions({
|
|||
continue;
|
||||
}
|
||||
|
||||
const condition = isNegative ? "t.name NOT LIKE ?" : "t.name LIKE ?";
|
||||
const condition = isNegative
|
||||
? "items.name NOT LIKE ?"
|
||||
: "items.name LIKE ?";
|
||||
const matcher = "%" + word.replace(/_%/g, "\\$0") + "%";
|
||||
|
||||
wordMatchConditions.push(condition);
|
||||
|
@ -336,7 +338,6 @@ function buildItemSearchConditions({
|
|||
: [];
|
||||
|
||||
const queryJoins = `
|
||||
INNER JOIN item_translations t ON t.item_id = items.id
|
||||
INNER JOIN parents_swf_assets rel
|
||||
ON rel.parent_type = "Item" AND rel.parent_id = items.id
|
||||
INNER JOIN swf_assets ON rel.swf_asset_id = swf_assets.id
|
||||
|
@ -346,7 +347,7 @@ function buildItemSearchConditions({
|
|||
const queryConditions = `
|
||||
(${wordMatchCondition}) AND (${bodyIdCondition}) AND
|
||||
(${zoneIdsCondition}) AND (${itemKindCondition}) AND
|
||||
(${currentUserCondition}) AND t.locale = "en"
|
||||
(${currentUserCondition})
|
||||
`;
|
||||
const queryConditionValues = [
|
||||
...wordMatchValues,
|
||||
|
@ -430,10 +431,10 @@ const buildItemSearchItemsLoader = (db, loaders) =>
|
|||
|
||||
const [rows] = await db.execute(
|
||||
`
|
||||
SELECT DISTINCT items.*, t.name FROM items
|
||||
SELECT DISTINCT items.* FROM items
|
||||
${queryJoins}
|
||||
WHERE ${queryConditions}
|
||||
ORDER BY t.name
|
||||
ORDER BY items.name
|
||||
LIMIT ? OFFSET ?
|
||||
`,
|
||||
[...queryConditionValues, actualLimit, actualOffset],
|
||||
|
|
Loading…
Reference in a new issue