(q oplog.Query, f func(oplog.OpMetadata) error)
| 341 | } |
| 342 | |
| 343 | func (m *SqliteStore) QueryMetadata(q oplog.Query, f func(oplog.OpMetadata) error) error { |
| 344 | where, args := m.buildQueryWhereClause(q, false) |
| 345 | rows, err := m.dbpool.QueryContext(context.Background(), "SELECT operations.id, operations.modno, operations.original_id, operations.flow_id, operations.original_flow_id, operations.status, operations.ogid, operation_groups.repo_id, operation_groups.repo_guid, operation_groups.plan_id FROM operations JOIN operation_groups ON operations.ogid = operation_groups.ogid WHERE "+where, args...) |
| 346 | if err != nil { |
| 347 | return fmt.Errorf("query metadata: %v", err) |
| 348 | } |
| 349 | defer rows.Close() |
| 350 | |
| 351 | for rows.Next() { |
| 352 | var meta oplog.OpMetadata |
| 353 | var ogid int64 |
| 354 | if err := rows.Scan(&meta.ID, &meta.Modno, &meta.OriginalID, &meta.FlowID, &meta.OriginalFlowID, &meta.Status, &ogid, &meta.RepoID, &meta.RepoGUID, &meta.PlanID); err != nil { |
| 355 | return fmt.Errorf("query metadata: scan: %v", err) |
| 356 | } |
| 357 | if err := f(meta); err != nil { |
| 358 | if errors.Is(err, oplog.ErrStopIteration) { |
| 359 | return nil |
| 360 | } |
| 361 | return err |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | return rows.Err() |
| 366 | } |
| 367 | |
| 368 | // tidyGroups deletes operation groups that are no longer referenced, it takes an int64 specifying the maximum group ID to consider. |
| 369 | // this allows ignoring newly created groups that may not yet be referenced. |
nothing calls this directly
no test coverage detected