// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.27.0 // source: calls.sql package database import ( "context" "github.com/google/uuid" "github.com/jackc/pgx/v5/pgtype" ) const addAlert = `-- name: AddAlert :exec INSERT INTO alerts (time, tgid, system_id, weight, score, orig_score, notified, metadata) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8 ) ` type AddAlertParams struct { Time pgtype.Timestamptz `json:"time"` TGID int `json:"tgid"` SystemID int `json:"system_id"` Weight *float32 `json:"weight"` Score *float32 `json:"score"` OrigScore *float32 `json:"orig_score"` Notified bool `json:"notified"` Metadata []byte `json:"metadata"` } func (q *Queries) AddAlert(ctx context.Context, arg AddAlertParams) error { _, err := q.db.Exec(ctx, addAlert, arg.Time, arg.TGID, arg.SystemID, arg.Weight, arg.Score, arg.OrigScore, arg.Notified, arg.Metadata, ) return err } const addCall = `-- name: AddCall :exec INSERT INTO calls ( id, submitter, system, talkgroup, call_date, audio_name, audio_blob, audio_type, audio_url, duration, frequency, frequencies, patches, tg_label, tg_alpha_tag, tg_group, source ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17 ) ` type AddCallParams struct { ID uuid.UUID `json:"id"` Submitter *int32 `json:"submitter"` System int `json:"system"` Talkgroup int `json:"talkgroup"` CallDate pgtype.Timestamptz `json:"call_date"` AudioName *string `json:"audio_name"` AudioBlob []byte `json:"audio_blob"` AudioType *string `json:"audio_type"` AudioUrl *string `json:"audio_url"` Duration *int32 `json:"duration"` Frequency int `json:"frequency"` Frequencies []int `json:"frequencies"` Patches []int `json:"patches"` TGLabel *string `json:"tg_label"` TGAlphaTag *string `json:"tg_alpha_tag"` TGGroup *string `json:"tg_group"` Source int `json:"source"` } func (q *Queries) AddCall(ctx context.Context, arg AddCallParams) error { _, err := q.db.Exec(ctx, addCall, arg.ID, arg.Submitter, arg.System, arg.Talkgroup, arg.CallDate, arg.AudioName, arg.AudioBlob, arg.AudioType, arg.AudioUrl, arg.Duration, arg.Frequency, arg.Frequencies, arg.Patches, arg.TGLabel, arg.TGAlphaTag, arg.TGGroup, arg.Source, ) return err } const cleanupSweptCalls = `-- name: CleanupSweptCalls :execrows WITH to_sweep AS ( SELECT id FROM calls JOIN incidents_calls ic ON ic.call_id = calls.id WHERE calls.call_date >= $1 AND calls.call_date < $2 ) UPDATE incidents_calls SET swept_call_id = call_id, calls_tbl_id = NULL WHERE call_id IN (SELECT id FROM to_sweep) ` func (q *Queries) CleanupSweptCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error) { result, err := q.db.Exec(ctx, cleanupSweptCalls, rangeStart, rangeEnd) if err != nil { return 0, err } return result.RowsAffected(), nil } const getCallAudioByID = `-- name: GetCallAudioByID :one SELECT call_date, audio_name, audio_type, audio_blob FROM calls WHERE id = $1 ` type GetCallAudioByIDRow struct { CallDate pgtype.Timestamptz `json:"call_date"` AudioName *string `json:"audio_name"` AudioType *string `json:"audio_type"` AudioBlob []byte `json:"audio_blob"` } func (q *Queries) GetCallAudioByID(ctx context.Context, id uuid.UUID) (GetCallAudioByIDRow, error) { row := q.db.QueryRow(ctx, getCallAudioByID, id) var i GetCallAudioByIDRow err := row.Scan( &i.CallDate, &i.AudioName, &i.AudioType, &i.AudioBlob, ) return i, err } const getDatabaseSize = `-- name: GetDatabaseSize :one SELECT pg_size_pretty(pg_database_size(current_database())) ` func (q *Queries) GetDatabaseSize(ctx context.Context) (string, error) { row := q.db.QueryRow(ctx, getDatabaseSize) var pg_size_pretty string err := row.Scan(&pg_size_pretty) return pg_size_pretty, err } const setCallTranscript = `-- name: SetCallTranscript :exec UPDATE calls SET transcript = $2 WHERE id = $1 ` func (q *Queries) SetCallTranscript(ctx context.Context, iD uuid.UUID, transcript *string) error { _, err := q.db.Exec(ctx, setCallTranscript, iD, transcript) return err } const sweepCalls = `-- name: SweepCalls :execrows WITH to_sweep AS ( SELECT id, submitter, system, talkgroup, calls.call_date, audio_name, audio_blob, duration, audio_type, audio_url, frequency, frequencies, patches, tg_label, tg_alpha_tag, tg_group, source, transcript FROM calls JOIN incidents_calls ic ON ic.call_id = calls.id WHERE calls.call_date >= $1 AND calls.call_date < $2 ) INSERT INTO swept_calls SELECT id, submitter, system, talkgroup, call_date, audio_name, audio_blob, duration, audio_type, audio_url, frequency, frequencies, patches, tg_label, tg_alpha_tag, tg_group, source, transcript FROM to_sweep ` func (q *Queries) SweepCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error) { result, err := q.db.Exec(ctx, sweepCalls, rangeStart, rangeEnd) if err != nil { return 0, err } return result.RowsAffected(), nil }