Compare commits
2 Commits
944afc977d
...
b240253996
Author | SHA1 | Date |
---|---|---|
Chocobozzz | b240253996 | |
Chocobozzz | f2cb0fc97f |
|
@ -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)
|
||||
|
|
|
@ -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),
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue