Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/platform/database/dbgen/opportunities.sql.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 39df94f92b2a33f852481fe1954dabed841524bb |
| Branch | w0-aedt-compliance |
| Path or archive member | internal/platform/database/dbgen/opportunities.sql.go |
| Original SHA-256 | 72f37d02bf8015946309d66f2956c43e7eb06f6a6806fb67ff97c620174d02c4 |
| Git blob SHA | c8108e44ecc82356f538bc9f7b55a2e80439b221 |
| Reading-copy SHA-256 | 72f37d02bf8015946309d66f2956c43e7eb06f6a6806fb67ff97c620174d02c4 |
Recovered source transcript
Download complete source text ↓195 lines · 5.1 KB
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: opportunities.sql
package dbgen
import (
"context"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
)
const createOpportunity = `-- name: CreateOpportunity :one
INSERT INTO opportunities (organization_id, name, solicitation_number, customer_agency, due_date, status)
VALUES ($1,$2,$3,$4,$5,$6)
RETURNING id, organization_id, name, solicitation_number, customer_agency, due_date, status, created_at, updated_at, value
`
type CreateOpportunityParams struct {
OrganizationID uuid.UUID `json:"organization_id"`
Name string `json:"name"`
SolicitationNumber *string `json:"solicitation_number"`
CustomerAgency *string `json:"customer_agency"`
DueDate pgtype.Date `json:"due_date"`
Status string `json:"status"`
}
func (q *Queries) CreateOpportunity(ctx context.Context, arg CreateOpportunityParams) (Opportunity, error) {
row := q.db.QueryRow(ctx, createOpportunity,
arg.OrganizationID,
arg.Name,
arg.SolicitationNumber,
arg.CustomerAgency,
arg.DueDate,
arg.Status,
)
var i Opportunity
err := row.Scan(
&i.ID,
&i.OrganizationID,
&i.Name,
&i.SolicitationNumber,
&i.CustomerAgency,
&i.DueDate,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
&i.Value,
)
return i, err
}
const getOpportunity = `-- name: GetOpportunity :one
SELECT id, organization_id, name, solicitation_number, customer_agency, due_date, status, created_at, updated_at, value FROM opportunities WHERE id = $1
`
func (q *Queries) GetOpportunity(ctx context.Context, id uuid.UUID) (Opportunity, error) {
row := q.db.QueryRow(ctx, getOpportunity, id)
var i Opportunity
err := row.Scan(
&i.ID,
&i.OrganizationID,
&i.Name,
&i.SolicitationNumber,
&i.CustomerAgency,
&i.DueDate,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
&i.Value,
)
return i, err
}
const listOpportunities = `-- name: ListOpportunities :many
SELECT id, organization_id, name, solicitation_number, customer_agency, due_date, status, created_at, updated_at, value FROM opportunities ORDER BY created_at DESC LIMIT $1 OFFSET $2
`
type ListOpportunitiesParams struct {
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
func (q *Queries) ListOpportunities(ctx context.Context, arg ListOpportunitiesParams) ([]Opportunity, error) {
rows, err := q.db.Query(ctx, listOpportunities, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Opportunity{}
for rows.Next() {
var i Opportunity
if err := rows.Scan(
&i.ID,
&i.OrganizationID,
&i.Name,
&i.SolicitationNumber,
&i.CustomerAgency,
&i.DueDate,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
&i.Value,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listRequirementsForOpportunity = `-- name: ListRequirementsForOpportunity :many
SELECT id, organization_id, opportunity_id, title, customer_agency, required_level, required_poly, required_years, work_location, remote_allowed, key_personnel, created_at, updated_at, deleted_at, labor_category, quantity FROM requirements WHERE opportunity_id = $1 AND deleted_at IS NULL ORDER BY created_at DESC
`
func (q *Queries) ListRequirementsForOpportunity(ctx context.Context, opportunityID *uuid.UUID) ([]Requirement, error) {
rows, err := q.db.Query(ctx, listRequirementsForOpportunity, opportunityID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Requirement{}
for rows.Next() {
var i Requirement
if err := rows.Scan(
&i.ID,
&i.OrganizationID,
&i.OpportunityID,
&i.Title,
&i.CustomerAgency,
&i.RequiredLevel,
&i.RequiredPoly,
&i.RequiredYears,
&i.WorkLocation,
&i.RemoteAllowed,
&i.KeyPersonnel,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.LaborCategory,
&i.Quantity,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const proposalReadiness = `-- name: ProposalReadiness :many
SELECT sm.band, sm.decision, COUNT(*) AS n
FROM requirements r
JOIN slates s ON s.requirement_id = r.id
JOIN slate_members sm ON sm.slate_id = s.id
WHERE r.opportunity_id = $1
GROUP BY sm.band, sm.decision
ORDER BY sm.band, sm.decision
`
type ProposalReadinessRow struct {
Band string `json:"band"`
Decision string `json:"decision"`
N int64 `json:"n"`
}
// Band/decision rollup across every slate member under one opportunity's requirements — the source
// for GET /proposal-readiness [review COMPL-2]. RLS scopes all three tables to the caller's org.
func (q *Queries) ProposalReadiness(ctx context.Context, opportunityID *uuid.UUID) ([]ProposalReadinessRow, error) {
rows, err := q.db.Query(ctx, proposalReadiness, opportunityID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ProposalReadinessRow{}
for rows.Next() {
var i ProposalReadinessRow
if err := rows.Scan(&i.Band, &i.Decision, &i.N); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}