Skip to content

Commit

Permalink
fix: task priority not taking effect
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Dec 2, 2023
1 parent f3dc7ff commit af7462c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions internal/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
})
}

Expand Down
2 changes: 1 addition & 1 deletion webui/src/components/OperationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions webui/src/lib/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ 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) {
return `${seconds % 60}s`;
} 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) => {
Expand Down

0 comments on commit af7462c

Please sign in to comment.