Compare commits

...

2 Commits

Author SHA1 Message Date
Chocobozzz b240253996
More robust objects indexer 2024-02-09 10:14:11 +01:00
Chocobozzz f2cb0fc97f
Fix bulk indexing error 2024-02-09 10:14:04 +01:00
4 changed files with 15 additions and 2 deletions

View File

@ -112,16 +112,17 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
logger.info(`Bulk indexing ${elements.length} elements in ${this.indexName}`)
this.bulkProcessEnqueuedTask = await this.indexElements(elements)
this.bulkIndexationTimer = undefined
} catch (err) {
logger.error({ err }, 'Cannot schedule bulk indexation')
} finally {
this.bulkIndexationTimer = undefined
}
}, CONFIG.INDEXER.BULK_INDEXATION_INTERVAL_MS)
}
private async indexElements (elements: T[]) {
const documents = elements.map(e => this.formatterFn(e))
.filter(e => !!e)
const result = await client.index(this.indexName).updateDocuments(documents, { primaryKey: this.primaryKey.toString() })
logger.debug(result, 'Indexed ' + documents.length + ' documents in ' + this.indexName)

View File

@ -89,6 +89,8 @@ export function formatChannelForAPI (c: DBChannel, fromHost?: string): APIVideoC
}
export function formatChannelForDB (c: IndexableChannel): DBChannel {
if (!c.ownerAccount) return undefined
return {
primaryKey: buildDBChannelPrimaryKey(c),

View File

@ -39,6 +39,11 @@ export async function queryPlaylists (search: PlaylistsSearchQuery) {
}
export function formatPlaylistForAPI (p: DBPlaylist, fromHost?: string): APIPlaylist {
if (!p.ownerAccount) return undefined
if (!p.videoChannel) return undefined
if (!p.privacy) return undefined
if (!p.type) return undefined
return {
id: p.id,
uuid: p.uuid,

View File

@ -91,6 +91,11 @@ export async function getVideosUpdatedAt (uuids: string[]): Promise<{ updatedAt:
}
export function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo | DBVideoDetails {
if (!v.category) return undefined
if (!v.licence) return undefined
if (!v.language) return undefined
if (!v.privacy) return undefined
const video = {
id: v.id,
uuid: v.uuid,