This commit is contained in:
2021-11-23 01:45:19 +01:00
parent 57b9b875ba
commit 2fbdea00a6
15 changed files with 357 additions and 263 deletions

View File

@@ -2,6 +2,7 @@ import { groupBy, orderBy, sum } from 'lodash'
import dj from 'dayjs'
import { DB } from './db.js'
import { SettingsValidator } from './validation.js'
export async function data({ start, end }) {
const logs = await getLogsBetweenDates({ start, end })
@@ -60,3 +61,9 @@ export function percentagesToBool(percentages) {
const blocked = percentages.map((p) => p >= 100).includes(true)
return blocked
}
export async function getSettingsWithDefaults() {
const values = await DB.settings.toArray()
const fromDB = Object.fromEntries(values.map((v) => [v.key, v.value]))
return SettingsValidator.validate(fromDB).value
}