diff --git a/backend/controller/console/console.go b/backend/controller/console/console.go index de6df6e5e3..e21bfcaa07 100644 --- a/backend/controller/console/console.go +++ b/backend/controller/console/console.go @@ -496,7 +496,7 @@ func eventDALToProto(event timeline.Event) *pbconsole.Event { case *timeline.CronScheduledEvent: return &pbconsole.Event{ - TimeStamp: timestamppb.New(event.StartTime), + TimeStamp: timestamppb.New(event.Time), Id: event.ID, Entry: &pbconsole.Event_CronScheduled{ CronScheduled: &pbconsole.CronScheduledEvent{ @@ -505,7 +505,8 @@ func eventDALToProto(event timeline.Event) *pbconsole.Event { Module: event.Verb.Module, Name: event.Verb.Name, }, - TimeStamp: timestamppb.New(event.StartTime), + TimeStamp: timestamppb.New(event.Time), + Duration: durationpb.New(event.Duration), ScheduledAt: timestamppb.New(event.ScheduledAt), Schedule: event.Schedule, Error: event.Error.Ptr(), diff --git a/backend/controller/cronjobs/cronjobs.go b/backend/controller/cronjobs/cronjobs.go index 1671e85e32..e9349aacaf 100644 --- a/backend/controller/cronjobs/cronjobs.go +++ b/backend/controller/cronjobs/cronjobs.go @@ -125,7 +125,7 @@ func (s *Service) scheduleCronJobs(ctx context.Context) (err error) { s.timelineService.EnqueueEvent(ctx, &timeline.CronScheduled{ DeploymentKey: job.DeploymentKey, Verb: job.Verb, - StartTime: now, + Time: now, ScheduledAt: job.NextExecution, Schedule: job.Schedule, Error: optional.Some(err.Error()), @@ -159,7 +159,7 @@ func (s *Service) OnJobCompletion(ctx context.Context, key model.CronJobKey, fai s.timelineService.EnqueueEvent(ctx, &timeline.CronScheduled{ DeploymentKey: job.DeploymentKey, Verb: job.Verb, - StartTime: now, + Time: now, ScheduledAt: job.NextExecution, Schedule: job.Schedule, Error: optional.Some(err.Error()), @@ -231,7 +231,7 @@ func (s *Service) scheduleCronJob(ctx context.Context, tx *dal.DAL, job model.Cr s.timelineService.EnqueueEvent(ctx, &timeline.CronScheduled{ DeploymentKey: job.DeploymentKey, Verb: job.Verb, - StartTime: startTime, + Time: startTime, ScheduledAt: nextAttemptForJob, Schedule: job.Schedule, }) diff --git a/backend/controller/timeline/events_cron.go b/backend/controller/timeline/events_cron.go index d619cfaf56..0959f32334 100644 --- a/backend/controller/timeline/events_cron.go +++ b/backend/controller/timeline/events_cron.go @@ -28,7 +28,7 @@ type CronScheduled struct { DeploymentKey model.DeploymentKey Verb schema.Ref - StartTime time.Time + Time time.Time ScheduledAt time.Time Schedule string Error optional.Option[string] @@ -45,7 +45,7 @@ type eventCronScheduledJSON struct { func (s *Service) insertCronScheduledEvent(ctx context.Context, querier sql.Querier, event *CronScheduled) error { cronJSON := eventCronScheduledJSON{ - DurationMS: time.Since(event.StartTime).Milliseconds(), + DurationMS: time.Since(event.Time).Milliseconds(), ScheduledAt: event.ScheduledAt, Schedule: event.Schedule, Error: event.Error, @@ -64,7 +64,7 @@ func (s *Service) insertCronScheduledEvent(ctx context.Context, querier sql.Quer err = libdal.TranslatePGError(querier.InsertTimelineCronScheduledEvent(ctx, sql.InsertTimelineCronScheduledEventParams{ DeploymentKey: event.DeploymentKey, - TimeStamp: event.StartTime, + TimeStamp: event.Time, Module: event.Verb.Module, Verb: event.Verb.Name, Payload: payload, diff --git a/backend/controller/timeline/query.go b/backend/controller/timeline/query.go index f3b23f96bc..d7782fbad2 100644 --- a/backend/controller/timeline/query.go +++ b/backend/controller/timeline/query.go @@ -381,7 +381,7 @@ func (s *Service) transformRowsToTimelineEvents(deploymentKeys map[int64]model.D CronScheduled: CronScheduled{ DeploymentKey: row.DeploymentKey, Verb: schema.Ref{Module: row.CustomKey1.MustGet(), Name: row.CustomKey2.MustGet()}, - StartTime: row.TimeStamp, + Time: row.TimeStamp, ScheduledAt: jsonPayload.ScheduledAt, Schedule: jsonPayload.Schedule, Error: jsonPayload.Error, diff --git a/backend/controller/timeline/timeline_test.go b/backend/controller/timeline/timeline_test.go index cee5e4ad1f..c0b209fb78 100644 --- a/backend/controller/timeline/timeline_test.go +++ b/backend/controller/timeline/timeline_test.go @@ -143,7 +143,7 @@ func TestTimeline(t *testing.T) { CronScheduled: CronScheduled{ DeploymentKey: deploymentKey, Verb: schema.Ref{Module: "time", Name: "time"}, - StartTime: time.Now().Round(time.Millisecond), + Time: time.Now().Round(time.Millisecond), ScheduledAt: time.Now().Add(time.Minute).Round(time.Millisecond).UTC(), Schedule: "* * * * *", Error: optional.None[string](), @@ -154,7 +154,7 @@ func TestTimeline(t *testing.T) { timeline.EnqueueEvent(ctx, &CronScheduled{ DeploymentKey: cronEvent.DeploymentKey, Verb: cronEvent.Verb, - StartTime: cronEvent.StartTime, + Time: cronEvent.Time, ScheduledAt: cronEvent.ScheduledAt, Schedule: cronEvent.Schedule, Error: cronEvent.Error, diff --git a/frontend/console/src/features/timeline/TimelineCronScheduled.tsx b/frontend/console/src/features/timeline/TimelineCronScheduled.tsx index 7fea4ff928..25da1034b0 100644 --- a/frontend/console/src/features/timeline/TimelineCronScheduled.tsx +++ b/frontend/console/src/features/timeline/TimelineCronScheduled.tsx @@ -3,7 +3,7 @@ import { formatTimestampShort } from '../../utils/date.utils.ts' import { verbRefString } from '../verbs/verb.utils' export const TimelineCronScheduled = ({ cron }: { cron: CronScheduledEvent }) => { - const verbRef = cron.verbRef?.module && verbRefString(cron.verbRef) || 'unknown' + const verbRef = (cron.verbRef?.module && verbRefString(cron.verbRef)) || 'unknown' const scheduledAt = formatTimestampShort(cron.scheduledAt) const title = `Cron ${cron.schedule} verb ${verbRef} scheduled for ${scheduledAt}` return (