SeedFromBytes applies an arbitrary JSON seed. Most callers should use Seed, which applies the seed embedded in this binary; SeedFromBytes is exposed for tests that need to inject a deterministic seed.
(ctx context.Context, db database.Store, data []byte)
| 43 | // which applies the seed embedded in this binary; SeedFromBytes is exposed |
| 44 | // for tests that need to inject a deterministic seed. |
| 45 | func SeedFromBytes(ctx context.Context, db database.Store, data []byte) error { |
| 46 | rows, err := parseSeed(data) |
| 47 | if err != nil { |
| 48 | return xerrors.Errorf("parse price seed: %w", err) |
| 49 | } |
| 50 | if len(rows) == 0 { |
| 51 | return xerrors.New("price seed is empty") |
| 52 | } |
| 53 | return db.UpsertAIModelPrices(ctx, data) |
| 54 | } |
| 55 | |
| 56 | func parseSeed(data []byte) ([]seedRow, error) { |
| 57 | var rows []seedRow |