2024-07-17 19:30:16 -04:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.26.0
|
|
|
|
// source: talkgroups.sql
|
|
|
|
|
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2024-08-06 11:19:30 -04:00
|
|
|
const bulkSetTalkgroupTags = `-- name: BulkSetTalkgroupTags :exec
|
|
|
|
UPDATE talkgroups SET tags = $2
|
|
|
|
WHERE id = ANY($1)
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) BulkSetTalkgroupTags(ctx context.Context, iD int64, tags []string) error {
|
|
|
|
_, err := q.db.Exec(ctx, bulkSetTalkgroupTags, iD, tags)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-08-16 14:54:50 -04:00
|
|
|
const getTalkgroup = `-- name: GetTalkgroup :one
|
|
|
|
SELECT id, system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups WHERE id = systg2id($1, $2)
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetTalkgroup(ctx context.Context, systemID int, tgid int) (Talkgroup, error) {
|
|
|
|
row := q.db.QueryRow(ctx, getTalkgroup, systemID, tgid)
|
|
|
|
var i Talkgroup
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.SystemID,
|
|
|
|
&i.Tgid,
|
|
|
|
&i.Name,
|
|
|
|
&i.TgGroup,
|
|
|
|
&i.Frequency,
|
|
|
|
&i.Metadata,
|
|
|
|
&i.Tags,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2024-08-06 11:19:30 -04:00
|
|
|
const getTalkgroupIDsByTags = `-- name: GetTalkgroupIDsByTags :many
|
|
|
|
SELECT system_id, tgid FROM talkgroups
|
|
|
|
WHERE (tags @> ARRAY[$1])
|
|
|
|
AND (tags && ARRAY[$2])
|
|
|
|
AND NOT (tags @> ARRAY[$3])
|
|
|
|
`
|
|
|
|
|
|
|
|
type GetTalkgroupIDsByTagsRow struct {
|
|
|
|
SystemID int32 `json:"system_id"`
|
|
|
|
Tgid int32 `json:"tgid"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetTalkgroupIDsByTags(ctx context.Context, anytags []string, alltags []string, nottags []string) ([]GetTalkgroupIDsByTagsRow, error) {
|
|
|
|
rows, err := q.db.Query(ctx, getTalkgroupIDsByTags, anytags, alltags, nottags)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []GetTalkgroupIDsByTagsRow
|
|
|
|
for rows.Next() {
|
|
|
|
var i GetTalkgroupIDsByTagsRow
|
|
|
|
if err := rows.Scan(&i.SystemID, &i.Tgid); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
2024-07-17 19:30:16 -04:00
|
|
|
const getTalkgroupTags = `-- name: GetTalkgroupTags :one
|
2024-07-28 23:07:04 -04:00
|
|
|
SELECT tags FROM talkgroups
|
2024-08-06 11:19:30 -04:00
|
|
|
WHERE id = systg2id($1, $2)
|
2024-07-17 19:30:16 -04:00
|
|
|
`
|
|
|
|
|
2024-08-06 11:19:30 -04:00
|
|
|
func (q *Queries) GetTalkgroupTags(ctx context.Context, sys int, tg int) ([]string, error) {
|
|
|
|
row := q.db.QueryRow(ctx, getTalkgroupTags, sys, tg)
|
2024-07-17 19:30:16 -04:00
|
|
|
var tags []string
|
|
|
|
err := row.Scan(&tags)
|
|
|
|
return tags, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getTalkgroupsWithAllTags = `-- name: GetTalkgroupsWithAllTags :many
|
2024-08-06 11:19:30 -04:00
|
|
|
SELECT id, system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups
|
2024-07-17 19:30:16 -04:00
|
|
|
WHERE tags && ARRAY[$1]
|
|
|
|
`
|
|
|
|
|
2024-07-28 23:07:04 -04:00
|
|
|
func (q *Queries) GetTalkgroupsWithAllTags(ctx context.Context, tags []string) ([]Talkgroup, error) {
|
2024-07-17 19:30:16 -04:00
|
|
|
rows, err := q.db.Query(ctx, getTalkgroupsWithAllTags, tags)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
2024-07-28 23:07:04 -04:00
|
|
|
var items []Talkgroup
|
2024-07-17 19:30:16 -04:00
|
|
|
for rows.Next() {
|
2024-07-28 23:07:04 -04:00
|
|
|
var i Talkgroup
|
|
|
|
if err := rows.Scan(
|
2024-08-06 11:19:30 -04:00
|
|
|
&i.ID,
|
2024-07-28 23:07:04 -04:00
|
|
|
&i.SystemID,
|
|
|
|
&i.Tgid,
|
|
|
|
&i.Name,
|
|
|
|
&i.TgGroup,
|
|
|
|
&i.Frequency,
|
|
|
|
&i.Metadata,
|
|
|
|
&i.Tags,
|
|
|
|
); err != nil {
|
2024-07-17 19:30:16 -04:00
|
|
|
return nil, err
|
|
|
|
}
|
2024-07-17 19:45:46 -04:00
|
|
|
items = append(items, i)
|
2024-07-17 19:30:16 -04:00
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const getTalkgroupsWithAnyTags = `-- name: GetTalkgroupsWithAnyTags :many
|
2024-08-06 11:19:30 -04:00
|
|
|
SELECT id, system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups
|
2024-07-17 19:30:16 -04:00
|
|
|
WHERE tags @> ARRAY[$1]
|
|
|
|
`
|
|
|
|
|
2024-07-28 23:07:04 -04:00
|
|
|
func (q *Queries) GetTalkgroupsWithAnyTags(ctx context.Context, tags []string) ([]Talkgroup, error) {
|
2024-07-17 19:30:16 -04:00
|
|
|
rows, err := q.db.Query(ctx, getTalkgroupsWithAnyTags, tags)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
2024-07-28 23:07:04 -04:00
|
|
|
var items []Talkgroup
|
2024-07-17 19:30:16 -04:00
|
|
|
for rows.Next() {
|
2024-07-28 23:07:04 -04:00
|
|
|
var i Talkgroup
|
|
|
|
if err := rows.Scan(
|
2024-08-06 11:19:30 -04:00
|
|
|
&i.ID,
|
2024-07-28 23:07:04 -04:00
|
|
|
&i.SystemID,
|
|
|
|
&i.Tgid,
|
|
|
|
&i.Name,
|
|
|
|
&i.TgGroup,
|
|
|
|
&i.Frequency,
|
|
|
|
&i.Metadata,
|
|
|
|
&i.Tags,
|
|
|
|
); err != nil {
|
2024-07-17 19:30:16 -04:00
|
|
|
return nil, err
|
|
|
|
}
|
2024-07-17 19:45:46 -04:00
|
|
|
items = append(items, i)
|
2024-07-17 19:30:16 -04:00
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
const setTalkgroupTags = `-- name: SetTalkgroupTags :exec
|
2024-08-06 11:19:30 -04:00
|
|
|
UPDATE talkgroups SET tags = $3
|
|
|
|
WHERE id = systg2id($1, $2)
|
2024-07-17 19:30:16 -04:00
|
|
|
`
|
|
|
|
|
2024-08-06 11:19:30 -04:00
|
|
|
func (q *Queries) SetTalkgroupTags(ctx context.Context, sys int, tg int, tags []string) error {
|
|
|
|
_, err := q.db.Exec(ctx, setTalkgroupTags, sys, tg, tags)
|
2024-07-17 19:30:16 -04:00
|
|
|
return err
|
|
|
|
}
|