don't get it twice

This commit is contained in:
cupcakearmy 2020-09-20 18:24:22 +02:00
parent 08984480b1
commit b404bd5d85
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9
2 changed files with 11 additions and 16 deletions

View File

@ -8,8 +8,8 @@
function set(interval, amount = 1) { function set(interval, amount = 1) {
return () => { return () => {
start = dj().subtract(amount, interval).toDate() start = dj().subtract(amount, interval).startOf('day').toDate()
end = new Date() end = dj().endOf('day').toDate()
} }
} }

View File

@ -1,8 +1,6 @@
<script> <script>
import { onMount } from 'svelte' import { onMount } from 'svelte'
import dayjs from 'dayjs'
import DateInput from '../components/DateInput.svelte'
import Chart from '../components/Chart.svelte' import Chart from '../components/Chart.svelte'
import RangeChooser from '../components/RangeChooser.svelte' import RangeChooser from '../components/RangeChooser.svelte'
@ -12,8 +10,8 @@
let full = 50 let full = 50
let loading = true let loading = true
let init = false
let counted = [] let counted = []
let timeout
let start let start
let end let end
@ -23,7 +21,7 @@
loading = true loading = true
const logs = await data({ const logs = await data({
start, start,
end: dayjs(end).endOf('day'), end,
}) })
counted = countInGroup(logs) counted = countInGroup(logs)
} finally { } finally {
@ -31,18 +29,15 @@
} }
} }
$: if (init) {
start, end
calculate()
}
$: topData = counted.slice(0, top).map(({ total, host, human }) => ({ value: total, name: host, human })) $: topData = counted.slice(0, top).map(({ total, host, human }) => ({ value: total, name: host, human }))
onMount(() => { $: {
setTimeout(() => { start, end
init = true clearTimeout(timeout)
}, 25) timeout = setTimeout(calculate, 5)
}) }
onMount(calculate)
</script> </script>
<style> <style>