f99010fae1
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Windows) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Has been cancelled
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// ListModelPricing returns every pricing row, including sentinel
|
|
// metadata rows (for example `_fallback_version`).
|
|
func (db *DB) ListModelPricing(
|
|
ctx context.Context,
|
|
) ([]ModelPricing, error) {
|
|
return db.listModelPricing(ctx)
|
|
}
|
|
|
|
func (db *DB) listModelPricing(
|
|
ctx context.Context,
|
|
) ([]ModelPricing, error) {
|
|
rows, err := db.getReader().QueryContext(
|
|
ctx,
|
|
`SELECT model_pattern, input_per_mtok,
|
|
output_per_mtok, cache_creation_per_mtok,
|
|
cache_read_per_mtok, updated_at
|
|
FROM model_pricing
|
|
ORDER BY model_pattern`,
|
|
)
|
|
if err != nil {
|
|
return nil, fmt.Errorf(
|
|
"listing model pricing: %w", err,
|
|
)
|
|
}
|
|
defer rows.Close()
|
|
|
|
var out []ModelPricing
|
|
for rows.Next() {
|
|
var p ModelPricing
|
|
if err := rows.Scan(
|
|
&p.ModelPattern,
|
|
&p.InputPerMTok,
|
|
&p.OutputPerMTok,
|
|
&p.CacheCreationPerMTok,
|
|
&p.CacheReadPerMTok,
|
|
&p.UpdatedAt,
|
|
); err != nil {
|
|
return nil, fmt.Errorf(
|
|
"scanning model pricing: %w", err,
|
|
)
|
|
}
|
|
out = append(out, p)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, fmt.Errorf(
|
|
"iterating model pricing: %w", err,
|
|
)
|
|
}
|
|
if out == nil {
|
|
out = []ModelPricing{}
|
|
}
|
|
return out, nil
|
|
}
|