Skip to content

Commit

Permalink
Add profile information when inserting a new execution
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Nov 14, 2024
1 parent a22bbb1 commit 7d3c358
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions go/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,7 @@ func (e *Exec) Prepare() error {
}

// insert new exec in SQL
if _, err = e.clientDB.Write(
"INSERT INTO execution(uuid, status, source, git_ref, workload, pull_nb, go_version) VALUES(?, ?, ?, ?, ?, ?, ?)",
e.UUID.String(),
StatusCreated,
e.Source,
e.GitRef,
e.Workload,
e.PullNB,
e.GolangVersion,
); err != nil {
if err = e.insert(); err != nil {
return err
}
e.createdInDB = true
Expand Down Expand Up @@ -435,6 +426,22 @@ func (e *Exec) handleStepEnd(err error) {
}
}

func (e *Exec) insert() error {
_, err := e.clientDB.Write("INSERT INTO execution(uuid, status, source, git_ref, workload, pull_nb, go_version) VALUES(?, ?, ?, ?, ?, ?, ?)",
e.UUID.String(),
StatusCreated,
e.Source,
e.GitRef,
e.Workload,
e.PullNB,
e.GolangVersion,
)
if e.ProfileInformation != nil {
_, err = e.clientDB.Write("UPDATE execution SET profile_binary = ?, profile_mode = ? WHERE uuid = ?", e.ProfileInformation.Binary, e.ProfileInformation.Mode, e.UUID.String())
}
return err
}

func GetRecentExecutions(client storage.SQLClient) ([]*Exec, error) {
var res []*Exec
query := "SELECT uuid, status, git_ref, started_at, finished_at, source, workload, pull_nb, go_version FROM execution ORDER BY started_at DESC LIMIT 1000"
Expand Down

0 comments on commit 7d3c358

Please sign in to comment.