From d461686bc32446b7a944d627c73c6ec4bb1ee4af Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 27 May 2021 17:39:56 -0700 Subject: [PATCH] Fix Maraquan modeling This was a known oversight, that I've finally fixed because I realized this subquery probably would be just fine lol! Now, instead of removing rows with _all_ species modeled, we remove rows with all species _for that color_ modeled. This leaves the rest of the modeling list unchanged, but removed 10 Maraquan items that were done modeling but still on the list: - Dyeworks Coral: Maraquan White Beaded Gown - Dyeworks Green: Maraquan White Beaded Gown - Dyeworks Lavender: Maraquan White Beaded Gown - Dyeworks Purple: Maraquan Wig with Negg Accessory - Dyeworks Lavender: Maraquan Sea Blue Gown - Dyeworks Pink: Maraquan Sea Blue Gown - Dyeworks Silver: Maraquan Sea Blue Gown - Maraquan White Lace Gown - Underwater Maraquan Markings (I also went in the database and marked the "Maraquan Ocean Blue Contacts" with the `modeling_status_hint = "done"`, because it's not compatible with Lutari.) --- src/server/loaders.js | 10 +++++++--- src/server/types/Item.js | 16 +++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/server/loaders.js b/src/server/loaders.js index 41d4e7b..8c3c1b6 100644 --- a/src/server/loaders.js +++ b/src/server/loaders.js @@ -427,7 +427,11 @@ const buildItemsThatNeedModelsLoader = (db) => GROUP_CONCAT( T_BODIES.species_id ORDER BY T_BODIES.species_id - ) AS modeled_species_ids + ) AS modeled_species_ids, + ( + SELECT GROUP_CONCAT(DISTINCT species_id ORDER BY species_id) + FROM pet_types WHERE color_id = T_BODIES.color_id + ) AS all_species_ids_for_this_color FROM ( -- NOTE: I found that extracting this as a separate query that runs -- first made things WAAAY faster. Less to join/group, I guess? @@ -457,8 +461,8 @@ const buildItemsThatNeedModelsLoader = (db) => modeled_species_count = 0 -- Single species (probably just their item) OR modeled_species_count = 1 - -- All species modeled - OR modeled_species_count = 55 + -- All species modeled (that are compatible with this color) + OR modeled_species_ids = all_species_ids_for_this_color -- All species modeled except Vandagyre, for items that don't support it OR (NOT T_ITEMS.supports_vandagyre AND modeled_species_count = 54 AND modeled_species_ids = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54") ) diff --git a/src/server/types/Item.js b/src/server/types/Item.js index 6d6d3ae..336cb37 100644 --- a/src/server/types/Item.js +++ b/src/server/types/Item.js @@ -438,12 +438,18 @@ const resolvers = { } const modeledSpeciesIds = row.modeledSpeciesIds.split(","); - // HACK: Needs to be updated if more species are added! - const allSpeciesIds = Array.from( - { length: row.supportsVandagyre ? 55 : 54 }, - (_, i) => String(i + 1) + const allSpeciesIdsForThisColor = row.allSpeciesIdsForThisColor.split( + "," ); - const unmodeledSpeciesIds = allSpeciesIds.filter( + + let allModelableSpeciesIds = allSpeciesIdsForThisColor; + if (!row.supportsVandagyre) { + allModelableSpeciesIds = allModelableSpeciesIds.filter( + (s) => s !== "55" + ); + } + + const unmodeledSpeciesIds = allModelableSpeciesIds.filter( (id) => !modeledSpeciesIds.includes(id) ); return unmodeledSpeciesIds.map((id) => ({ id }));