mirror of
https://github.com/cupcakearmy/ora.git
synced 2024-12-22 08:06:28 +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) {
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user