reduce default nb of jobs on runs page

This commit is contained in:
Ruben Fiszel
2023-08-20 11:36:32 +02:00
parent befef02cd9
commit 6ef55616e5
3 changed files with 10 additions and 15 deletions
+4 -4
View File
@@ -16,7 +16,7 @@
} from 'chart.js'
import type { CompletedJob } from '$lib/gen'
import { createEventDispatcher } from 'svelte'
import { getNow } from '$lib/forLater'
import { getDbClockNow } from '$lib/forLater'
export let jobs: CompletedJob[] | undefined = []
export let maxIsNow: boolean = false
@@ -98,18 +98,18 @@
}
let minTime = addSeconds(new Date(), -300)
let maxTime = getNow()
let maxTime = getDbClockNow()
$: computeMinMaxTime(jobs)
function computeMinMaxTime(jobs: CompletedJob[] | undefined) {
if (jobs == undefined || jobs?.length == 0) {
minTime = addSeconds(new Date(), -300)
maxTime = getNow()
maxTime = getDbClockNow()
return
}
const maxJob = maxIsNow ? getNow() : new Date(jobs?.[0].started_at)
const maxJob = maxIsNow ? getDbClockNow() : new Date(jobs?.[0].started_at)
const minJob = new Date(jobs?.[jobs?.length - 1].started_at)
const diff = (maxJob.getTime() - minJob.getTime()) / 20000
+4 -4
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { getNow } from '$lib/forLater'
import { getDbClockNow } from '$lib/forLater'
import { displayDate } from '$lib/utils'
import { onDestroy, onMount } from 'svelte'
@@ -32,7 +32,7 @@
}
function isToday(someDate: Date): boolean {
const today = getNow()
const today = getDbClockNow()
return (
someDate.getDate() == today.getDate() &&
someDate.getMonth() == today.getMonth() &&
@@ -41,12 +41,12 @@
}
function daysAgo(someDate: Date): number {
const today = getNow()
const today = getDbClockNow()
return Math.floor((today.getTime() - someDate.getTime()) / 86400000)
}
function secondsAgo(date: Date) {
return Math.max(0, Math.floor((getNow().getTime() - date.getTime()) / 1000))
return Math.max(0, Math.floor((getDbClockNow().getTime() - date.getTime()) / 1000))
}
async function displayDaysAgo(dateString: string): Promise<string> {
+2 -7
View File
@@ -18,15 +18,10 @@ export async function computeDrift() {
}
export function forLater(scheduledString: string): boolean {
let drift = get(dbClockDrift)
if (drift == undefined) {
computeDrift()
drift = 0
}
return adjustDate(drift) < subtractSeconds(new Date(scheduledString), 5)
return getDbClockNow() < subtractSeconds(new Date(scheduledString), 5)
}
export function getNow() {
export function getDbClockNow() {
let drift = get(dbClockDrift)
if (drift == undefined) {
computeDrift()