fix: task priority not taking effect

This commit is contained in:
garethgeorge
2023-12-01 22:55:26 -08:00
parent f3dc7ffd07
commit af7462cefb
3 changed files with 9 additions and 8 deletions

View File

@@ -20,10 +20,10 @@ var ErrRepoInitializationFailed = errors.New("repo initialization failed")
var ErrPlanNotFound = errors.New("plan not found")
const (
TaskPriorityDefault = iota
TaskPriorityInteractive // higher priority than default scheduled operations e.g. the user clicked to run an operation.
taskPriorityForget
TaskPriorityDefault = iota
TaskPriorityInteractive // higher priority than default scheduled operations e.g. the user clicked to run an operation
taskPriorityIndexSnapshots // higher priority than interactive operations e.g. a system operation like a forget or index (typically scheduled by another task that wants work done immediately after it's completion).
taskPriorityForget
)
// Orchestrator is responsible for managing repos and backups.
@@ -163,8 +163,9 @@ func (o *Orchestrator) ScheduleTask(t Task, priority int) {
}
zap.L().Info("scheduling task", zap.String("task", t.Name()), zap.String("runAt", nextRun.Format(time.RFC3339)))
o.taskQueue.Push(scheduledTask{
task: t,
runAt: *nextRun,
task: t,
runAt: *nextRun,
priority: priority,
})
}

View File

@@ -147,7 +147,7 @@ export const OperationRow = ({
parseInt(operation.unixTimeStartMs!)
)}`;
} else if (operation.status === OperationStatus.STATUS_INPROGRESS) {
desc += " and is still running.";
desc += " is still running.";
}
return (

View File

@@ -48,7 +48,7 @@ export const formatDate = (time: number | string | Date) => {
};
export const formatDuration = (ms: number) => {
const seconds = Math.floor(ms / 100) / 10;
const seconds = Math.ceil(ms / 100);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
if (hours === 0 && minutes === 0) {
@@ -56,7 +56,7 @@ export const formatDuration = (ms: number) => {
} else if (hours === 0) {
return `${minutes}m${seconds % 60}s`;
}
return `${hours}h${minutes % 60}m${seconds % 60}s`;
return `${hours}h${minutes % 60}m${Math.floor(seconds)}s`;
};
export const normalizeSnapshotId = (id: string) => {