package federalsignal import ( "context" "github.com/missionworkforce/missionmatch/internal/platform/database/dbgen" ) // repo is the production Repo: a thin dbgen backed adapter over the global catalogs. The classification // sync runs it as the migrator role, because federal_mission_tags and award_incumbent_roles are global // reference data the application role may only read. No tenant transaction is involved. type repo struct{ q *dbgen.Queries } // NewRepo builds the production Repo over a dbgen capable handle (a pool or a transaction). func NewRepo(db dbgen.DBTX) Repo { return &repo{q: dbgen.New(db)} } // AliasPairs reads the (phrase, code) rows that seed the missionclass AliasIndex and returns them as a // map. Duplicate phrases collapse on the map, which is fine: the SQL already unions and orders the rows, // and the AliasIndex builds deterministically from the resulting map in sorted key order. func (r *repo) AliasPairs(ctx context.Context) (map[string]string, error) { rows, err := r.q.MissionAliasPairs(ctx) if err != nil { return nil, err } out := make(map[string]string, len(rows)) for _, row := range rows { out[row.Phrase] = row.Code } return out, nil } func (r *repo) ListOpportunityRecordsForClassify(ctx context.Context) ([]dbgen.ListOpportunityRecordsForClassifyRow, error) { return r.q.ListOpportunityRecordsForClassify(ctx) } func (r *repo) ListAwardsForClassify(ctx context.Context) ([]dbgen.ListAwardsForClassifyRow, error) { return r.q.ListAwardsForClassify(ctx) } func (r *repo) ListSamForClassify(ctx context.Context) ([]dbgen.ListSamForClassifyRow, error) { return r.q.ListSamForClassify(ctx) } func (r *repo) UpsertFederalMissionTag(ctx context.Context, p dbgen.UpsertFederalMissionTagParams) error { return r.q.UpsertFederalMissionTag(ctx, p) } func (r *repo) UpsertAwardIncumbentRole(ctx context.Context, p dbgen.UpsertAwardIncumbentRoleParams) error { return r.q.UpsertAwardIncumbentRole(ctx, p) }