Sort similar links by status

This commit is contained in:
Aleksandr Statciuk 2022-02-24 22:18:10 +03:00
parent 63ce588aca
commit e8923a15de
3 changed files with 16 additions and 2 deletions

View file

@ -6,7 +6,12 @@ const _ = require('lodash')
async function main() {
await db.streams.load()
let streams = await db.streams.find({})
streams = orderBy(streams, ['title', 'height', 'url'], ['asc', 'desc', 'asc'])
const levels = { online: 1, blocked: 2, timeout: 3, error: 4, default: 5 }
streams = orderBy(
streams,
['title', s => levels[s.status] || levels['default'], 'height', 'url'],
['asc', 'asc', 'desc', 'asc']
)
const files = _.groupBy(streams, 'filepath')
for (const filepath in files) {