Skip to content

Commit

Permalink
Merge pull request #126 from yohamta/fix/status-correction
Browse files Browse the repository at this point in the history
fix: status correction issue
  • Loading branch information
yottahmd authored May 27, 2022
2 parents fff64c3 + 9990504 commit ec7d5c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ func (s *controller) GetLastStatus() (*models.Status, error) {
}
return defaultStatus(s.cfg), readErr
}
// it is wrong status if the status is running
status.CorrectRunningStatus()
return status, nil
}
return nil, err
Expand All @@ -147,6 +149,14 @@ func (s *controller) GetLastStatus() (*models.Status, error) {
func (s *controller) GetStatusByRequestId(requestId string) (*models.Status, error) {
db := database.New(database.DefaultConfig())
ret, err := db.FindByRequestId(s.cfg.ConfigPath, requestId)
if err != nil {
return nil, err
}
status, _ := s.GetStatus()
if status != nil && status.RequestId != requestId {
// if the request id is not matched then correct the status
ret.Status.CorrectRunningStatus()
}
return ret.Status, err
}

Expand Down
1 change: 0 additions & 1 deletion internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func ParseFile(file string) (*models.Status, error) {
var m *models.Status
m, err = models.StatusFromJson(string(line))
if err == nil {
m.CorrectRunningStatus()
ret = m
continue
}
Expand Down

0 comments on commit ec7d5c6

Please sign in to comment.