// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: wages.sql package dbgen import ( "context" "github.com/shopspring/decimal" ) const listBlsWages = `-- name: ListBlsWages :many SELECT series_id, occupation_code, occupation_title, role, area, area_name, metric, period_year, value, raw, synced_at FROM bls_wages ORDER BY occupation_code, area, metric ` func (q *Queries) ListBlsWages(ctx context.Context) ([]BlsWage, error) { rows, err := q.db.Query(ctx, listBlsWages) if err != nil { return nil, err } defer rows.Close() items := []BlsWage{} for rows.Next() { var i BlsWage if err := rows.Scan( &i.SeriesID, &i.OccupationCode, &i.OccupationTitle, &i.Role, &i.Area, &i.AreaName, &i.Metric, &i.PeriodYear, &i.Value, &i.Raw, &i.SyncedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const upsertBlsWage = `-- name: UpsertBlsWage :exec INSERT INTO bls_wages ( series_id, occupation_code, occupation_title, role, area, area_name, metric, period_year, value, raw, synced_at ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, now() ) ON CONFLICT (series_id) DO UPDATE SET occupation_code = EXCLUDED.occupation_code, occupation_title = EXCLUDED.occupation_title, role = EXCLUDED.role, area = EXCLUDED.area, area_name = EXCLUDED.area_name, metric = EXCLUDED.metric, period_year = EXCLUDED.period_year, value = EXCLUDED.value, raw = EXCLUDED.raw, synced_at = now() ` type UpsertBlsWageParams struct { SeriesID string `json:"series_id"` OccupationCode string `json:"occupation_code"` OccupationTitle string `json:"occupation_title"` Role string `json:"role"` Area string `json:"area"` AreaName string `json:"area_name"` Metric string `json:"metric"` PeriodYear string `json:"period_year"` Value *decimal.Decimal `json:"value"` Raw []byte `json:"raw"` } // BLS OEWS wage baseline cache. Global public catalog (no organization_id, outside RLS): reads run // off the pool, writes come from the weekly rates sync (cmd/rates-sync) as the migrator role. func (q *Queries) UpsertBlsWage(ctx context.Context, arg UpsertBlsWageParams) error { _, err := q.db.Exec(ctx, upsertBlsWage, arg.SeriesID, arg.OccupationCode, arg.OccupationTitle, arg.Role, arg.Area, arg.AreaName, arg.Metric, arg.PeriodYear, arg.Value, arg.Raw, ) return err } const upsertBlsWageByOcc = `-- name: UpsertBlsWageByOcc :exec INSERT INTO bls_wages ( series_id, occupation_code, occupation_title, role, area, area_name, metric, period_year, value, raw, synced_at ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, now() ) ON CONFLICT (occupation_code, area, metric) DO UPDATE SET series_id = EXCLUDED.series_id, occupation_title = EXCLUDED.occupation_title, role = EXCLUDED.role, area_name = EXCLUDED.area_name, period_year = EXCLUDED.period_year, value = EXCLUDED.value, raw = EXCLUDED.raw, synced_at = now() ` type UpsertBlsWageByOccParams struct { SeriesID string `json:"series_id"` OccupationCode string `json:"occupation_code"` OccupationTitle string `json:"occupation_title"` Role string `json:"role"` Area string `json:"area"` AreaName string `json:"area_name"` Metric string `json:"metric"` PeriodYear string `json:"period_year"` Value *decimal.Decimal `json:"value"` Raw []byte `json:"raw"` } // National OEWS wage expansion upsert, keyed on the natural key (occupation_code, area, metric), the // UNIQUE added in migration 0035. Used by cmd/oews-national-sync for the area='US' national rows: a // second run updates the value in place and inserts nothing new. Idempotent. func (q *Queries) UpsertBlsWageByOcc(ctx context.Context, arg UpsertBlsWageByOccParams) error { _, err := q.db.Exec(ctx, upsertBlsWageByOcc, arg.SeriesID, arg.OccupationCode, arg.OccupationTitle, arg.Role, arg.Area, arg.AreaName, arg.Metric, arg.PeriodYear, arg.Value, arg.Raw, ) return err } const wagesSyncMeta = `-- name: WagesSyncMeta :one SELECT COUNT(*)::bigint AS total, MAX(synced_at) AS last_synced FROM bls_wages ` type WagesSyncMetaRow struct { Total int64 `json:"total"` LastSynced interface{} `json:"last_synced"` } func (q *Queries) WagesSyncMeta(ctx context.Context) (WagesSyncMetaRow, error) { row := q.db.QueryRow(ctx, wagesSyncMeta) var i WagesSyncMetaRow err := row.Scan(&i.Total, &i.LastSynced) return i, err }