Filter instance in bulk
This commit is contained in:
parent
fde7007788
commit
69e17e2777
|
@ -29,6 +29,7 @@ instances-index:
|
|||
- 'replay.jres.org'
|
||||
- 'tube.nah.re'
|
||||
- 'video.passageenseine.fr'
|
||||
- 'peertube.luga.at'
|
||||
|
||||
api:
|
||||
blacklist:
|
||||
|
|
|
@ -2,6 +2,7 @@ import { CONFIG } from '../../initializers/constants'
|
|||
import { listIndexInstancesHost, getMajorInstanceVersion } from '../requests/instances-index'
|
||||
import { client } from '../../helpers/meilisearch'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import Bluebird from 'bluebird'
|
||||
|
||||
async function buildInstanceHosts () {
|
||||
let indexHosts = await listIndexInstancesHost()
|
||||
|
@ -14,15 +15,17 @@ async function buildInstanceHosts () {
|
|||
indexHosts = indexHosts.filter(h => whitelistHosts.includes(h))
|
||||
}
|
||||
|
||||
for (const indexHost of indexHosts) {
|
||||
indexHosts = await Bluebird.filter(indexHosts, async indexHost => {
|
||||
const instanceVersion = await getMajorInstanceVersion(indexHost)
|
||||
|
||||
if (instanceVersion < 4) {
|
||||
logger.info(`Do not index ${indexHost} because the major version is too low (v${instanceVersion} < v4)`)
|
||||
|
||||
indexHosts = indexHosts.filter(h => h !== indexHost)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}, { concurrency: 10 })
|
||||
|
||||
const dbHosts = await listDBInstances()
|
||||
const removedHosts = getRemovedHosts(dbHosts, indexHosts)
|
||||
|
|
Loading…
Reference in New Issue