From 68b5486bb7861460c65219b01ae215a60b0c489f Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 3 Oct 2020 04:05:25 -0700 Subject: [PATCH] update `labeled` field for pet appearances Oops, when building the Support tool to label pet appearances, I didn't realize that there's also a boolean `labeled` field that needs to be true for labeled appearances. Without it, the old app shows the appearance as "Unlabeled". I also ran this query to fix the rows we'd incorrectly written: ``` mysql> UPDATE pet_states SET labeled = 1 WHERE mood_id IS NOT NULL; Query OK, 158 rows affected (0.14 sec) Rows matched: 19640 Changed: 158 Warnings: 0 ``` --- src/server/types/MutationsForSupport.js | 13 +++++++++---- src/server/util.js | 16 ++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/server/types/MutationsForSupport.js b/src/server/types/MutationsForSupport.js index 5f665f4..85cebf3 100644 --- a/src/server/types/MutationsForSupport.js +++ b/src/server/types/MutationsForSupport.js @@ -380,12 +380,17 @@ const resolvers = { const oldPetState = await petStateLoader.load(appearanceId); - const { moodId, female, unconverted } = getPetStateFieldsFromPose(pose); + const { + moodId, + female, + unconverted, + labeled, + } = getPetStateFieldsFromPose(pose); const [result] = await db.execute( - `UPDATE pet_states SET mood_id = ?, female = ?, unconverted = ? - WHERE id = ? LIMIT 1`, - [moodId, female, unconverted, appearanceId] + `UPDATE pet_states SET mood_id = ?, female = ?, unconverted = ?, + labeled = ? WHERE id = ? LIMIT 1`, + [moodId, female, unconverted, labeled, appearanceId] ); if (result.affectedRows !== 1) { diff --git a/src/server/util.js b/src/server/util.js index 8a456d5..b8fd18a 100644 --- a/src/server/util.js +++ b/src/server/util.js @@ -36,21 +36,21 @@ function getPoseFromPetState(petState) { function getPetStateFieldsFromPose(pose) { if (pose === "UNCONVERTED") { - return { moodId: null, female: null, unconverted: true }; + return { moodId: null, female: null, unconverted: true, labeled: true }; } else if (pose === "UNKNOWN") { - return { moodId: null, female: null, unconverted: false }; + return { moodId: null, female: null, unconverted: false, labeled: false }; } else if (pose === "HAPPY_MASC") { - return { moodId: "1", female: false, unconverted: false }; + return { moodId: "1", female: false, unconverted: false, labeled: true }; } else if (pose === "HAPPY_FEM") { - return { moodId: "1", female: true, unconverted: false }; + return { moodId: "1", female: true, unconverted: false, labeled: true }; } else if (pose === "SAD_MASC") { - return { moodId: "2", female: false, unconverted: false }; + return { moodId: "2", female: false, unconverted: false, labeled: true }; } else if (pose === "SAD_FEM") { - return { moodId: "2", female: true, unconverted: false }; + return { moodId: "2", female: true, unconverted: false, labeled: true }; } else if (pose === "SICK_MASC") { - return { moodId: "4", female: false, unconverted: false }; + return { moodId: "4", female: false, unconverted: false, labeled: true }; } else if (pose === "SICK_FEM") { - return { moodId: "4", female: true, unconverted: false }; + return { moodId: "4", female: true, unconverted: false, labeled: true }; } else { throw new Error(`unexpected pose ${pose}`); }