Compare commits
No commits in common. "4b2b9399e91ccddab69512a3fa437fa2a8f46792" and "5a82da2b1683c5f5c6803f2e537258f95f19b05c" have entirely different histories.
4b2b9399e9
...
5a82da2b16
5 changed files with 13 additions and 16 deletions
|
@ -36,8 +36,7 @@ func (a *Alert) ToAddAlertParams() database.AddAlertParams {
|
||||||
return database.AddAlertParams{
|
return database.AddAlertParams{
|
||||||
ID: a.ID,
|
ID: a.ID,
|
||||||
Time: pgtype.Timestamptz{Time: a.Timestamp, Valid: true},
|
Time: pgtype.Timestamptz{Time: a.Timestamp, Valid: true},
|
||||||
SystemID: int(a.Score.ID.System),
|
PackedTg: a.Score.ID.Pack(),
|
||||||
Tgid: int(a.Score.ID.Talkgroup),
|
|
||||||
Weight: &a.Weight,
|
Weight: &a.Weight,
|
||||||
Score: &f32score,
|
Score: &f32score,
|
||||||
OrigScore: origScore,
|
OrigScore: origScore,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const addAlert = `-- name: AddAlert :exec
|
const addAlert = `-- name: AddAlert :exec
|
||||||
INSERT INTO alerts (id, time, tgid, system_id, weight, score, orig_score, notified, metadata)
|
INSERT INTO alerts (id, time, talkgroup, weight, score, orig_score, notified, metadata)
|
||||||
VALUES
|
VALUES
|
||||||
(
|
(
|
||||||
$1,
|
$1,
|
||||||
|
@ -23,16 +23,14 @@ VALUES
|
||||||
$5,
|
$5,
|
||||||
$6,
|
$6,
|
||||||
$7,
|
$7,
|
||||||
$8,
|
$8
|
||||||
$9
|
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
|
|
||||||
type AddAlertParams struct {
|
type AddAlertParams struct {
|
||||||
ID uuid.UUID `json:"id"`
|
ID uuid.UUID `json:"id"`
|
||||||
Time pgtype.Timestamptz `json:"time"`
|
Time pgtype.Timestamptz `json:"time"`
|
||||||
Tgid int `json:"tgid"`
|
PackedTg int64 `json:"packed_tg"`
|
||||||
SystemID int `json:"system_id"`
|
|
||||||
Weight *float32 `json:"weight"`
|
Weight *float32 `json:"weight"`
|
||||||
Score *float32 `json:"score"`
|
Score *float32 `json:"score"`
|
||||||
OrigScore *float32 `json:"orig_score"`
|
OrigScore *float32 `json:"orig_score"`
|
||||||
|
@ -44,8 +42,7 @@ func (q *Queries) AddAlert(ctx context.Context, arg AddAlertParams) error {
|
||||||
_, err := q.db.Exec(ctx, addAlert,
|
_, err := q.db.Exec(ctx, addAlert,
|
||||||
arg.ID,
|
arg.ID,
|
||||||
arg.Time,
|
arg.Time,
|
||||||
arg.Tgid,
|
arg.PackedTg,
|
||||||
arg.SystemID,
|
|
||||||
arg.Weight,
|
arg.Weight,
|
||||||
arg.Score,
|
arg.Score,
|
||||||
arg.OrigScore,
|
arg.OrigScore,
|
||||||
|
|
|
@ -15,8 +15,9 @@ import (
|
||||||
type Alert struct {
|
type Alert struct {
|
||||||
ID uuid.UUID `json:"id"`
|
ID uuid.UUID `json:"id"`
|
||||||
Time pgtype.Timestamptz `json:"time"`
|
Time pgtype.Timestamptz `json:"time"`
|
||||||
Tgid int `json:"tgid"`
|
Talkgroup int64 `json:"talkgroup"`
|
||||||
SystemID int `json:"system_id"`
|
SystemID int32 `json:"system_id"`
|
||||||
|
Tgid int32 `json:"tgid"`
|
||||||
Weight *float32 `json:"weight"`
|
Weight *float32 `json:"weight"`
|
||||||
Score *float32 `json:"score"`
|
Score *float32 `json:"score"`
|
||||||
OrigScore *float32 `json:"orig_score"`
|
OrigScore *float32 `json:"orig_score"`
|
||||||
|
|
|
@ -74,8 +74,9 @@ CREATE TABLE IF NOT EXISTS talkgroups_learned(
|
||||||
CREATE TABLE IF NOT EXISTS alerts(
|
CREATE TABLE IF NOT EXISTS alerts(
|
||||||
id UUID PRIMARY KEY,
|
id UUID PRIMARY KEY,
|
||||||
time TIMESTAMPTZ NOT NULL,
|
time TIMESTAMPTZ NOT NULL,
|
||||||
tgid INTEGER NOT NULL,
|
talkgroup INT8 REFERENCES talkgroups(id) NOT NULL,
|
||||||
system_id INTEGER REFERENCES systems(id) NOT NULL,
|
system_id INT4 REFERENCES systems(id) NOT NULL GENERATED ALWAYS AS (talkgroup >> 32) STORED,
|
||||||
|
tgid INT4 NOT NULL GENERATED ALWAYS AS (talkgroup & x'ffffffff'::BIGINT) STORED,
|
||||||
weight REAL,
|
weight REAL,
|
||||||
score REAL,
|
score REAL,
|
||||||
orig_score REAL,
|
orig_score REAL,
|
||||||
|
|
|
@ -41,13 +41,12 @@ source
|
||||||
UPDATE calls SET transcript = $2 WHERE id = $1;
|
UPDATE calls SET transcript = $2 WHERE id = $1;
|
||||||
|
|
||||||
-- name: AddAlert :exec
|
-- name: AddAlert :exec
|
||||||
INSERT INTO alerts (id, time, tgid, system_id, weight, score, orig_score, notified, metadata)
|
INSERT INTO alerts (id, time, talkgroup, weight, score, orig_score, notified, metadata)
|
||||||
VALUES
|
VALUES
|
||||||
(
|
(
|
||||||
sqlc.arg(id),
|
sqlc.arg(id),
|
||||||
sqlc.arg(time),
|
sqlc.arg(time),
|
||||||
sqlc.arg(tgid),
|
sqlc.arg(packed_tg),
|
||||||
sqlc.arg(system_id),
|
|
||||||
sqlc.arg(weight),
|
sqlc.arg(weight),
|
||||||
sqlc.arg(score),
|
sqlc.arg(score),
|
||||||
sqlc.arg(orig_score),
|
sqlc.arg(orig_score),
|
||||||
|
|
Loading…
Reference in a new issue