mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-19 03:05:53 +08:00
Fix no previous enqueue entry's UI display
This commit is contained in:
parent
c6471e8c04
commit
96eec9ce11
@ -219,8 +219,9 @@ type SchedulerEntry struct {
|
|||||||
TaskType string `json:"task_type"`
|
TaskType string `json:"task_type"`
|
||||||
TaskPayload asynq.Payload `json:"task_payload"`
|
TaskPayload asynq.Payload `json:"task_payload"`
|
||||||
Opts []string `json:"options"`
|
Opts []string `json:"options"`
|
||||||
NextEnqueueAt time.Time `json:"next_enqueue_at"`
|
NextEnqueueAt string `json:"next_enqueue_at"`
|
||||||
PrevEnqueueAt time.Time `json:"prev_enqueue_at"`
|
// This field is omitted if there were no previous enqueue events.
|
||||||
|
PrevEnqueueAt string `json:"prev_enqueue_at,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func toSchedulerEntry(e *asynq.SchedulerEntry) *SchedulerEntry {
|
func toSchedulerEntry(e *asynq.SchedulerEntry) *SchedulerEntry {
|
||||||
@ -228,14 +229,18 @@ func toSchedulerEntry(e *asynq.SchedulerEntry) *SchedulerEntry {
|
|||||||
for _, o := range e.Opts {
|
for _, o := range e.Opts {
|
||||||
opts = append(opts, o.String())
|
opts = append(opts, o.String())
|
||||||
}
|
}
|
||||||
|
prev := ""
|
||||||
|
if !e.Prev.IsZero() {
|
||||||
|
prev = e.Prev.Format(time.RFC3339)
|
||||||
|
}
|
||||||
return &SchedulerEntry{
|
return &SchedulerEntry{
|
||||||
ID: e.ID,
|
ID: e.ID,
|
||||||
Spec: e.Spec,
|
Spec: e.Spec,
|
||||||
TaskType: e.Task.Type,
|
TaskType: e.Task.Type,
|
||||||
TaskPayload: e.Task.Payload,
|
TaskPayload: e.Task.Payload,
|
||||||
Opts: opts,
|
Opts: opts,
|
||||||
NextEnqueueAt: e.Next,
|
NextEnqueueAt: e.Next.Format(time.RFC3339),
|
||||||
PrevEnqueueAt: e.Prev,
|
PrevEnqueueAt: prev,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,9 @@ export interface SchedulerEntry {
|
|||||||
task_payload: { [key: string]: any };
|
task_payload: { [key: string]: any };
|
||||||
options: string[];
|
options: string[];
|
||||||
next_enqueue_at: string;
|
next_enqueue_at: string;
|
||||||
prev_enqueue_at: string;
|
// prev_enqueue_at will be omitted
|
||||||
|
// if there were no previous enqueue events.
|
||||||
|
prev_enqueue_at?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaginationOptions extends Record<string, number | undefined> {
|
export interface PaginationOptions extends Record<string, number | undefined> {
|
||||||
|
@ -118,36 +118,38 @@ export default function SchedulerEntriesTable(props: Props) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const cmpFunc = (e1: SchedulerEntry, q2: SchedulerEntry): number => {
|
const cmpFunc = (e1: SchedulerEntry, e2: SchedulerEntry): number => {
|
||||||
let isE1Smaller: boolean;
|
let isE1Smaller: boolean;
|
||||||
switch (sortBy) {
|
switch (sortBy) {
|
||||||
case SortBy.EntryId:
|
case SortBy.EntryId:
|
||||||
if (e1.id === q2.id) return 0;
|
if (e1.id === e2.id) return 0;
|
||||||
isE1Smaller = e1.id < q2.id;
|
isE1Smaller = e1.id < e2.id;
|
||||||
break;
|
break;
|
||||||
case SortBy.Spec:
|
case SortBy.Spec:
|
||||||
if (e1.spec === q2.spec) return 0;
|
if (e1.spec === e2.spec) return 0;
|
||||||
isE1Smaller = e1.spec < q2.spec;
|
isE1Smaller = e1.spec < e2.spec;
|
||||||
break;
|
break;
|
||||||
case SortBy.Type:
|
case SortBy.Type:
|
||||||
if (e1.task_type === q2.task_type) return 0;
|
if (e1.task_type === e2.task_type) return 0;
|
||||||
isE1Smaller = e1.task_type < q2.task_type;
|
isE1Smaller = e1.task_type < e2.task_type;
|
||||||
break;
|
break;
|
||||||
case SortBy.Payload:
|
case SortBy.Payload:
|
||||||
if (e1.task_payload === q2.task_payload) return 0;
|
if (e1.task_payload === e2.task_payload) return 0;
|
||||||
isE1Smaller = e1.task_payload < q2.task_payload;
|
isE1Smaller = e1.task_payload < e2.task_payload;
|
||||||
break;
|
break;
|
||||||
case SortBy.Options:
|
case SortBy.Options:
|
||||||
if (e1.options === q2.options) return 0;
|
if (e1.options === e2.options) return 0;
|
||||||
isE1Smaller = e1.options < q2.options;
|
isE1Smaller = e1.options < e2.options;
|
||||||
break;
|
break;
|
||||||
case SortBy.NextEnqueue:
|
case SortBy.NextEnqueue:
|
||||||
if (e1.next_enqueue_at === q2.next_enqueue_at) return 0;
|
if (e1.next_enqueue_at === e2.next_enqueue_at) return 0;
|
||||||
isE1Smaller = e1.next_enqueue_at < q2.next_enqueue_at;
|
isE1Smaller = e1.next_enqueue_at < e2.next_enqueue_at;
|
||||||
break;
|
break;
|
||||||
case SortBy.PrevEnqueue:
|
case SortBy.PrevEnqueue:
|
||||||
if (e1.prev_enqueue_at === q2.prev_enqueue_at) return 0;
|
const e1PrevEnqueueAt = e1.prev_enqueue_at || "";
|
||||||
isE1Smaller = e1.prev_enqueue_at < q2.prev_enqueue_at;
|
const e2PrevEnqueueAt = e2.prev_enqueue_at || "";
|
||||||
|
if (e1PrevEnqueueAt === e2PrevEnqueueAt) return 0;
|
||||||
|
isE1Smaller = e1PrevEnqueueAt < e2PrevEnqueueAt;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// eslint-disable-next-line no-throw-literal
|
// eslint-disable-next-line no-throw-literal
|
||||||
@ -228,7 +230,9 @@ export default function SchedulerEntriesTable(props: Props) {
|
|||||||
{durationBefore(entry.next_enqueue_at)}
|
{durationBefore(entry.next_enqueue_at)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={clsx(isLastRow && classes.noBorder)}>
|
<TableCell className={clsx(isLastRow && classes.noBorder)}>
|
||||||
{timeAgo(entry.prev_enqueue_at)}
|
{entry.prev_enqueue_at
|
||||||
|
? timeAgo(entry.prev_enqueue_at)
|
||||||
|
: "N/A"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user