Update update.js

This commit is contained in:
Aleksandr Statciuk 2022-10-28 01:23:41 +03:00
parent 8471163f66
commit 81f1157027

View file

@ -158,20 +158,19 @@ function getChannelPrograms(programs) {
} }
function calcPriority(programs) { function calcPriority(programs) {
let priority = 0 return programs.reduce((total, program) => {
for (let program of programs) { let values = Object.values(program)
for (let prop in program) {
let value = program[prop]
for (let value of values) {
if (Array.isArray(value) && value.length) { if (Array.isArray(value) && value.length) {
priority++ total++
} else if (typeof value === 'string' && value) { } else if (typeof value === 'string' && value) {
priority++ total++
} else if (value && typeof value === 'object' && Object.values(value).map(Boolean).length) { } else if (value && typeof value === 'object' && Object.values(value).map(Boolean).length) {
priority++ total++
} }
} }
}
return priority return total
}, 0)
} }