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{
|
||||
ID: a.ID,
|
||||
Time: pgtype.Timestamptz{Time: a.Timestamp, Valid: true},
|
||||
SystemID: int(a.Score.ID.System),
|
||||
Tgid: int(a.Score.ID.Talkgroup),
|
||||
PackedTg: a.Score.ID.Pack(),
|
||||
Weight: &a.Weight,
|
||||
Score: &f32score,
|
||||
OrigScore: origScore,
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
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
|
||||
(
|
||||
$1,
|
||||
|
@ -23,16 +23,14 @@ VALUES
|
|||
$5,
|
||||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9
|
||||
$8
|
||||
)
|
||||
`
|
||||
|
||||
type AddAlertParams struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Time pgtype.Timestamptz `json:"time"`
|
||||
Tgid int `json:"tgid"`
|
||||
SystemID int `json:"system_id"`
|
||||
PackedTg int64 `json:"packed_tg"`
|
||||
Weight *float32 `json:"weight"`
|
||||
Score *float32 `json:"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,
|
||||
arg.ID,
|
||||
arg.Time,
|
||||
arg.Tgid,
|
||||
arg.SystemID,
|
||||
arg.PackedTg,
|
||||
arg.Weight,
|
||||
arg.Score,
|
||||
arg.OrigScore,
|
||||
|
|
|
@ -15,8 +15,9 @@ import (
|
|||
type Alert struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Time pgtype.Timestamptz `json:"time"`
|
||||
Tgid int `json:"tgid"`
|
||||
SystemID int `json:"system_id"`
|
||||
Talkgroup int64 `json:"talkgroup"`
|
||||
SystemID int32 `json:"system_id"`
|
||||
Tgid int32 `json:"tgid"`
|
||||
Weight *float32 `json:"weight"`
|
||||
Score *float32 `json:"score"`
|
||||
OrigScore *float32 `json:"orig_score"`
|
||||
|
|
|
@ -74,8 +74,9 @@ CREATE TABLE IF NOT EXISTS talkgroups_learned(
|
|||
CREATE TABLE IF NOT EXISTS alerts(
|
||||
id UUID PRIMARY KEY,
|
||||
time TIMESTAMPTZ NOT NULL,
|
||||
tgid INTEGER NOT NULL,
|
||||
system_id INTEGER REFERENCES systems(id) NOT NULL,
|
||||
talkgroup INT8 REFERENCES talkgroups(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,
|
||||
score REAL,
|
||||
orig_score REAL,
|
||||
|
|
|
@ -41,13 +41,12 @@ source
|
|||
UPDATE calls SET transcript = $2 WHERE id = $1;
|
||||
|
||||
-- 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
|
||||
(
|
||||
sqlc.arg(id),
|
||||
sqlc.arg(time),
|
||||
sqlc.arg(tgid),
|
||||
sqlc.arg(system_id),
|
||||
sqlc.arg(packed_tg),
|
||||
sqlc.arg(weight),
|
||||
sqlc.arg(score),
|
||||
sqlc.arg(orig_score),
|
||||
|
|
Loading…
Reference in a new issue