sepia-search-motore-di-rice.../server/lib/indexers/channel-indexer.ts

29 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-06-24 15:18:54 +02:00
import { logger } from '../../helpers/logger'
import { CONFIG, SORTABLE_COLUMNS } from '../../initializers/constants'
2021-06-24 15:18:54 +02:00
import { DBChannel, IndexableChannel } from '../../types/channel.model'
import { formatChannelForDB } from '../meilisearch/meilisearch-channels'
2021-06-24 15:18:54 +02:00
import { getChannel } from '../requests/peertube-instance'
import { AbstractIndexer } from './shared'
export class ChannelIndexer extends AbstractIndexer <IndexableChannel, DBChannel> {
protected readonly primaryKey = 'primaryKey'
protected readonly filterableAttributes = [ 'url', 'host', 'videosCount', 'ownerAccount.handle', 'handle' ]
protected readonly sortableAttributes = SORTABLE_COLUMNS.CHANNELS_SEARCH
// Keep the order, most important first
protected readonly searchableAttributes = [ 'name', 'displayName', 'ownerAccount.displayName', 'description' ]
2021-06-24 15:18:54 +02:00
constructor () {
super(CONFIG.MEILISEARCH.INDEXES.CHANNELS, formatChannelForDB)
2021-06-24 15:18:54 +02:00
}
async indexSpecificElement (host: string, name: string) {
2024-01-04 14:20:20 +01:00
await this.waitForBulkIndexation()
2021-06-24 15:18:54 +02:00
const channel = await getChannel(host, name)
logger.info('Indexing specific channel %s@%s.', name, host)
2024-01-04 14:20:20 +01:00
this.addElementsToBulkIndex([ channel ])
2021-07-28 13:25:39 +02:00
}
2021-06-24 15:18:54 +02:00
}