MCPcopy
hub / github.com/sourcegraph/checkup / GetIndex

Method GetIndex

storage/sql/sql.go:106–133  ·  view source on GitHub ↗

GetIndex returns the list of check results for the database.

()

Source from the content-addressed store, hash-verified

104
105// GetIndex returns the list of check results for the database.
106func (sql Storage) GetIndex() (map[string]int64, error) {
107 db, err := sql.dbConnect()
108 if err != nil {
109 return nil, err
110 }
111 defer db.Close()
112
113 idx := make(map[string]int64)
114 var check struct {
115 Name string `db:"name"`
116 Timestamp int64 `db:"timestamp"`
117 }
118
119 rows, err := db.Queryx(`SELECT name,timestamp FROM "checks"`)
120 if err != nil {
121 return nil, err
122 }
123 for rows.Next() {
124 err := rows.StructScan(&check)
125 if err != nil {
126 rows.Close()
127 return nil, err
128 }
129 idx[check.Name] = check.Timestamp
130 }
131
132 return idx, nil
133}
134
135// Fetch fetches results of the check with given name.
136func (sql Storage) Fetch(name string) ([]types.Result, 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 1

dbConnectMethod · 0.95

Tested by 1

TestSQLFunction · 0.76