Function bodies 401 total
GetVersion method · go · L199-L205 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetVersion(id int64) (*Version, error) {
row, err := s.es.Get("versions", id)
if err != nil || row == nil {
return nil, err
}
return versionFromRow(row), nil
}GetVersionByLabel method · go · L207-L213 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetVersionByLabel(label string) (*Version, error) {
row, err := s.es.GetBy("versions", sqlite.Row{"label": label})
if err != nil || row == nil {
return nil, err
}
return versionFromRow(row), nil
}ListVersions method · go · L215-L221 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListVersions() ([]*Version, error) {
rows, err := s.es.List("versions", nil, "")
if err != nil {
return nil, err
}
return rowsTo(rows, versionFromRow), nil
}CreateCircuit method · go · L225-L234 (10 LOC)store/sqlstore_entities.go
func (s *SqlStore) CreateCircuit(p *Circuit) (int64, error) {
if p == nil {
return 0, fmt.Errorf("circuit is nil")
}
return s.es.Create("circuits", sqlite.Row{
"suite_id": p.SuiteID, "version_id": p.VersionID, "name": p.Name,
"source_run_id": nilIfEmpty(p.SourceRunID), "status": p.Status,
"started_at": nilIfEmpty(p.StartedAt), "ended_at": nilIfEmpty(p.EndedAt),
})
}GetCircuit method · go · L236-L242 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetCircuit(id int64) (*Circuit, error) {
row, err := s.es.Get("circuits", id)
if err != nil || row == nil {
return nil, err
}
return circuitFromRow(row), nil
}ListCircuitsBySuite method · go · L244-L250 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListCircuitsBySuite(suiteID int64) ([]*Circuit, error) {
rows, err := s.es.List("circuits", sqlite.Row{"suite_id": suiteID}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, circuitFromRow), nil
}CreateLaunch method · go · L254-L266 (13 LOC)store/sqlstore_entities.go
func (s *SqlStore) CreateLaunch(l *Launch) (int64, error) {
if l == nil {
return 0, fmt.Errorf("launch is nil")
}
return s.es.Create("launches", sqlite.Row{
"circuit_id": l.CircuitID, "source_run_id": nilIfEmpty(l.SourceRunID),
"source_run_uuid": nilIfEmpty(l.SourceRunUUID), "name": nilIfEmpty(l.Name),
"status": nilIfEmpty(l.Status), "started_at": nilIfEmpty(l.StartedAt),
"ended_at": nilIfEmpty(l.EndedAt), "env_attributes": nilIfEmpty(l.EnvAttributes),
"git_branch": nilIfEmpty(l.GitBranch), "git_commit": nilIfEmpty(l.GitCommit),
"envelope_payload": l.EnvelopePayload,
})
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
GetLaunch method · go · L268-L274 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetLaunch(id int64) (*Launch, error) {
row, err := s.es.Get("launches", id)
if err != nil || row == nil {
return nil, err
}
return launchFromRow(row), nil
}GetLaunchBySourceRunID method · go · L276-L284 (9 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetLaunchBySourceRunID(circuitID int64, sourceRunID string) (*Launch, error) {
row, err := s.es.GetBy("launches", sqlite.Row{
"circuit_id": circuitID, "source_run_id": sourceRunID,
})
if err != nil || row == nil {
return nil, err
}
return launchFromRow(row), nil
}ListLaunchesByCircuit method · go · L286-L292 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListLaunchesByCircuit(circuitID int64) ([]*Launch, error) {
rows, err := s.es.List("launches", sqlite.Row{"circuit_id": circuitID}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, launchFromRow), nil
}CreateJob method · go · L296-L307 (12 LOC)store/sqlstore_entities.go
func (s *SqlStore) CreateJob(j *Job) (int64, error) {
if j == nil {
return 0, fmt.Errorf("job is nil")
}
return s.es.Create("jobs", sqlite.Row{
"launch_id": j.LaunchID, "source_item_id": nilIfEmpty(j.SourceItemID),
"name": j.Name, "clock_type": nilIfEmpty(j.ClockType), "status": nilIfEmpty(j.Status),
"stats_total": nilIfZero(j.StatsTotal), "stats_failed": nilIfZero(j.StatsFailed),
"stats_passed": nilIfZero(j.StatsPassed), "stats_skipped": nilIfZero(j.StatsSkipped),
"started_at": nilIfEmpty(j.StartedAt), "ended_at": nilIfEmpty(j.EndedAt),
})
}GetJob method · go · L309-L315 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetJob(id int64) (*Job, error) {
row, err := s.es.Get("jobs", id)
if err != nil || row == nil {
return nil, err
}
return jobFromRow(row), nil
}ListJobsByLaunch method · go · L317-L323 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListJobsByLaunch(launchID int64) ([]*Job, error) {
rows, err := s.es.List("jobs", sqlite.Row{"launch_id": launchID}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, jobFromRow), nil
}CreateCase method · go · L327-L349 (23 LOC)store/sqlstore_entities.go
func (s *SqlStore) CreateCase(c *Case) (int64, error) {
if c == nil {
return 0, fmt.Errorf("case is nil")
}
now := nowUTC()
if c.Status == "" {
c.Status = "open"
}
if c.CreatedAt == "" {
c.CreatedAt = now
}
c.UpdatedAt = now
return s.es.Create("cases", sqlite.Row{
"job_id": c.JobID, "launch_id": c.LaunchID,
"source_item_id": nilIfEmpty(c.SourceItemID), "name": c.Name,
"external_ref": nilIfEmpty(c.ExternalRef), "status": c.Status,
"symptom_id": nilIfZero64(c.SymptomID), "rca_id": nilIfZero64(c.RCAID),
"error_message": nilIfEmpty(c.ErrorMessage), "log_snippet": nilIfEmpty(c.LogSnippet),
"log_truncated": boolToInt(c.LogTruncated),
"started_at": nilIfEmpty(c.StartedAt), "ended_at": nilIfEmpty(c.EndedAt),
"created_at": c.CreatedAt, "updated_at": c.UpdatedAt,
})
}GetCase method · go · L351-L357 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetCase(id int64) (*Case, error) {
row, err := s.es.Get("cases", id)
if err != nil || row == nil {
return nil, err
}
return caseFromRow(row), nil
}Open data scored by Repobility · https://repobility.com
ListCasesByJob method · go · L359-L365 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListCasesByJob(jobID int64) ([]*Case, error) {
rows, err := s.es.List("cases", sqlite.Row{"job_id": jobID}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, caseFromRow), nil
}ListCasesBySymptom method · go · L367-L373 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListCasesBySymptom(symptomID int64) ([]*Case, error) {
rows, err := s.es.List("cases", sqlite.Row{"symptom_id": symptomID}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, caseFromRow), nil
}UpdateCaseStatus method · go · L375-L379 (5 LOC)store/sqlstore_entities.go
func (s *SqlStore) UpdateCaseStatus(caseID int64, status string) error {
return s.es.Update("cases", caseID, sqlite.Row{
"status": status, "updated_at": nowUTC(),
})
}LinkCaseToRCA method · go · L381-L383 (3 LOC)store/sqlstore_entities.go
func (s *SqlStore) LinkCaseToRCA(caseID, rcaID int64) error {
return s.es.Update("cases", caseID, sqlite.Row{"rca_id": rcaID})
}LinkCaseToSymptom method · go · L385-L389 (5 LOC)store/sqlstore_entities.go
func (s *SqlStore) LinkCaseToSymptom(caseID, symptomID int64) error {
return s.es.Update("cases", caseID, sqlite.Row{
"symptom_id": symptomID, "updated_at": nowUTC(),
})
}CreateTriage method · go · L393-L410 (18 LOC)store/sqlstore_entities.go
func (s *SqlStore) CreateTriage(t *Triage) (int64, error) {
if t == nil {
return 0, fmt.Errorf("triage is nil")
}
if t.CreatedAt == "" {
t.CreatedAt = nowUTC()
}
return s.es.Create("triages", sqlite.Row{
"case_id": t.CaseID, "symptom_category": t.SymptomCategory,
"severity": nilIfEmpty(t.Severity), "defect_type_hypothesis": nilIfEmpty(t.DefectTypeHypothesis),
"skip_investigation": boolToInt(t.SkipInvestigation),
"clock_skew_suspected": boolToInt(t.ClockSkewSuspected),
"cascade_suspected": boolToInt(t.CascadeSuspected),
"candidate_repos": nilIfEmpty(t.CandidateRepos),
"data_quality_notes": nilIfEmpty(t.DataQualityNotes),
"created_at": t.CreatedAt,
})
}GetTriageByCase method · go · L412-L418 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetTriageByCase(caseID int64) (*Triage, error) {
row, err := s.es.GetBy("triages", sqlite.Row{"case_id": caseID})
if err != nil || row == nil {
return nil, err
}
return triageFromRow(row), nil
}CreateSymptom method · go · L422-L447 (26 LOC)store/sqlstore_entities.go
func (s *SqlStore) CreateSymptom(sym *Symptom) (int64, error) {
if sym == nil {
return 0, fmt.Errorf("symptom is nil")
}
now := nowUTC()
if sym.Status == "" {
sym.Status = "active"
}
if sym.OccurrenceCount == 0 {
sym.OccurrenceCount = 1
}
if sym.FirstSeenAt == "" {
sym.FirstSeenAt = now
}
if sym.LastSeenAt == "" {
sym.LastSeenAt = sym.FirstSeenAt
}
return s.es.Create("symptoms", sqlite.Row{
"fingerprint": sym.Fingerprint, "name": sym.Name,
"description": nilIfEmpty(sym.Description), "error_pattern": nilIfEmpty(sym.ErrorPattern),
"test_name_pattern": nilIfEmpty(sym.TestNamePattern), "component": nilIfEmpty(sym.Component),
"severity": nilIfEmpty(sym.Severity), "first_seen_at": sym.FirstSeenAt,
"last_seen_at": sym.LastSeenAt, "occurrence_count": sym.OccurrenceCount,
"status": sym.Status,
})
}Repobility — the code-quality scanner for AI-generated software · https://repobility.com
GetSymptom method · go · L449-L455 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetSymptom(id int64) (*Symptom, error) {
row, err := s.es.Get("symptoms", id)
if err != nil || row == nil {
return nil, err
}
return symptomFromRow(row), nil
}GetSymptomByFingerprint method · go · L457-L463 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetSymptomByFingerprint(fingerprint string) (*Symptom, error) {
row, err := s.es.GetBy("symptoms", sqlite.Row{"fingerprint": fingerprint})
if err != nil || row == nil {
return nil, err
}
return symptomFromRow(row), nil
}FindSymptomCandidates method · go · L465-L474 (10 LOC)store/sqlstore_entities.go
func (s *SqlStore) FindSymptomCandidates(testName string) ([]*Symptom, error) {
if testName == "" {
return nil, nil
}
rows, err := s.es.List("symptoms", sqlite.Row{"name": testName}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, symptomFromRow), nil
}UpdateSymptomSeen method · go · L476-L492 (17 LOC)store/sqlstore_entities.go
func (s *SqlStore) UpdateSymptomSeen(id int64) error {
now := nowUTC()
res, err := s.es.DB().ExecSQL(
`UPDATE symptoms SET occurrence_count = occurrence_count + 1, last_seen_at = ?,
status = CASE WHEN status = 'dormant' THEN 'active' ELSE status END
WHERE id = ?`,
now, id,
)
if err != nil {
return fmt.Errorf("update symptom seen: %w", err)
}
n, _ := res.RowsAffected()
if n == 0 {
return fmt.Errorf("symptom %d not found", id)
}
return nil
}ListSymptoms method · go · L494-L500 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListSymptoms() ([]*Symptom, error) {
rows, err := s.es.List("symptoms", nil, "")
if err != nil {
return nil, err
}
return rowsTo(rows, symptomFromRow), nil
}MarkDormantSymptoms method · go · L502-L513 (12 LOC)store/sqlstore_entities.go
func (s *SqlStore) MarkDormantSymptoms(staleDays int) (int64, error) {
res, err := s.es.DB().ExecSQL(
`UPDATE symptoms SET status = 'dormant'
WHERE status = 'active'
AND last_seen_at < datetime('now', '-' || ? || ' days')`,
staleDays,
)
if err != nil {
return 0, fmt.Errorf("mark dormant symptoms: %w", err)
}
return res.RowsAffected()
}SaveRCA method · go · L517-L541 (25 LOC)store/sqlstore_entities.go
func (s *SqlStore) SaveRCA(rca *RCA) (int64, error) {
if rca == nil {
return 0, fmt.Errorf("rca is nil")
}
if rca.Status == "" {
rca.Status = "open"
}
if rca.CreatedAt == "" {
rca.CreatedAt = nowUTC()
}
row := sqlite.Row{
"title": rca.Title, "description": rca.Description, "defect_type": rca.DefectType,
"category": nilIfEmpty(rca.Category), "component": nilIfEmpty(rca.Component),
"affected_versions": nilIfEmpty(rca.AffectedVersions),
"evidence_refs": nilIfEmpty(rca.EvidenceRefs), "convergence_score": rca.ConvergenceScore,
"jira_ticket_id": nilIfEmpty(rca.JiraTicketID), "jira_link": nilIfEmpty(rca.JiraLink),
"status": rca.Status, "resolved_at": nilIfEmpty(rca.ResolvedAt),
"verified_at": nilIfEmpty(rca.VerifiedAt), "archived_at": nilIfEmpty(rca.ArchivedAt),
}
if rca.ID != 0 {
return rca.ID, s.es.Update("rcas", rca.ID, row)
}
row["created_at"] = rca.CreatedAt
return s.es.Create("rcas", row)
}GetRCA method · go · L543-L549 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetRCA(id int64) (*RCA, error) {
row, err := s.es.Get("rcas", id)
if err != nil || row == nil {
return nil, err
}
return rcaFromRow(row), nil
}About: code-quality intelligence by Repobility · https://repobility.com
ListRCAs method · go · L551-L557 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListRCAs() ([]*RCA, error) {
rows, err := s.es.List("rcas", nil, "")
if err != nil {
return nil, err
}
return rowsTo(rows, rcaFromRow), nil
}ListRCAsByStatus method · go · L559-L565 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) ListRCAsByStatus(status string) ([]*RCA, error) {
rows, err := s.es.List("rcas", sqlite.Row{"status": status}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, rcaFromRow), nil
}UpdateRCAStatus method · go · L567-L582 (16 LOC)store/sqlstore_entities.go
func (s *SqlStore) UpdateRCAStatus(id int64, status string) error {
now := nowUTC()
set := sqlite.Row{"status": status}
switch status {
case "resolved":
set["resolved_at"] = now
case "verified":
set["verified_at"] = now
case "archived":
set["archived_at"] = now
case "open":
set["resolved_at"] = nil
set["verified_at"] = nil
}
return s.es.Update("rcas", id, set)
}LinkSymptomToRCA method · go · L586-L598 (13 LOC)store/sqlstore_entities.go
func (s *SqlStore) LinkSymptomToRCA(link *SymptomRCA) (int64, error) {
if link == nil {
return 0, fmt.Errorf("link is nil")
}
if link.LinkedAt == "" {
link.LinkedAt = nowUTC()
}
return s.es.Create("symptom_rca", sqlite.Row{
"symptom_id": link.SymptomID, "rca_id": link.RCAID,
"confidence": link.Confidence, "notes": nilIfEmpty(link.Notes),
"linked_at": link.LinkedAt,
})
}GetRCAsForSymptom method · go · L600-L606 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetRCAsForSymptom(symptomID int64) ([]*SymptomRCA, error) {
rows, err := s.es.List("symptom_rca", sqlite.Row{"symptom_id": symptomID}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, symptomRCAFromRow), nil
}GetSymptomsForRCA method · go · L608-L614 (7 LOC)store/sqlstore_entities.go
func (s *SqlStore) GetSymptomsForRCA(rcaID int64) ([]*SymptomRCA, error) {
rows, err := s.es.List("symptom_rca", sqlite.Row{"rca_id": rcaID}, "")
if err != nil {
return nil, err
}
return rowsTo(rows, symptomRCAFromRow), nil
}Open function · go · L24-L30 (7 LOC)store/sqlstore.go
func Open(path string) (*SqlStore, error) {
schema, err := LoadSchema()
if err != nil {
return nil, fmt.Errorf("load schema: %w", err)
}
return openDB(path, schema)
}OpenWithSchema function · go · L33-L39 (7 LOC)store/sqlstore.go
func OpenWithSchema(path string, schemaData []byte) (*SqlStore, error) {
schema, err := sqlite.ParseSchema(schemaData)
if err != nil {
return nil, fmt.Errorf("parse schema: %w", err)
}
return openDB(path, schema)
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
OpenMemory function · go · L42-L48 (7 LOC)store/sqlstore.go
func OpenMemory() (*SqlStore, error) {
schema, err := LoadSchema()
if err != nil {
return nil, fmt.Errorf("load schema: %w", err)
}
return openMemDB(schema)
}OpenMemoryWithSchema function · go · L51-L57 (7 LOC)store/sqlstore.go
func OpenMemoryWithSchema(schemaData []byte) (*SqlStore, error) {
schema, err := sqlite.ParseSchema(schemaData)
if err != nil {
return nil, fmt.Errorf("parse schema: %w", err)
}
return openMemDB(schema)
}openDB function · go · L59-L65 (7 LOC)store/sqlstore.go
func openDB(path string, schema *sqlite.Schema) (*SqlStore, error) {
db, err := sqlite.Open(path, schema)
if err != nil {
return nil, fmt.Errorf("open sqlite: %w", err)
}
return &SqlStore{db: db, es: sqlite.NewEntityStore(db)}, nil
}openMemDB function · go · L67-L73 (7 LOC)store/sqlstore.go
func openMemDB(schema *sqlite.Schema) (*SqlStore, error) {
db, err := sqlite.OpenMemory(schema)
if err != nil {
return nil, fmt.Errorf("open memory sqlite: %w", err)
}
return &SqlStore{db: db, es: sqlite.NewEntityStore(db)}, nil
}Close method · go · L75-L77 (3 LOC)store/sqlstore.go
func (s *SqlStore) Close() error {
return s.db.Close()
}RawDB method · go · L80-L82 (3 LOC)store/sqlstore.go
func (s *SqlStore) RawDB() *sqlite.DB {
return s.db
}SaveEnvelope method · go · L84-L170 (87 LOC)store/sqlstore.go
func (s *SqlStore) SaveEnvelope(runID string, env *rcatype.Envelope) error {
if env == nil {
return errors.New("envelope is nil")
}
payload, err := json.Marshal(env)
if err != nil {
return fmt.Errorf("marshal envelope: %w", err)
}
var existingID int64
err = s.db.QueryRow(
"SELECT id FROM launches WHERE source_run_id = ? LIMIT 1", runID,
).Scan(&existingID)
if err == nil {
_, err = s.db.Exec(
"UPDATE launches SET envelope_payload = ? WHERE id = ?",
payload, existingID,
)
if err != nil {
return fmt.Errorf("update envelope: %w", err)
}
return nil
}
if !errors.Is(err, sql.ErrNoRows) {
return fmt.Errorf("check existing launch: %w", err)
}
now := nowUTC()
var suiteID int64
err = s.db.QueryRow(
"SELECT id FROM investigation_suites WHERE name = 'Default Suite' LIMIT 1",
).Scan(&suiteID)
if errors.Is(err, sql.ErrNoRows) {
res, err := s.db.Exec(
"INSERT INTO investigation_suites(name, description, status, created_at) VALUES(?, ?, 'open', ?)",GetEnvelope method · go · L172-L192 (21 LOC)store/sqlstore.go
func (s *SqlStore) GetEnvelope(runID string) (*rcatype.Envelope, error) {
var payload []byte
err := s.db.QueryRow(
"SELECT envelope_payload FROM launches WHERE source_run_id = ? LIMIT 1",
runID,
).Scan(&payload)
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("get envelope: %w", err)
}
if payload == nil {
return nil, nil
}
var env rcatype.Envelope
if err := json.Unmarshal(payload, &env); err != nil {
return nil, fmt.Errorf("unmarshal envelope: %w", err)
}
return &env, nil
}Open data scored by Repobility · https://repobility.com
FillTemplateFS function · go · L24-L33 (10 LOC)template.go
func FillTemplateFS(fsys fs.FS, templatePath string, params *TemplateParams) (string, error) {
if fsys == nil {
return "", fmt.Errorf("read template %s: prompt filesystem is nil", templatePath)
}
data, err := fs.ReadFile(fsys, templatePath)
if err != nil {
return "", fmt.Errorf("read template %s: %w", templatePath, err)
}
return FillTemplateString(templatePath, string(data), params)
}FillTemplate function · go · L38-L44 (7 LOC)template.go
func FillTemplate(templatePath string, params *TemplateParams) (string, error) {
data, err := os.ReadFile(templatePath)
if err != nil {
return "", fmt.Errorf("read template %s: %w", templatePath, err)
}
return FillTemplateString(templatePath, string(data), params)
}FillTemplateString function · go · L48-L59 (12 LOC)template.go
func FillTemplateString(name, tmplStr string, params *TemplateParams) (string, error) {
tmpl, err := template.New(name).Funcs(PromptFuncMap).Parse(tmplStr)
if err != nil {
return "", fmt.Errorf("parse template %s: %w", name, err)
}
var buf bytes.Buffer
if err := tmpl.Execute(&buf, params); err != nil {
return "", fmt.Errorf("execute template %s: %w", name, err)
}
return buf.String(), nil
}