diff --git a/server/internal/cache/cacheHandler.ts b/server/internal/cache/cacheHandler.ts index c42c072..63fa291 100644 --- a/server/internal/cache/cacheHandler.ts +++ b/server/internal/cache/cacheHandler.ts @@ -1,17 +1,5 @@ import { prefixStorage, type StorageValue, type Storage } from "unstorage"; -export interface CacheProviderOptions { - /** - * Max number of items in the cache - */ - max?: number; - - /** - * Time to live (in ms) - */ - ttl?: number; -} - /** * Creates and manages the lifecycles of various caches */ diff --git a/server/internal/metadata/pcgamingwiki.ts b/server/internal/metadata/pcgamingwiki.ts index 6e7850f..16f28ba 100644 --- a/server/internal/metadata/pcgamingwiki.ts +++ b/server/internal/metadata/pcgamingwiki.ts @@ -113,7 +113,7 @@ export class PCGamingWikiProvider implements MetadataProvider { year: game.Released !== null && game.Released.length > 0 ? // sometimes will provide multiple dates - DateTime.fromISO(game.Released.split(";")[0]).year + this.parseTS(game.Released).year : 0, }; return metadata; @@ -141,6 +141,22 @@ export class PCGamingWikiProvider implements MetadataProvider { return results; } + /** + * Parses the specific format that the wiki returns when specifying a iso timestamp + * @param isoStr + * @returns + */ + private parseTS(isoStr: string): DateTime { + return DateTime.fromISO(isoStr.split(";")[0]); + } + + private parseWebsitesGetFirst(websiteStr?: string | null): string { + if (websiteStr === undefined || websiteStr === null) return ""; + + // string comes in format: "[https://www.gamesci.com.cn www.gamesci.com.cn]" + return websiteStr.replaceAll(/\[|]/g, "").split(" ")[0] ?? ""; + } + async fetchGame({ id, name, @@ -234,14 +250,14 @@ export class PCGamingWikiProvider implements MetadataProvider { const company = res.data.cargoquery[i].title; const fixedCompanyName = - company.PageName.split("Company:").at(1) ?? company.PageName; + this.parseCompanyStr(company.PageName)[0] ?? company.PageName; const metadata: CompanyMetadata = { id: company.PageID, name: fixedCompanyName, shortDescription: "", description: "", - website: company?.Website ?? "", + website: this.parseWebsitesGetFirst(company?.Website), logo: icon, banner: icon, diff --git a/server/tasks/cleanup/objects.ts b/server/tasks/cleanup/objects.ts index 5c3e719..62955dc 100644 --- a/server/tasks/cleanup/objects.ts +++ b/server/tasks/cleanup/objects.ts @@ -22,7 +22,10 @@ export default defineTask({ ); console.log(objects); const results = await findUnreferencedStrings(objects, buildRefMap()); - console.log("[Task cleanup:objects]: Unreferenced objects: ", results); + console.log( + `[Task cleanup:objects]: found ${results.length} Unreferenced objects`, + ); + console.log(results); console.log("[Task cleanup:objects]: Done"); return { result: true }; @@ -60,6 +63,8 @@ async function isReferencedInModelFields( id: string, fieldRefMap: FieldReferenceMap, ): Promise { + // TODO: optimize the built queries + // rn it runs a query for every id over each db table for (const { model, fields, arrayFields } of Object.values(fieldRefMap)) { const singleFieldOrConditions = fields ? fields.map((field) => ({