remove svgUrl logging

this has sorta become log noise, now that we have support for the movie assets and stuff, and we know we're pretty reliable overall
This commit is contained in:
Emi Matchu 2020-10-23 22:45:35 -07:00
parent 3a20deba09
commit 851e6201eb
2 changed files with 3 additions and 51 deletions

View file

@ -4,7 +4,6 @@ const { gql, makeExecutableSchema } = require("apollo-server");
const { getUserIdFromToken } = require("./auth");
const connectToDb = require("./db");
const buildLoaders = require("./loaders");
const { svgLoggingPlugin } = require("./types/AppearanceLayer");
const rootTypeDefs = gql`
directive @cacheControl(maxAge: Int!) on FIELD_DEFINITION | OBJECT
@ -44,7 +43,7 @@ const schema = makeExecutableSchema(
])
);
const plugins = [svgLoggingPlugin];
const plugins = [];
if (process.env["NODE_ENV"] !== "test") {
plugins.push(beelinePlugin);
@ -55,8 +54,6 @@ const config = {
context: async ({ req }) => {
const db = await connectToDb();
const svgLogger = svgLoggingPlugin.buildSvgLogger();
const auth = (req && req.headers && req.headers.authorization) || "";
const authMatch = auth.match(/^Bearer (.+)$/);
const token = authMatch && authMatch[1];
@ -64,7 +61,6 @@ const config = {
return {
db,
svgLogger,
currentUserId,
...buildLoaders(db),
};

View file

@ -117,7 +117,7 @@ const resolvers = {
`/${rid1}/${rid2}/${rid3}/${rid}/${sizeNum}x${sizeNum}.png?v2-${time}`
);
},
svgUrl: async ({ id }, _, { db, swfAssetLoader, svgLogger }) => {
svgUrl: async ({ id }, _, { db, swfAssetLoader }) => {
const layer = await swfAssetLoader.load(id);
let manifest = layer.manifest && JSON.parse(layer.manifest);
@ -128,27 +128,22 @@ const resolvers = {
}
if (!manifest) {
svgLogger.log("no-manifest");
return null;
}
if (manifest.assets.length !== 1) {
svgLogger.log(`wrong-asset-count:${manifest.assets.length}!=1`);
return null;
}
const asset = manifest.assets[0];
if (asset.format !== "vector") {
svgLogger.log(`wrong-asset-format:${asset.format}`);
return null;
}
if (asset.assetData.length !== 1) {
svgLogger.log(`wrong-assetData-length:${asset.assetData.length}!=1`);
return null;
}
svgLogger.log("success");
const assetDatum = asset.assetData[0];
const url = new URL(assetDatum.path, "http://images.neopets.com");
return url.toString();
@ -273,43 +268,4 @@ function convertSwfUrlToManifestUrl(swfUrl) {
return `http://images.neopets.com/cp/${type}/data/${folders}/manifest.json`;
}
let lastSvgLogger = null;
const svgLoggingPlugin = {
requestDidStart() {
return {
willSendResponse({ operationName }) {
const logEntries = lastSvgLogger.entries;
if (logEntries.length === 0) {
return;
}
console.log(`[svgLogger] Operation: ${operationName}`);
const logEntryCounts = {};
for (const logEntry of logEntries) {
logEntryCounts[logEntry] = (logEntryCounts[logEntry] || 0) + 1;
}
const logEntriesSortedByCount = Object.entries(logEntryCounts).sort(
(a, b) => b[1] - a[1]
);
for (const [logEntry, count] of logEntriesSortedByCount) {
console.log(`[svgLogger] - ${logEntry}: ${count}`);
}
},
};
},
buildSvgLogger() {
const svgLogger = {
entries: [],
log(entry) {
this.entries.push(entry);
},
};
lastSvgLogger = svgLogger;
return svgLogger;
},
};
module.exports = { typeDefs, resolvers, svgLoggingPlugin };
module.exports = { typeDefs, resolvers };