MCPcopy Create free account
hub / github.com/cinar/indicator / GetSince

Method GetSince

asset/sql_repository.go:117–149  ·  view source on GitHub ↗

GetSince attempts to return a channel of snapshots for the asset with the given name since the given date.

(name string, date time.Time)

Source from the content-addressed store, hash-verified

115
116// GetSince attempts to return a channel of snapshots for the asset with the given name since the given date.
117func (s *SQLRepository) GetSince(name string, date time.Time) (<-chan *Snapshot, error) {
118 rows, err := s.getSinceQuery.Query(name, date)
119 if err != nil {
120 return nil, fmt.Errorf("unable to get since: %w", err)
121 }
122
123 snapshots := make(chan *Snapshot)
124
125 go func() {
126 defer helper.CloseDatabaseRows(rows)
127 defer close(snapshots)
128
129 for rows.Next() {
130 snapshot := &Snapshot{}
131
132 err := rows.Scan(
133 &snapshot.Date,
134 &snapshot.Open,
135 &snapshot.High,
136 &snapshot.Low,
137 &snapshot.Close,
138 &snapshot.Volume,
139 )
140 if err != nil {
141 log.Printf("unable to scan row: %v", err)
142 }
143
144 snapshots <- snapshot
145 }
146 }()
147
148 return snapshots, nil
149}
150
151// LastDate returns the date of the last snapshot for the asset with the given name.
152func (s *SQLRepository) LastDate(name string) (time.Time, error) {

Callers 1

GetMethod · 0.95

Calls 3

CloseDatabaseRowsFunction · 0.92
QueryMethod · 0.80
NextMethod · 0.80

Tested by

no test coverage detected