stillbox/pkg/database/calls.sql.go

157 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:
2024-11-15 11:34:54 -05:00
// sqlc v1.27.0
2024-07-16 19:31:30 -04:00
// 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-17 21:46:10 -05:00
INSERT INTO alerts (time, tgid, system_id, 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,
2024-11-17 21:46:10 -05:00
$8
2024-11-01 09:15:39 -04:00
)
`
type AddAlertParams struct {
2024-11-02 09:41:48 -04:00
Time pgtype.Timestamptz `json:"time"`
2024-11-15 11:34:54 -05:00
TGID int `json:"tgid"`
SystemID int `json:"system_id"`
2024-11-02 09:41:48 -04:00
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.Time,
2024-11-15 11:34:54 -05:00
arg.TGID,
arg.SystemID,
2024-11-01 09:15:39 -04:00
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
}
const addCall = `-- name: AddCall :exec
2024-07-16 19:31:30 -04:00
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
)
2024-07-16 19:31:30 -04:00
`
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"`
2024-11-17 21:46:10 -05:00
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) error {
_, err := q.db.Exec(ctx, addCall,
arg.ID,
2024-07-16 19:31:30 -04:00
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,
2024-11-17 21:46:10 -05:00
arg.TGLabel,
arg.TGAlphaTag,
arg.TGGroup,
2024-07-16 19:31:30 -04:00
arg.Source,
)
return 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
}