stillbox/pkg/database/calls.sql.go

140 lines
3.2 KiB
Go
Raw Normal View History

2024-07-16 19:31:30 -04:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.26.0
// source: calls.sql
package database
import (
"context"
2024-07-24 22:42:30 -04:00
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
2024-07-16 19:31:30 -04:00
)
2024-11-01 09:15:39 -04:00
const addAlert = `-- name: AddAlert :exec
2024-11-02 14:26:58 -04:00
INSERT INTO alerts (id, time, talkgroup, weight, score, orig_score, notified, metadata)
2024-11-01 09:15:39 -04:00
VALUES
(
$1,
$2,
$3,
$4,
$5,
2024-11-02 09:41:48 -04:00
$6,
2024-11-02 14:26:58 -04:00
$7,
$8
2024-11-01 09:15:39 -04:00
)
`
type AddAlertParams struct {
2024-11-02 09:41:48 -04:00
ID uuid.UUID `json:"id"`
Time pgtype.Timestamptz `json:"time"`
PackedTg int64 `json:"packed_tg"`
Weight *float32 `json:"weight"`
Score *float32 `json:"score"`
OrigScore *float32 `json:"orig_score"`
2024-11-02 14:26:58 -04:00
Notified bool `json:"notified"`
2024-11-02 09:41:48 -04:00
Metadata []byte `json:"metadata"`
2024-11-01 09:15:39 -04:00
}
func (q *Queries) AddAlert(ctx context.Context, arg AddAlertParams) error {
_, err := q.db.Exec(ctx, addAlert,
arg.ID,
arg.Time,
arg.PackedTg,
arg.Weight,
arg.Score,
2024-11-02 09:41:48 -04:00
arg.OrigScore,
2024-11-02 14:26:58 -04:00
arg.Notified,
2024-11-01 09:15:39 -04:00
arg.Metadata,
)
return err
}
2024-07-16 19:31:30 -04:00
const addCall = `-- name: AddCall :one
INSERT INTO calls (
id,
submitter,
system,
talkgroup,
2024-07-16 19:35:16 -04:00
call_date,
2024-07-16 19:31:30 -04:00
audio_name,
audio_blob,
audio_type,
audio_url,
2024-08-11 13:46:43 -04:00
duration,
2024-07-16 19:31:30 -04:00
frequency,
frequencies,
patches,
tg_label,
2024-08-23 14:28:47 -04:00
tg_alpha_tag,
2024-07-27 19:25:16 -04:00
tg_group,
2024-07-16 19:31:30 -04:00
source
2024-08-11 13:46:43 -04:00
) VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
RETURNING id
2024-07-16 19:31:30 -04:00
`
type AddCallParams struct {
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"`
2024-07-16 19:31:30 -04:00
}
func (q *Queries) AddCall(ctx context.Context, arg AddCallParams) (uuid.UUID, error) {
2024-07-16 19:31:30 -04:00
row := q.db.QueryRow(ctx, addCall,
arg.Submitter,
arg.System,
arg.Talkgroup,
2024-07-16 19:35:16 -04:00
arg.CallDate,
2024-07-16 19:31:30 -04:00
arg.AudioName,
arg.AudioBlob,
arg.AudioType,
arg.AudioUrl,
2024-08-11 13:46:43 -04:00
arg.Duration,
2024-07-16 19:31:30 -04:00
arg.Frequency,
arg.Frequencies,
arg.Patches,
arg.TgLabel,
2024-08-23 14:28:47 -04:00
arg.TgAlphaTag,
2024-07-27 19:25:16 -04:00
arg.TgGroup,
2024-07-16 19:31:30 -04:00
arg.Source,
)
var id uuid.UUID
err := row.Scan(&id)
return id, err
2024-07-16 19:31:30 -04:00
}
2024-10-20 13:04:42 -04:00
const getDatabaseSize = `-- name: GetDatabaseSize :one
SELECT pg_size_pretty(pg_database_size(current_database()))
2024-10-20 12:26:32 -04:00
`
2024-10-20 13:04:42 -04:00
func (q *Queries) GetDatabaseSize(ctx context.Context) (string, error) {
row := q.db.QueryRow(ctx, getDatabaseSize)
2024-10-20 12:26:32 -04:00
var pg_size_pretty string
err := row.Scan(&pg_size_pretty)
return pg_size_pretty, err
}
2024-07-17 19:33:09 -04:00
const setCallTranscript = `-- name: SetCallTranscript :exec
2024-07-16 19:31:30 -04:00
UPDATE calls SET transcript = $2 WHERE id = $1
`
2024-07-25 09:37:27 -04:00
func (q *Queries) SetCallTranscript(ctx context.Context, iD uuid.UUID, transcript *string) error {
2024-07-22 08:39:33 -04:00
_, err := q.db.Exec(ctx, setCallTranscript, iD, transcript)
2024-07-16 19:31:30 -04:00
return err
}