fix bug with duplicate search results

This commit is contained in:
Matt Dunn-Rankin 2020-04-25 20:16:24 -07:00
parent 26244ea776
commit 17e78c5699
2 changed files with 34 additions and 34 deletions

View file

@ -521,7 +521,7 @@ describe("Search", () => {
], ],
], ],
Array [ Array [
"SELECT items.*, t.name FROM items "SELECT DISTINCT items.*, t.name FROM items
INNER JOIN item_translations t ON t.item_id = items.id INNER JOIN item_translations t ON t.item_id = items.id
INNER JOIN parents_swf_assets rel INNER JOIN parents_swf_assets rel
ON rel.parent_type = \\"Item\\" AND rel.parent_id = items.id ON rel.parent_type = \\"Item\\" AND rel.parent_id = items.id
@ -579,10 +579,6 @@ describe("Search", () => {
"id": "67242", "id": "67242",
"name": "Accessories Shop Wig and Hat", "name": "Accessories Shop Wig and Hat",
}, },
Object {
"id": "67242",
"name": "Accessories Shop Wig and Hat",
},
Object { Object {
"id": "64177", "id": "64177",
"name": "Acorn Hat", "name": "Acorn Hat",
@ -591,10 +587,6 @@ describe("Search", () => {
"id": "69995", "id": "69995",
"name": "Adventure in Pastel Hat and Wig", "name": "Adventure in Pastel Hat and Wig",
}, },
Object {
"id": "69995",
"name": "Adventure in Pastel Hat and Wig",
},
Object { Object {
"id": "62375", "id": "62375",
"name": "Altador Cup Trophy Hat", "name": "Altador Cup Trophy Hat",
@ -607,6 +599,14 @@ describe("Search", () => {
"id": "62322", "id": "62322",
"name": "Altador Team Jester Hat", "name": "Altador Team Jester Hat",
}, },
Object {
"id": "58733",
"name": "Apple Bobbing Bart Hat",
},
Object {
"id": "80401",
"name": "Aurricks Finest Hat",
},
], ],
"query": "hat", "query": "hat",
}, },
@ -622,7 +622,7 @@ describe("Search", () => {
], ],
], ],
Array [ Array [
"SELECT items.*, t.name FROM items "SELECT DISTINCT items.*, t.name FROM items
INNER JOIN item_translations t ON t.item_id = items.id INNER JOIN item_translations t ON t.item_id = items.id
INNER JOIN parents_swf_assets rel INNER JOIN parents_swf_assets rel
ON rel.parent_type = \\"Item\\" AND rel.parent_id = items.id ON rel.parent_type = \\"Item\\" AND rel.parent_id = items.id
@ -668,18 +668,6 @@ describe("Search", () => {
Object { Object {
"itemSearchToFit": Object { "itemSearchToFit": Object {
"items": Array [ "items": Array [
Object {
"id": "58733",
"name": "Apple Bobbing Bart Hat",
},
Object {
"id": "80401",
"name": "Aurricks Finest Hat",
},
Object {
"id": "80401",
"name": "Aurricks Finest Hat",
},
Object { Object {
"id": "50168", "id": "50168",
"name": "Babaa Hat", "name": "Babaa Hat",
@ -688,14 +676,6 @@ describe("Search", () => {
"id": "78311", "id": "78311",
"name": "Backwards Hat and Wig", "name": "Backwards Hat and Wig",
}, },
Object {
"id": "78311",
"name": "Backwards Hat and Wig",
},
Object {
"id": "66653",
"name": "Bagel Hat Wig",
},
Object { Object {
"id": "66653", "id": "66653",
"name": "Bagel Hat Wig", "name": "Bagel Hat Wig",
@ -705,8 +685,28 @@ describe("Search", () => {
"name": "Balloon Sculpture Hat", "name": "Balloon Sculpture Hat",
}, },
Object { Object {
"id": "51366", "id": "66236",
"name": "Balloon Sculpture Hat", "name": "Banker Hat and Wig",
},
Object {
"id": "52733",
"name": "Battlefield Legends Hat",
},
Object {
"id": "57617",
"name": "Big Black Lace Pirate Hat",
},
Object {
"id": "44451",
"name": "Big Fuzzy Hat",
},
Object {
"id": "58318",
"name": "Bigsby Shadingtons Hat",
},
Object {
"id": "39883",
"name": "Bird Nest Hat",
}, },
], ],
"query": "hat", "query": "hat",
@ -723,7 +723,7 @@ describe("Search", () => {
], ],
], ],
Array [ Array [
"SELECT items.*, t.name FROM items "SELECT DISTINCT items.*, t.name FROM items
INNER JOIN item_translations t ON t.item_id = items.id INNER JOIN item_translations t ON t.item_id = items.id
INNER JOIN parents_swf_assets rel INNER JOIN parents_swf_assets rel
ON rel.parent_type = \\"Item\\" AND rel.parent_id = items.id ON rel.parent_type = \\"Item\\" AND rel.parent_id = items.id

View file

@ -129,7 +129,7 @@ const buildItemSearchToFitLoader = (db) =>
const queryForMysql = "%" + query.replace(/_%/g, "\\$0") + "%"; const queryForMysql = "%" + query.replace(/_%/g, "\\$0") + "%";
const [rows, _] = await db.execute( const [rows, _] = await db.execute(
`SELECT items.*, t.name FROM items `SELECT DISTINCT items.*, t.name FROM items
INNER JOIN item_translations t ON t.item_id = items.id INNER JOIN item_translations t ON t.item_id = items.id
INNER JOIN parents_swf_assets rel INNER JOIN parents_swf_assets rel
ON rel.parent_type = "Item" AND rel.parent_id = items.id ON rel.parent_type = "Item" AND rel.parent_id = items.id