MCPcopy Index your code
hub / github.com/sourcegraph/checkup / Store

Method Store

storage/sql/sql.go:157–174  ·  view source on GitHub ↗

Store stores results in the database.

(results []types.Result)

Source from the content-addressed store, hash-verified

155
156// Store stores results in the database.
157func (sql Storage) Store(results []types.Result) error {
158 db, err := sql.dbConnect()
159 if err != nil {
160 return err
161 }
162 defer db.Close()
163
164 name := *fs.GenerateFilename()
165 contents, err := json.Marshal(results)
166 if err != nil {
167 return err
168 }
169
170 // Insert data
171 const insertResults = `INSERT INTO "checks" (name, timestamp, results) VALUES (?, ?, ?)`
172 _, err = db.Exec(insertResults, name, time.Now().UnixNano(), contents)
173 return err
174}
175
176// Maintain deletes check files that are older than sql.CheckExpiry.
177func (sql Storage) Maintain() error {

Callers 1

TestSQLFunction · 0.95

Implementers 5

fakecheckup_test.go
Storagestorage/sql/sql.go
Storagestorage/s3/s3.go
Storagestorage/github/github.go
Storagestorage/fs/fs.go

Calls 2

dbConnectMethod · 0.95
GenerateFilenameFunction · 0.92

Tested by 1

TestSQLFunction · 0.76