Merge branch 'main' of github.com:matchu/impress-2020 into main

This commit is contained in:
Emi Matchu 2021-08-07 21:44:37 -07:00
commit 30e6c46d48
3 changed files with 62 additions and 17 deletions

View file

@ -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 (
<Box fontSize="xs" fontStyle="italic" fontWeight="600" opacity="0.8">
Need {item.speciesThatNeedModels.length} models
Need {numModelsNeeded} models
</Box>
);
}

View file

@ -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

View file

@ -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,