From b7b4fa21ec071962eac764f5ea9a8183ddaa9a55 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 17 Jul 2021 05:47:32 -0700 Subject: [PATCH 1/3] Oops, show models needed for special colors Right, oops, `speciesThatNeedModels` is for standard colors! Add in the special colors, too! --- src/app/HomePage.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/app/HomePage.js b/src/app/HomePage.js index 50ee7ff..c687068 100644 --- a/src/app/HomePage.js +++ b/src/app/HomePage.js @@ -386,6 +386,18 @@ function NewItemsSectionContent() { id name } + babySpeciesThatNeedModels: speciesThatNeedModels(colorId: "6") { + id + name + } + maraquanSpeciesThatNeedModels: speciesThatNeedModels(colorId: "44") { + id + name + } + mutantSpeciesThatNeedModels: speciesThatNeedModels(colorId: "46") { + id + name + } compatibleBodiesAndTheirZones { body { id @@ -492,10 +504,16 @@ function ItemModelingSummary({ item }) { // NOTE: To test this logic, I like to swap out `newestItems` in the query: // `newestItems: items(ids: ["81546", "35082", "75149", "81797", "58741", "78953", "82427", "82727", "82726"])` - if (item.speciesThatNeedModels.length > 0) { + const numModelsNeeded = + item.speciesThatNeedModels.length + + item.babySpeciesThatNeedModels.length + + item.maraquanSpeciesThatNeedModels.length + + item.mutantSpeciesThatNeedModels.length; + + if (numModelsNeeded > 0) { return ( - Need {item.speciesThatNeedModels.length} models + Need {numModelsNeeded} models ); } From 2ba18ace4d48d37740bf169bce3ff003be7e1fb8 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 21 Jul 2021 16:03:24 -0700 Subject: [PATCH 2/3] Add debug lines to appearanceOn Apollo resolver Hmm, the item page in prod is slower than it is in dev? In dev, most items are satisfied by the preloading in ItemPagePreview, but in prod, those same items need to send a separate OutfitItemsAppearance query _way_ after (which, I think just due to queueing, waits for all the items to wait too). There's an obvious issue in the case of all the Maraquan items lately, because we just don't do the clever cache lookups for non-standard colors at all. But I don't understand why even standard items like the 17th Birthday Party Hat are struggling! These are just some simple debug statements, hopefully they'll tell us something about the basics of what's happening! --- src/app/apolloClient.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/apolloClient.js b/src/app/apolloClient.js index 8e503ad..9bf6c5d 100644 --- a/src/app/apolloClient.js +++ b/src/app/apolloClient.js @@ -58,6 +58,12 @@ const typePolicies = { // it! This helps for fast loading when switching between standard // colors. const { speciesId, colorId } = args; + console.debug( + "[appearanceOn] seeking cached appearance", + speciesId, + colorId, + readField("id") + ); const speciesStandardBodyId = readField( "standardBodyId", toReference({ __typename: "Species", id: speciesId }) @@ -71,16 +77,22 @@ const typePolicies = { // be loading them, depending on the page? Either way, return // `undefined`, meaning we don't know how to serve this from cache. // This will cause us to start loading it from the server. + console.debug("[appearanceOn] species/colors not loaded yet"); return undefined; } if (colorIsStandard) { const itemId = readField("id"); + console.debug( + "[appearanceOn] standard color, will read:", + `item-${itemId}-body-${speciesStandardBodyId}` + ); return toReference({ __typename: "ItemAppearance", id: `item-${itemId}-body-${speciesStandardBodyId}`, }); } else { + console.debug("[appearanceOn] non-standard color, failure"); // This isn't a standard color, so we don't support special // cross-color caching for it. Return `undefined`, meaning we don't // know how to serve this from cache. This will cause us to start From fb12f817e255be4b4f47a269618229f86a1d0f38 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 29 Jul 2021 00:24:29 -0700 Subject: [PATCH 3/3] Add negative word filters to search Just a quick lil change on a whim, I hope it works well! --- src/server/loaders.js | 45 ++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/server/loaders.js b/src/server/loaders.js index b482ab5..18be3be 100644 --- a/src/server/loaders.js +++ b/src/server/loaders.js @@ -308,10 +308,25 @@ function buildItemSearchConditions({ // Split the query into words, and search for each word as a substring // of the name. const words = query.split(/\s+/); - const wordMatchersForMysql = words.map( - (word) => "%" + word.replace(/_%/g, "\\$0") + "%" - ); - const matcherPlaceholders = words.map((_) => "t.name LIKE ?").join(" AND "); + const wordMatchConditions = []; + const wordMatchValues = []; + for (let word of words) { + // If the word starts with `-`, remove `-` and treat the filter as negative. + const isNegative = word.startsWith("-"); + if (isNegative) { + word = word.substr(1); + } + if (!word) { + continue; + } + + const condition = isNegative ? "t.name NOT LIKE ?" : "t.name LIKE ?"; + const matcher = "%" + word.replace(/_%/g, "\\$0") + "%"; + + wordMatchConditions.push(condition); + wordMatchValues.push(matcher); + } + const wordMatchCondition = wordMatchConditions.join(" AND ") || "1"; const itemKindCondition = itemSearchKindConditions[itemKind] || "1"; const bodyIdCondition = bodyId @@ -333,20 +348,20 @@ 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 - ${currentUserJoin} - `; + 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 + ${currentUserJoin} + `; const queryConditions = ` - (${matcherPlaceholders}) AND t.locale = "en" AND - (${bodyIdCondition}) AND (${zoneIdsCondition}) AND - (${itemKindCondition}) AND (${currentUserCondition}) - `; + (${wordMatchCondition}) AND (${bodyIdCondition}) AND + (${zoneIdsCondition}) AND (${itemKindCondition}) AND + (${currentUserCondition}) AND t.locale = "en" + `; const queryConditionValues = [ - ...wordMatchersForMysql, + ...wordMatchValues, ...bodyIdValues, ...zoneIds, ...currentUserValues,