Simplify struct SessionInfo and adjoining code
This commit is contained in:
committed by
=Michael Hohn
parent
9d1a891c72
commit
0cffb3c849
@@ -216,12 +216,18 @@ func (c *CommanderSingle) MRVAStatusCommon(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
jobs, err := c.v.State.GetJobList(int(sessionId))
|
||||
if err != nil || len(jobs) == 0 {
|
||||
if err != nil {
|
||||
msg := "No jobs found for given session id"
|
||||
slog.Error(msg, "id", variantAnalysisID)
|
||||
http.Error(w, msg, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if len(jobs) == 0 {
|
||||
// TODO Empty joblist found; short-circuit the rest of this func
|
||||
// c.submitStatusResponse(w, job.Spec, jobInfo)
|
||||
slog.Error("TODO empty joblist found", "id", variantAnalysisID)
|
||||
return
|
||||
}
|
||||
|
||||
// The status reports one status for all jobs belonging to an id.
|
||||
// So we simply report the status of a job as the status of all.
|
||||
@@ -452,28 +458,21 @@ func (c *CommanderSingle) MRVARequestCommon(w http.ResponseWriter, r *http.Reque
|
||||
|
||||
notFoundRepos, analysisRepos := c.v.CodeQLDBStore.FindAvailableDBs(repoNWOs)
|
||||
|
||||
if len(*analysisRepos) == 0 {
|
||||
slog.Warn("No repositories found for analysis")
|
||||
}
|
||||
|
||||
// XX: session_is is separate from the query pack ref. Value may be equal
|
||||
c.startAnalyses(analysisRepos, queryPackLocation, sessionId, queryLanguage)
|
||||
|
||||
sessionInfo := SessionInfo{
|
||||
ID: sessionId,
|
||||
Owner: "unused",
|
||||
ControllerRepo: "unused",
|
||||
// TODO verify: these fields are never used
|
||||
// Owner: "unused",
|
||||
// ControllerRepo: "unused",
|
||||
// Repositories: repoNWOs,
|
||||
// OverLimitRepos: nil, /* FIXME */
|
||||
// AnalysisRepos: analysisRepos,
|
||||
|
||||
QueryPack: strconv.Itoa(sessionId), // TODO
|
||||
Language: queryLanguage,
|
||||
Repositories: repoNWOs,
|
||||
ID: sessionId,
|
||||
QueryPack: strconv.Itoa(sessionId), // TODO
|
||||
Language: queryLanguage,
|
||||
|
||||
AccessMismatchRepos: nil, /* FIXME */
|
||||
NotFoundRepos: notFoundRepos,
|
||||
NoCodeqlDBRepos: nil, /* FIXME */
|
||||
OverLimitRepos: nil, /* FIXME */
|
||||
|
||||
AnalysisRepos: analysisRepos,
|
||||
}
|
||||
|
||||
slog.Debug("Forming and sending response for submitted analysis job", "id", sessionInfo.ID)
|
||||
@@ -483,9 +482,15 @@ func (c *CommanderSingle) MRVARequestCommon(w http.ResponseWriter, r *http.Reque
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(submitResponseJson)
|
||||
|
||||
// Start analysis only if repositories were found
|
||||
if len(*analysisRepos) == 0 {
|
||||
slog.Warn("No repositories found for analysis")
|
||||
return
|
||||
}
|
||||
c.startAnalyses(analysisRepos, queryPackLocation, sessionId, queryLanguage)
|
||||
}
|
||||
|
||||
func (c *CommanderSingle) MRVARequestID(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -9,17 +9,20 @@ import (
|
||||
)
|
||||
|
||||
type SessionInfo struct {
|
||||
ID int
|
||||
Owner string
|
||||
ControllerRepo string
|
||||
QueryPack string
|
||||
Language string
|
||||
Repositories []common.NameWithOwner
|
||||
// TODO verify: these fields are never used
|
||||
// Owner string
|
||||
// ControllerRepo string
|
||||
// Repositories []common.NameWithOwner
|
||||
// OverLimitRepos []common.NameWithOwner
|
||||
// AnalysisRepos *map[common.NameWithOwner]qldbstore.CodeQLDatabaseLocation
|
||||
|
||||
ID int
|
||||
QueryPack string
|
||||
Language string
|
||||
|
||||
AccessMismatchRepos []common.NameWithOwner
|
||||
NotFoundRepos []common.NameWithOwner
|
||||
NoCodeqlDBRepos []common.NameWithOwner
|
||||
OverLimitRepos []common.NameWithOwner
|
||||
AnalysisRepos *map[common.NameWithOwner]qldbstore.CodeQLDatabaseLocation
|
||||
}
|
||||
|
||||
type CommanderSingle struct {
|
||||
|
||||
Reference in New Issue
Block a user