add body name to support log for removed layer

In practice I saw that this doesn't actually tell you what you _really_ want to know about where the change happened! You want to know it was broken on the Acara or w/e.
This commit is contained in:
Emi Matchu 2020-08-20 23:23:33 -07:00
parent 10cea2ff92
commit 7b1d2d67f0
2 changed files with 35 additions and 29 deletions

View file

@ -10,6 +10,7 @@ const {
getPoseFromPetData,
getEmotion,
getGenderPresentation,
loadBodyName,
logToDiscord,
normalizeRow,
} = require("./util");
@ -792,31 +793,6 @@ const resolvers = {
if (process.env["SUPPORT_TOOLS_DISCORD_WEBHOOK_URL"]) {
try {
async function loadBodyName(bodyId) {
if (String(bodyId) === "0") {
return "All bodies";
}
const [rows] = await db.execute(
`SELECT pt.body_id, st.name AS species_name,
ct.name AS color_name, c.standard FROM pet_types pt
INNER JOIN species_translations st
ON pt.species_id = st.species_id AND st.locale = "en"
INNER JOIN color_translations ct
ON pt.color_id = ct.color_id AND ct.locale = "en"
INNER JOIN colors c ON c.id = pt.color_id
WHERE pt.body_id = ?
ORDER BY ct.name, st.name LIMIT 1;`,
[bodyId]
);
const row = normalizeRow(rows[0]);
const speciesName = capitalize(row.speciesName);
const colorName = row.standard
? "Standard"
: capitalize(row.colorName);
return `${colorName} ${speciesName}`;
}
const itemId = await db
.execute(
`SELECT parent_id FROM parents_swf_assets
@ -835,8 +811,8 @@ const resolvers = {
itemLoader.load(itemId),
itemTranslationLoader.load(itemId),
zoneTranslationLoader.load(oldSwfAsset.zoneId),
loadBodyName(oldSwfAsset.bodyId),
loadBodyName(bodyId),
loadBodyName(oldSwfAsset.bodyId, db),
loadBodyName(bodyId, db),
]);
await logToDiscord({
@ -905,10 +881,16 @@ const resolvers = {
if (process.env["SUPPORT_TOOLS_DISCORD_WEBHOOK_URL"]) {
try {
const [item, itemTranslation, zoneTranslation] = await Promise.all([
const [
item,
itemTranslation,
zoneTranslation,
bodyName,
] = await Promise.all([
itemLoader.load(itemId),
itemTranslationLoader.load(itemId),
zoneTranslationLoader.load(oldSwfAsset.zoneId),
loadBodyName(oldSwfAsset.bodyId, db),
]);
await logToDiscord({
@ -923,7 +905,7 @@ const resolvers = {
fields: [
{
name: `Layer ${layerId} (${zoneTranslation.label})`,
value: `❌ Removed from item`,
value: `❌ Removed from ${bodyName}`,
},
],
timestamp: new Date().toISOString(),

View file

@ -85,6 +85,29 @@ function getPoseFromPetData(petMetaData, petCustomData) {
}
}
async function loadBodyName(bodyId, db) {
if (String(bodyId) === "0") {
return "All bodies";
}
const [rows] = await db.execute(
`SELECT pt.body_id, st.name AS species_name,
ct.name AS color_name, c.standard FROM pet_types pt
INNER JOIN species_translations st
ON pt.species_id = st.species_id AND st.locale = "en"
INNER JOIN color_translations ct
ON pt.color_id = ct.color_id AND ct.locale = "en"
INNER JOIN colors c ON c.id = pt.color_id
WHERE pt.body_id = ?
ORDER BY ct.name, st.name LIMIT 1;`,
[bodyId]
);
const row = normalizeRow(rows[0]);
const speciesName = capitalize(row.speciesName);
const colorName = row.standard ? "Standard" : capitalize(row.colorName);
return `${colorName} ${speciesName}`;
}
async function logToDiscord(body) {
const span = beeline.startSpan({ name: "logToDiscord" });
@ -126,6 +149,7 @@ module.exports = {
getGenderPresentation,
getPoseFromPetState,
getPoseFromPetData,
loadBodyName,
logToDiscord,
normalizeRow,
};