Add date of when a process exited in report history

This commit is contained in:
Ingo Oppermann
2023-03-14 15:10:06 +01:00
parent b76e6a9b2c
commit 1d298038dd
5 changed files with 17 additions and 5 deletions

View File

@@ -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(),
}

View File

@@ -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"`
}

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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,
})
}
}