From 0b1194eefdb9216a31a6d56f3a59e849a4ef1917 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Mon, 3 Oct 2022 18:52:33 -0700 Subject: [PATCH] More search facets --- packages/skin-database/cli.ts | 11 ++++++++++ packages/skin-database/data/FileInfoModel.ts | 1 - packages/skin-database/data/SkinModel.ts | 13 ++++++------ packages/skin-database/data/skins.ts | 22 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/packages/skin-database/cli.ts b/packages/skin-database/cli.ts index 8cf45959..f20636d5 100755 --- a/packages/skin-database/cli.ts +++ b/packages/skin-database/cli.ts @@ -329,13 +329,24 @@ program "Refresh the data we keep about files within skin archives" ) .option("--refresh-content-hash", "Refresh content hash") + .option("--update-search-index", "Refresh content hash") .action( async ({ uploadIaScreenshot, uploadMissingScreenshots, refreshArchiveFiles, refreshContentHash, + updateSearchIndex, }) => { + if (updateSearchIndex) { + const ctx = new UserContext(); + const rows = await knex.raw( + `SELECT md5, update_timestamp from skins LEFT JOIN algolia_field_updates ON skins.md5 = algolia_field_updates.skin_md5 GROUP BY md5 ORDER BY update_timestamp LIMIT ?;`, + [100] + ); + const md5s = rows.map((row) => row.md5); + console.log(await Skins.updateSearchIndexs(ctx, md5s)); + } if (refreshContentHash) { const ctx = new UserContext(); const skinRows = await knex("skins").select(); diff --git a/packages/skin-database/data/FileInfoModel.ts b/packages/skin-database/data/FileInfoModel.ts index fa2a2e5f..aff25ec0 100644 --- a/packages/skin-database/data/FileInfoModel.ts +++ b/packages/skin-database/data/FileInfoModel.ts @@ -27,7 +27,6 @@ export default class FileInfoModel { } getTextContent(): string | null { - console.log("row", this.row); return this.row.text_content; } diff --git a/packages/skin-database/data/SkinModel.ts b/packages/skin-database/data/SkinModel.ts index b416edcf..16f88df5 100644 --- a/packages/skin-database/data/SkinModel.ts +++ b/packages/skin-database/data/SkinModel.ts @@ -195,7 +195,6 @@ export default class SkinModel { if (readme == null) { return null; } - console.log("readme", readme); return readme.getTextContent(); } @@ -281,15 +280,17 @@ export default class SkinModel { }); } - /** - * - * @returns - */ + async hasEqualizer(): Promise { + return this._hasSpriteSheet("EQMAIN"); + } + async hasPlaylist(): Promise { + return this._hasSpriteSheet("PLEDIT"); + } async hasMediaLibrary(): Promise { return this.hasGeneral(); } - async hasMiniBrowser(): Promise { + async hasBrowser(): Promise { return this._hasSpriteSheet("MB"); } diff --git a/packages/skin-database/data/skins.ts b/packages/skin-database/data/skins.ts index b886ceb8..12f45f53 100644 --- a/packages/skin-database/data/skins.ts +++ b/packages/skin-database/data/skins.ts @@ -161,6 +161,17 @@ type SearchIndex = { nsfw: boolean; fileName: string; twitterLikes: number; + equalizer: boolean; + playlist: boolean; + browser: boolean; + general: boolean; + video: boolean; + cur: boolean; + ani: boolean; + transparency: boolean; + mikro: boolean; + vidamp: boolean; + avs: boolean; }; async function getSearchIndexes( @@ -187,6 +198,17 @@ async function getSearchIndexes( readmeText: readmeText ? truncate(readmeText, 4800) : null, fileName: await skin.getFileName(), twitterLikes: likes, + equalizer: await skin.hasEqualizer(), + playlist: await skin.hasPlaylist(), + browser: await skin.hasBrowser(), + general: await skin.hasGeneral(), + video: await skin.hasVideo(), + cur: await skin.hasCur(), + ani: await skin.hasAni(), + transparency: await skin.hasTransparency(), + mikro: await skin.hasMikro(), + vidamp: await skin.hasVidamp(), + avs: await skin.hasAVS(), }; }) );