mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 10:15:31 +00:00
Expose last index time in graph
This commit is contained in:
parent
51fbd7fdfa
commit
e53fadb63f
4 changed files with 34 additions and 0 deletions
|
|
@ -35,4 +35,12 @@ export default class ClassicSkinResolver
|
|||
const reviews = await this._model.getReviews();
|
||||
return reviews.map((row) => new ReviewResolver(row));
|
||||
}
|
||||
async last_algolia_index_update_date() {
|
||||
const updates = await this._model.getAlgoliaIndexUpdates(1);
|
||||
if (updates.length < 1) {
|
||||
return null;
|
||||
}
|
||||
const update = updates[0];
|
||||
return new Date(update.update_timestamp * 1000).toISOString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,6 +221,12 @@ type ClassicSkin implements Skin & Node {
|
|||
reivew page, or via the Discord bot.
|
||||
"""
|
||||
reviews: [Review]
|
||||
|
||||
"""
|
||||
The date on which this skin was last updated in the Algolia search index.
|
||||
Given in simplified extended ISO format (ISO 8601).
|
||||
"""
|
||||
last_algolia_index_update_date: String
|
||||
}
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -370,6 +370,10 @@ export default class SkinModel {
|
|||
);
|
||||
}
|
||||
|
||||
async getAlgoliaIndexUpdates(limit?: number): Promise<any[]> {
|
||||
return Skins.searchIndexUpdatesForSkin(this.getMd5(), limit);
|
||||
}
|
||||
|
||||
async withScreenshotTempFile<T>(
|
||||
cb: (file: string) => Promise<T>
|
||||
): Promise<T> {
|
||||
|
|
|
|||
|
|
@ -342,6 +342,22 @@ export async function getSkinsToShoot(limit: number): Promise<string[]> {
|
|||
return results.map((row) => row.md5);
|
||||
}
|
||||
|
||||
export async function searchIndexUpdatesForSkin(
|
||||
md5: string,
|
||||
limit?: number
|
||||
): Promise<
|
||||
Array<{ skin_md5: string; update_timestamp: number; field: string }>
|
||||
> {
|
||||
let query = knex("algolia_field_updates")
|
||||
.where({ skin_md5: md5 })
|
||||
.orderBy("update_timestamp", "desc");
|
||||
|
||||
if (limit != null) {
|
||||
query = query.limit(limit);
|
||||
}
|
||||
return query.select();
|
||||
}
|
||||
|
||||
export async function recordSearchIndexUpdates(
|
||||
md5: string,
|
||||
fields: string[]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue