oops, add support for all-body item layers!
This commit is contained in:
parent
5028c39ea9
commit
881be0c910
2 changed files with 39 additions and 9 deletions
|
@ -89,7 +89,7 @@ describe("Item", () => {
|
||||||
const res = await query({
|
const res = await query({
|
||||||
query: gql`
|
query: gql`
|
||||||
query {
|
query {
|
||||||
items(ids: ["38912", "38911"]) {
|
items(ids: ["38912", "38911", "37375"]) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
|
||||||
|
@ -113,6 +113,23 @@ describe("Item", () => {
|
||||||
expect(res.data).toMatchInlineSnapshot(`
|
expect(res.data).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"items": Array [
|
"items": Array [
|
||||||
|
Object {
|
||||||
|
"appearanceOn": Object {
|
||||||
|
"layers": Array [
|
||||||
|
Object {
|
||||||
|
"id": "30203",
|
||||||
|
"imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/006/6829/600x600.png?0",
|
||||||
|
"zone": Object {
|
||||||
|
"depth": 3,
|
||||||
|
"id": "3",
|
||||||
|
"label": "Background",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"id": "37375",
|
||||||
|
"name": "Moon and Stars Background",
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"appearanceOn": Object {
|
"appearanceOn": Object {
|
||||||
"layers": Array [
|
"layers": Array [
|
||||||
|
@ -153,26 +170,30 @@ describe("Item", () => {
|
||||||
expect(queryFn.mock.calls).toMatchInlineSnapshot(`
|
expect(queryFn.mock.calls).toMatchInlineSnapshot(`
|
||||||
Array [
|
Array [
|
||||||
Array [
|
Array [
|
||||||
"SELECT * FROM items WHERE id IN (?,?)",
|
"SELECT * FROM items WHERE id IN (?,?,?)",
|
||||||
Array [
|
Array [
|
||||||
"38912",
|
"38912",
|
||||||
"38911",
|
"38911",
|
||||||
|
"37375",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"SELECT * FROM item_translations WHERE item_id IN (?,?) AND locale = \\"en\\"",
|
"SELECT * FROM item_translations WHERE item_id IN (?,?,?) AND locale = \\"en\\"",
|
||||||
Array [
|
Array [
|
||||||
|
"37375",
|
||||||
"38911",
|
"38911",
|
||||||
"38912",
|
"38912",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"SELECT * FROM pet_types WHERE (species_id = ? AND color_id = ?) OR (species_id = ? AND color_id = ?)",
|
"SELECT * FROM pet_types WHERE (species_id = ? AND color_id = ?) OR (species_id = ? AND color_id = ?) OR (species_id = ? AND color_id = ?)",
|
||||||
Array [
|
Array [
|
||||||
"54",
|
"54",
|
||||||
"75",
|
"75",
|
||||||
"54",
|
"54",
|
||||||
"75",
|
"75",
|
||||||
|
"54",
|
||||||
|
"75",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
|
@ -180,8 +201,10 @@ describe("Item", () => {
|
||||||
INNER JOIN parents_swf_assets rel ON
|
INNER JOIN parents_swf_assets rel ON
|
||||||
rel.parent_type = \\"Item\\" AND
|
rel.parent_type = \\"Item\\" AND
|
||||||
rel.swf_asset_id = sa.id
|
rel.swf_asset_id = sa.id
|
||||||
WHERE (rel.parent_id = ? AND sa.body_id = ?) OR (rel.parent_id = ? AND sa.body_id = ?)",
|
WHERE (rel.parent_id = ? AND (sa.body_id = ? OR sa.body_id = 0)) OR (rel.parent_id = ? AND (sa.body_id = ? OR sa.body_id = 0)) OR (rel.parent_id = ? AND (sa.body_id = ? OR sa.body_id = 0))",
|
||||||
Array [
|
Array [
|
||||||
|
"37375",
|
||||||
|
"180",
|
||||||
"38911",
|
"38911",
|
||||||
"180",
|
"180",
|
||||||
"38912",
|
"38912",
|
||||||
|
@ -189,15 +212,17 @@ describe("Item", () => {
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"SELECT * FROM zones WHERE id IN (?,?)",
|
"SELECT * FROM zones WHERE id IN (?,?,?)",
|
||||||
Array [
|
Array [
|
||||||
|
"3",
|
||||||
"40",
|
"40",
|
||||||
"26",
|
"26",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
"SELECT * FROM zone_translations WHERE zone_id IN (?,?) AND locale = \\"en\\"",
|
"SELECT * FROM zone_translations WHERE zone_id IN (?,?,?) AND locale = \\"en\\"",
|
||||||
Array [
|
Array [
|
||||||
|
"3",
|
||||||
"40",
|
"40",
|
||||||
"26",
|
"26",
|
||||||
],
|
],
|
||||||
|
|
|
@ -57,7 +57,9 @@ const buildSwfAssetLoader = (db) =>
|
||||||
const conditions = [];
|
const conditions = [];
|
||||||
const values = [];
|
const values = [];
|
||||||
for (const { itemId, bodyId } of itemAndBodyPairs) {
|
for (const { itemId, bodyId } of itemAndBodyPairs) {
|
||||||
conditions.push("(rel.parent_id = ? AND sa.body_id = ?)");
|
conditions.push(
|
||||||
|
"(rel.parent_id = ? AND (sa.body_id = ? OR sa.body_id = 0))"
|
||||||
|
);
|
||||||
values.push(itemId, bodyId);
|
values.push(itemId, bodyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +75,10 @@ const buildSwfAssetLoader = (db) =>
|
||||||
const entities = rows.map(normalizeRow);
|
const entities = rows.map(normalizeRow);
|
||||||
|
|
||||||
return itemAndBodyPairs.map(({ itemId, bodyId }) =>
|
return itemAndBodyPairs.map(({ itemId, bodyId }) =>
|
||||||
entities.filter((e) => e.parentId === itemId && e.bodyId === bodyId)
|
entities.filter(
|
||||||
|
(e) =>
|
||||||
|
e.parentId === itemId && (e.bodyId === bodyId || e.bodyId === "0")
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue