mirror of
https://github.com/cupcakearmy/ora.git
synced 2024-12-21 23:56:31 +00:00
don't get it twice
This commit is contained in:
parent
08984480b1
commit
b404bd5d85
@ -8,8 +8,8 @@
|
||||
|
||||
function set(interval, amount = 1) {
|
||||
return () => {
|
||||
start = dj().subtract(amount, interval).toDate()
|
||||
end = new Date()
|
||||
start = dj().subtract(amount, interval).startOf('day').toDate()
|
||||
end = dj().endOf('day').toDate()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
import DateInput from '../components/DateInput.svelte'
|
||||
import Chart from '../components/Chart.svelte'
|
||||
import RangeChooser from '../components/RangeChooser.svelte'
|
||||
|
||||
@ -12,8 +10,8 @@
|
||||
let full = 50
|
||||
|
||||
let loading = true
|
||||
let init = false
|
||||
let counted = []
|
||||
let timeout
|
||||
|
||||
let start
|
||||
let end
|
||||
@ -23,7 +21,7 @@
|
||||
loading = true
|
||||
const logs = await data({
|
||||
start,
|
||||
end: dayjs(end).endOf('day'),
|
||||
end,
|
||||
})
|
||||
counted = countInGroup(logs)
|
||||
} finally {
|
||||
@ -31,18 +29,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: if (init) {
|
||||
start, end
|
||||
calculate()
|
||||
}
|
||||
|
||||
$: topData = counted.slice(0, top).map(({ total, host, human }) => ({ value: total, name: host, human }))
|
||||
|
||||
onMount(() => {
|
||||
setTimeout(() => {
|
||||
init = true
|
||||
}, 25)
|
||||
})
|
||||
$: {
|
||||
start, end
|
||||
clearTimeout(timeout)
|
||||
timeout = setTimeout(calculate, 5)
|
||||
}
|
||||
|
||||
onMount(calculate)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
Loading…
Reference in New Issue
Block a user