Skip to content

Commit

Permalink
/action/{id}/runs: fix zero value Run displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
dermetfan committed Jun 21, 2022
1 parent 4878fc1 commit 6b29ee2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/application/component/web/main.go
Expand Up @@ -399,7 +399,7 @@ func (self *Web) ActionIdRunGet(w http.ResponseWriter, req *http.Request) {
errChan <- err
return
} else {
entries[i].Run = &run
entries[i].Run = run
}
}(i, invocation.Id)
}
Expand Down Expand Up @@ -541,7 +541,7 @@ func (self *Web) InvocationIdGet(w http.ResponseWriter, req *http.Request) {
return
}
} else {
run = &run_
run = run_
}

var inputs map[string]domain.Fact
Expand Down Expand Up @@ -739,7 +739,7 @@ func (self *Web) RunGet(w http.ResponseWriter, req *http.Request) {
if run, err := self.RunService.GetByInvocationId(id); err != nil && !pgxscan.NotFound(err) {
errChan <- err
} else if err == nil {
entries[i].Run = &run
entries[i].Run = run
}
}(i, invocation.Id)
}
Expand Down Expand Up @@ -867,7 +867,7 @@ func (self *Web) ApiRunByInputGet(w http.ResponseWriter, req *http.Request) {
self.ServerError(w, err)
return
} else {
runs[i] = &run
runs[i] = run
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/application/service/run.go
Expand Up @@ -30,7 +30,7 @@ type RunService interface {

GetByNomadJobId(uuid.UUID) (domain.Run, error)
GetByNomadJobIdWithLock(uuid.UUID, string) (domain.Run, error)
GetByInvocationId(uuid.UUID) (domain.Run, error)
GetByInvocationId(uuid.UUID) (*domain.Run, error)
GetByActionId(uuid.UUID, *repository.Page) ([]*domain.Run, error)
GetLatestByActionId(uuid.UUID) (domain.Run, error)
GetAll(*repository.Page) ([]*domain.Run, error)
Expand Down Expand Up @@ -98,7 +98,7 @@ func (self runService) GetByNomadJobIdWithLock(id uuid.UUID, lock string) (run d
return
}

func (self runService) GetByInvocationId(invocationId uuid.UUID) (run domain.Run, err error) {
func (self runService) GetByInvocationId(invocationId uuid.UUID) (run *domain.Run, err error) {
self.logger.Trace().Str("invocation-id", invocationId.String()).Msg("Getting Runs by input Fact IDs")
run, err = self.runRepository.GetByInvocationId(invocationId)
err = errors.WithMessagef(err, "Could not select Runs by Invocation ID %q", invocationId)
Expand Down
2 changes: 1 addition & 1 deletion src/domain/repository/run.go
Expand Up @@ -12,7 +12,7 @@ type RunRepository interface {

GetByNomadJobId(uuid.UUID) (domain.Run, error)
GetByNomadJobIdWithLock(uuid.UUID, string) (domain.Run, error)
GetByInvocationId(uuid.UUID) (domain.Run, error)
GetByInvocationId(uuid.UUID) (*domain.Run, error)
GetByActionId(uuid.UUID, *Page) ([]*domain.Run, error)
GetLatestByActionId(uuid.UUID) (domain.Run, error)
GetAll(*Page) ([]*domain.Run, error)
Expand Down
6 changes: 3 additions & 3 deletions src/infrastructure/persistence/run.go
Expand Up @@ -35,10 +35,10 @@ func (a runRepository) GetByNomadJobIdWithLock(id uuid.UUID, lock string) (run d
)
}

func (a runRepository) GetByInvocationId(invocationId uuid.UUID) (run domain.Run, err error) {
func (a runRepository) GetByInvocationId(invocationId uuid.UUID) (run *domain.Run, err error) {
return run, pgxscan.Get(
context.Background(), a.DB, &run,
`SELECT * FROM run WHERE invocation_id = $1 `,
context.Background(), a.DB, run,
`SELECT * FROM run WHERE invocation_id = $1`,
invocationId,
)
}
Expand Down

0 comments on commit 6b29ee2

Please sign in to comment.