mirror of
https://github.com/datarhei/core.git
synced 2025-10-07 00:43:39 +08:00
Add date of when a process exited in report history
This commit is contained in:
@@ -732,12 +732,14 @@ type Report struct {
|
|||||||
type ReportHistoryEntry struct {
|
type ReportHistoryEntry struct {
|
||||||
Report
|
Report
|
||||||
|
|
||||||
|
ExitedAt time.Time
|
||||||
ExitState string
|
ExitState string
|
||||||
Progress Progress
|
Progress Progress
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReportHistorySearchResult struct {
|
type ReportHistorySearchResult struct {
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
|
ExitedAt time.Time
|
||||||
ExitState string
|
ExitState string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,19 +758,20 @@ func (p *parser) SearchReportHistory(state string, from, to *time.Time) []Report
|
|||||||
}
|
}
|
||||||
|
|
||||||
if from != nil {
|
if from != nil {
|
||||||
if e.CreatedAt.Before(*from) {
|
if e.ExitedAt.Before(*from) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if to != nil {
|
if to != nil {
|
||||||
if e.CreatedAt.After(*to) {
|
if e.ExitedAt.After(*to) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = append(result, ReportHistorySearchResult{
|
result = append(result, ReportHistorySearchResult{
|
||||||
CreatedAt: e.CreatedAt,
|
CreatedAt: e.CreatedAt,
|
||||||
|
ExitedAt: e.ExitedAt,
|
||||||
ExitState: e.ExitState,
|
ExitState: e.ExitState,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -789,6 +792,7 @@ func (p *parser) storeReportHistory(state string) {
|
|||||||
|
|
||||||
h := ReportHistoryEntry{
|
h := ReportHistoryEntry{
|
||||||
Report: report,
|
Report: report,
|
||||||
|
ExitedAt: time.Now(),
|
||||||
ExitState: state,
|
ExitState: state,
|
||||||
Progress: p.Progress(),
|
Progress: p.Progress(),
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ type ProcessReportEntry struct {
|
|||||||
type ProcessReportHistoryEntry struct {
|
type ProcessReportHistoryEntry struct {
|
||||||
ProcessReportEntry
|
ProcessReportEntry
|
||||||
|
|
||||||
|
ExitedAt int64 `json:"exited_at" format:"int64"`
|
||||||
ExitState string `json:"exit_state"`
|
ExitState string `json:"exit_state"`
|
||||||
Progress Progress `json:"progress"`
|
Progress Progress `json:"progress"`
|
||||||
}
|
}
|
||||||
@@ -49,6 +50,7 @@ func (report *ProcessReport) Unmarshal(l *app.Log) {
|
|||||||
Prelude: h.Prelude,
|
Prelude: h.Prelude,
|
||||||
Log: make([][2]string, len(h.Log)),
|
Log: make([][2]string, len(h.Log)),
|
||||||
},
|
},
|
||||||
|
ExitedAt: h.ExitedAt.Unix(),
|
||||||
ExitState: h.ExitState,
|
ExitState: h.ExitState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,4 +70,5 @@ type ProcessReportSearchResult struct {
|
|||||||
Reference string `json:"reference"`
|
Reference string `json:"reference"`
|
||||||
ExitState string `json:"exit_state"`
|
ExitState string `json:"exit_state"`
|
||||||
CreatedAt int64 `json:"created_at" format:"int64"`
|
CreatedAt int64 `json:"created_at" format:"int64"`
|
||||||
|
ExitedAt int64 `json:"exited_at" format:"int64"`
|
||||||
}
|
}
|
||||||
|
@@ -338,9 +338,9 @@ func (h *RestreamHandler) GetReport(c echo.Context) error {
|
|||||||
return c.JSON(http.StatusOK, report)
|
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
|
// @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.?.?
|
// @Tags v16.?.?
|
||||||
// @ID process-3-get-report-at
|
// @ID process-3-get-report-at
|
||||||
// @Produce json
|
// @Produce json
|
||||||
@@ -367,7 +367,7 @@ func (h *RestreamHandler) GetReportAt(c echo.Context) error {
|
|||||||
report.Unmarshal(l)
|
report.Unmarshal(l)
|
||||||
|
|
||||||
for _, r := range report.History {
|
for _, r := range report.History {
|
||||||
if r.CreatedAt == at {
|
if r.ExitedAt == at {
|
||||||
return c.JSON(http.StatusOK, r)
|
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].Reference = b.Reference
|
||||||
response[i].ExitState = b.ExitState
|
response[i].ExitState = b.ExitState
|
||||||
response[i].CreatedAt = b.CreatedAt.Unix()
|
response[i].CreatedAt = b.CreatedAt.Unix()
|
||||||
|
response[i].ExitedAt = b.ExitedAt.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(http.StatusOK, response)
|
return c.JSON(http.StatusOK, response)
|
||||||
|
@@ -18,6 +18,7 @@ type LogEntry struct {
|
|||||||
type LogHistoryEntry struct {
|
type LogHistoryEntry struct {
|
||||||
LogEntry
|
LogEntry
|
||||||
|
|
||||||
|
ExitedAt time.Time
|
||||||
ExitState string
|
ExitState string
|
||||||
Progress Progress
|
Progress Progress
|
||||||
}
|
}
|
||||||
@@ -31,5 +32,6 @@ type LogHistorySearchResult struct {
|
|||||||
ProcessID string
|
ProcessID string
|
||||||
Reference string
|
Reference string
|
||||||
ExitState string
|
ExitState string
|
||||||
|
ExitedAt time.Time
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
}
|
}
|
||||||
|
@@ -1430,6 +1430,7 @@ func (r *restream) GetProcessLog(id string) (*app.Log, error) {
|
|||||||
CreatedAt: h.CreatedAt,
|
CreatedAt: h.CreatedAt,
|
||||||
Prelude: h.Prelude,
|
Prelude: h.Prelude,
|
||||||
},
|
},
|
||||||
|
ExitedAt: h.ExitedAt,
|
||||||
ExitState: h.ExitState,
|
ExitState: h.ExitState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1487,6 +1488,7 @@ func (r *restream) SearchProcessLogHistory(idpattern, refpattern, state string,
|
|||||||
Reference: task.reference,
|
Reference: task.reference,
|
||||||
ExitState: f.ExitState,
|
ExitState: f.ExitState,
|
||||||
CreatedAt: f.CreatedAt,
|
CreatedAt: f.CreatedAt,
|
||||||
|
ExitedAt: f.ExitedAt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user