More search facets

This commit is contained in:
Jordan Eldredge 2022-10-03 18:52:33 -07:00
parent b224b627e3
commit 0b1194eefd
4 changed files with 40 additions and 7 deletions

View File

@ -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();

View File

@ -27,7 +27,6 @@ export default class FileInfoModel {
}
getTextContent(): string | null {
console.log("row", this.row);
return this.row.text_content;
}

View File

@ -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<boolean> {
return this._hasSpriteSheet("EQMAIN");
}
async hasPlaylist(): Promise<boolean> {
return this._hasSpriteSheet("PLEDIT");
}
async hasMediaLibrary(): Promise<boolean> {
return this.hasGeneral();
}
async hasMiniBrowser(): Promise<boolean> {
async hasBrowser(): Promise<boolean> {
return this._hasSpriteSheet("MB");
}

View File

@ -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(),
};
})
);