diff --git a/ffmpeg/parse/parser.go b/ffmpeg/parse/parser.go index bdf664b4..dc1424cb 100644 --- a/ffmpeg/parse/parser.go +++ b/ffmpeg/parse/parser.go @@ -732,12 +732,14 @@ type Report struct { type ReportHistoryEntry struct { Report + ExitedAt time.Time ExitState string Progress Progress } type ReportHistorySearchResult struct { CreatedAt time.Time + ExitedAt time.Time ExitState string } @@ -756,19 +758,20 @@ func (p *parser) SearchReportHistory(state string, from, to *time.Time) []Report } if from != nil { - if e.CreatedAt.Before(*from) { + if e.ExitedAt.Before(*from) { return } } if to != nil { - if e.CreatedAt.After(*to) { + if e.ExitedAt.After(*to) { return } } result = append(result, ReportHistorySearchResult{ CreatedAt: e.CreatedAt, + ExitedAt: e.ExitedAt, ExitState: e.ExitState, }) }) @@ -789,6 +792,7 @@ func (p *parser) storeReportHistory(state string) { h := ReportHistoryEntry{ Report: report, + ExitedAt: time.Now(), ExitState: state, Progress: p.Progress(), } diff --git a/http/api/report.go b/http/api/report.go index a32cc250..3ac1ea3c 100644 --- a/http/api/report.go +++ b/http/api/report.go @@ -16,6 +16,7 @@ type ProcessReportEntry struct { type ProcessReportHistoryEntry struct { ProcessReportEntry + ExitedAt int64 `json:"exited_at" format:"int64"` ExitState string `json:"exit_state"` Progress Progress `json:"progress"` } @@ -49,6 +50,7 @@ func (report *ProcessReport) Unmarshal(l *app.Log) { Prelude: h.Prelude, Log: make([][2]string, len(h.Log)), }, + ExitedAt: h.ExitedAt.Unix(), ExitState: h.ExitState, } @@ -68,4 +70,5 @@ type ProcessReportSearchResult struct { Reference string `json:"reference"` ExitState string `json:"exit_state"` CreatedAt int64 `json:"created_at" format:"int64"` + ExitedAt int64 `json:"exited_at" format:"int64"` } diff --git a/http/handler/api/restream.go b/http/handler/api/restream.go index 2c4c129a..0f1fe1b3 100644 --- a/http/handler/api/restream.go +++ b/http/handler/api/restream.go @@ -338,9 +338,9 @@ func (h *RestreamHandler) GetReport(c echo.Context) error { return c.JSON(http.StatusOK, report) } -// GetReportAt return the loh history entry of a process +// GetReportAt return the log history entry of a process // @Summary Get the log history entry of a process -// @Description Get the log history entry of a process at a certain time. +// @Description Get the log history entry of a process that finished at a certain time. // @Tags v16.?.? // @ID process-3-get-report-at // @Produce json @@ -367,7 +367,7 @@ func (h *RestreamHandler) GetReportAt(c echo.Context) error { report.Unmarshal(l) for _, r := range report.History { - if r.CreatedAt == at { + if r.ExitedAt == at { return c.JSON(http.StatusOK, r) } } @@ -425,6 +425,7 @@ func (h *RestreamHandler) SearchReportHistory(c echo.Context) error { response[i].Reference = b.Reference response[i].ExitState = b.ExitState response[i].CreatedAt = b.CreatedAt.Unix() + response[i].ExitedAt = b.ExitedAt.Unix() } return c.JSON(http.StatusOK, response) diff --git a/restream/app/log.go b/restream/app/log.go index b5e756cc..a5152446 100644 --- a/restream/app/log.go +++ b/restream/app/log.go @@ -18,6 +18,7 @@ type LogEntry struct { type LogHistoryEntry struct { LogEntry + ExitedAt time.Time ExitState string Progress Progress } @@ -31,5 +32,6 @@ type LogHistorySearchResult struct { ProcessID string Reference string ExitState string + ExitedAt time.Time CreatedAt time.Time } diff --git a/restream/restream.go b/restream/restream.go index 42ae782f..0089d529 100644 --- a/restream/restream.go +++ b/restream/restream.go @@ -1430,6 +1430,7 @@ func (r *restream) GetProcessLog(id string) (*app.Log, error) { CreatedAt: h.CreatedAt, Prelude: h.Prelude, }, + ExitedAt: h.ExitedAt, ExitState: h.ExitState, } @@ -1487,6 +1488,7 @@ func (r *restream) SearchProcessLogHistory(idpattern, refpattern, state string, Reference: task.reference, ExitState: f.ExitState, CreatedAt: f.CreatedAt, + ExitedAt: f.ExitedAt, }) } }