mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
fix: pcgamingwiki not parsing company websites
This commit is contained in:
12
server/internal/cache/cacheHandler.ts
vendored
12
server/internal/cache/cacheHandler.ts
vendored
@ -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
|
||||
*/
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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<boolean> {
|
||||
// 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) => ({
|
||||
|
||||
Reference in New Issue
Block a user