Begin new alert rule builder #100
23 changed files with 203 additions and 159 deletions
|
@ -169,7 +169,11 @@
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<tr mat-header-row *matHeaderRowDef="columns; sticky: true"></tr>
|
<tr mat-header-row *matHeaderRowDef="columns; sticky: true"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: columns" [ngClass]="{'in-incident': row.incidents > 0}"></tr>
|
<tr
|
||||||
|
mat-row
|
||||||
|
*matRowDef="let row; columns: columns"
|
||||||
|
[ngClass]="{ 'in-incident': row.incidents > 0 }"
|
||||||
|
></tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="pagFoot">
|
<div class="pagFoot">
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
@let inc = inc$ | async;
|
@let inc = inc$ | async;
|
||||||
<mat-card class="incident" appearance="outlined">
|
<mat-card class="incident" appearance="outlined">
|
||||||
<div class="cardHdr">
|
<div class="cardHdr">
|
||||||
<h1>{{ inc?.name }}</h1>
|
<h1>
|
||||||
|
{{ inc?.name }}
|
||||||
|
<a [href]="'/api/incident/' + incID + '.m3u'"
|
||||||
|
><mat-icon>playlist_play</mat-icon></a
|
||||||
|
>
|
||||||
|
</h1>
|
||||||
<button mat-icon-button (click)="editIncident(incID)">
|
<button mat-icon-button (click)="editIncident(incID)">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -15,12 +15,19 @@ export class AlertTime {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AlertRule {
|
export class AlertRule {
|
||||||
times: AlertTime[];
|
times!: string[];
|
||||||
mult: number;
|
mult!: number;
|
||||||
|
|
||||||
constructor(times: AlertTime[], mult: number) {
|
public getTimes(): AlertTime[] {
|
||||||
this.times = times;
|
let timesProc = <AlertTime[]>[];
|
||||||
this.mult = mult;
|
this.times.forEach((tm) => {
|
||||||
|
let sr = tm.split('+');
|
||||||
|
timesProc.push(<AlertTime>{
|
||||||
|
time: sr[0],
|
||||||
|
duration: sr[1],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return timesProc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +68,7 @@ export class Talkgroup {
|
||||||
tags!: string[];
|
tags!: string[];
|
||||||
alert!: boolean;
|
alert!: boolean;
|
||||||
system?: System;
|
system?: System;
|
||||||
alert_config!: AlertRule[];
|
alert_rules!: AlertRule[];
|
||||||
weight!: number;
|
weight!: number;
|
||||||
learned?: boolean;
|
learned?: boolean;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
|
@ -77,13 +84,17 @@ export class Talkgroup {
|
||||||
metadata: Metadata | null,
|
metadata: Metadata | null,
|
||||||
tags: string[],
|
tags: string[],
|
||||||
alert: boolean,
|
alert: boolean,
|
||||||
alert_config: AlertRule[],
|
alert_rules: AlertRule[],
|
||||||
weight: number,
|
weight: number,
|
||||||
system?: System,
|
system?: System,
|
||||||
learned?: boolean,
|
learned?: boolean,
|
||||||
icon?: string,
|
icon?: string,
|
||||||
) {
|
) {
|
||||||
this.iconSvg = this.iconMap(this.metadata?.icon!);
|
this.iconSvg = this.iconMap(this.metadata?.icon!);
|
||||||
|
this.alert_rules = this.alert_rules.map((x) =>
|
||||||
|
Object.assign(new AlertRule(), x),
|
||||||
|
);
|
||||||
|
console.log(this.alert_rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
iconMap(icon: string): string {
|
iconMap(icon: string): string {
|
||||||
|
@ -113,6 +124,6 @@ export interface TalkgroupUpdate {
|
||||||
metadata: Object | null;
|
metadata: Object | null;
|
||||||
tags: string[] | null;
|
tags: string[] | null;
|
||||||
alert: boolean | null;
|
alert: boolean | null;
|
||||||
alert_config: AlertRule[] | null;
|
alert_rules: AlertRule[] | null;
|
||||||
weight: number | null;
|
weight: number | null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,21 @@
|
||||||
<div class="container flex">
|
<div class="container flex">
|
||||||
@for (rule of rules; track $index) {
|
@for (rule of rules; track $index) {
|
||||||
<div class="">
|
<div class="rule">
|
||||||
<table class="table">
|
<table mat-table [dataSource]="rule | ruleTimes">
|
||||||
<thead>
|
<ng-container matColumnDef="time">
|
||||||
<tr>
|
<th mat-header-cell *matHeaderCellDef>Time</th>
|
||||||
<td>Start</td>
|
<td mat-cell *matCellDef="let time">{{ time.time }}</td>
|
||||||
<td>Duration</td>
|
</ng-container>
|
||||||
<td></td>
|
<ng-container matColumnDef="duration">
|
||||||
</tr>
|
<th mat-header-cell *matHeaderCellDef>Duration</th>
|
||||||
</thead>
|
<td mat-cell *matCellDef="let time">{{ time.duration }}</td>
|
||||||
<tbody>
|
</ng-container>
|
||||||
@for (time of rule.times; track $index) {
|
<ng-container matColumnDef="multiplier">
|
||||||
<tr>
|
<th mat-header-cell *matHeaderCellDef>Multiplier</th>
|
||||||
<td>
|
<td mat-cell *matCellDef="let time">{{ rule.mult }}</td>
|
||||||
{{ time.time }}
|
</ng-container>
|
||||||
</td>
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
<td>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||||
{{ time.duration }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
} @empty {
|
|
||||||
<tr>
|
|
||||||
<td><em>No times</em></td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
} @empty {
|
} @empty {
|
||||||
|
|
|
@ -1,18 +1,43 @@
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import {
|
||||||
import { AlertRule } from '../../../talkgroup';
|
Component,
|
||||||
|
Input,
|
||||||
|
Output,
|
||||||
|
EventEmitter,
|
||||||
|
Pipe,
|
||||||
|
PipeTransform,
|
||||||
|
} from '@angular/core';
|
||||||
|
import { AlertRule, AlertTime } from '../../../talkgroup';
|
||||||
|
import { MatTableModule } from '@angular/material/table';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'ruleTimes',
|
||||||
|
standalone: true,
|
||||||
|
pure: true,
|
||||||
|
})
|
||||||
|
export class AlertRulePipe implements PipeTransform {
|
||||||
|
transform(rule: AlertRule, args?: any): AlertTime[] {
|
||||||
|
return rule.getTimes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'alert-rule-builder',
|
selector: 'alert-rule-builder',
|
||||||
imports: [],
|
imports: [MatTableModule, AlertRulePipe],
|
||||||
templateUrl: './alert-rule-builder.component.html',
|
templateUrl: './alert-rule-builder.component.html',
|
||||||
styleUrl: './alert-rule-builder.component.scss',
|
styleUrl: './alert-rule-builder.component.scss',
|
||||||
})
|
})
|
||||||
export class AlertRuleBuilderComponent {
|
export class AlertRuleBuilderComponent {
|
||||||
@Input() rules: AlertRule[] = [];
|
@Input() rules!: AlertRule[];
|
||||||
@Output() rulesChange: EventEmitter<AlertRule[]> = new EventEmitter<
|
@Output() rulesChange: EventEmitter<AlertRule[]> = new EventEmitter<
|
||||||
AlertRule[]
|
AlertRule[]
|
||||||
>();
|
>();
|
||||||
|
|
||||||
|
displayedColumns = ['time', 'duration', 'multiplier'];
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.rules = <AlertRule[]>this.rules;
|
||||||
|
}
|
||||||
|
|
||||||
emit() {
|
emit() {
|
||||||
this.rulesChange.emit(this.rules);
|
this.rulesChange.emit(this.rules);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="alert">
|
<div class="alert">
|
||||||
<alert-rule-builder [rules]="tg.alert_config" />
|
<alert-rule-builder [rules]="tg.alert_rules" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
} @else {
|
} @else {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
IconMap,
|
IconMap,
|
||||||
iconMapping,
|
iconMapping,
|
||||||
TGID,
|
TGID,
|
||||||
|
AlertRule,
|
||||||
} from '../../talkgroup';
|
} from '../../talkgroup';
|
||||||
import { COMMA, ENTER } from '@angular/cdk/keycodes';
|
import { COMMA, ENTER } from '@angular/cdk/keycodes';
|
||||||
import { TalkgroupService } from '../talkgroups.service';
|
import { TalkgroupService } from '../talkgroups.service';
|
||||||
|
@ -157,6 +158,10 @@ export class TalkgroupRecordComponent {
|
||||||
.getTalkgroup(Number(this.tgid.sys), Number(this.tgid.tg))
|
.getTalkgroup(Number(this.tgid.sys), Number(this.tgid.tg))
|
||||||
.pipe(
|
.pipe(
|
||||||
tap((tg) => {
|
tap((tg) => {
|
||||||
|
console.log('tap run');
|
||||||
|
tg.alert_rules = tg.alert_rules
|
||||||
|
? tg.alert_rules.map((x) => Object.assign(new AlertRule(), x))
|
||||||
|
: [];
|
||||||
this.form.patchValue(tg);
|
this.form.patchValue(tg);
|
||||||
this.form.controls['tagInput'].setValue('');
|
this.form.controls['tagInput'].setValue('');
|
||||||
this.form.controls['tagsControl'].setValue(this.tg?.tags ?? []);
|
this.form.controls['tagsControl'].setValue(this.tg?.tags ?? []);
|
||||||
|
|
|
@ -33,7 +33,10 @@ export class TalkgroupService {
|
||||||
private subscriptions = new Subscription();
|
private subscriptions = new Subscription();
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
this.tgs$ = this.fetchAll.pipe(switchMap(() => this.getTalkgroups()));
|
this.tgs$ = this.fetchAll.pipe(switchMap(() => this.getTalkgroups()));
|
||||||
this.tags$ = this.fetchAll.pipe(switchMap(() => this.getAllTags()));
|
this.tags$ = this.fetchAll.pipe(
|
||||||
|
switchMap(() => this.getAllTags()),
|
||||||
|
shareReplay(),
|
||||||
|
);
|
||||||
this.fillTgMap();
|
this.fillTgMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,11 +55,8 @@ export class TalkgroupService {
|
||||||
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
|
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
|
||||||
const key = this.tgKey(sys, tg);
|
const key = this.tgKey(sys, tg);
|
||||||
if (!this._getTalkgroup.get(key)) {
|
if (!this._getTalkgroup.get(key)) {
|
||||||
return this.tgs$.pipe(
|
let rs = new ReplaySubject<Talkgroup>();
|
||||||
switchMap((talkg) =>
|
this._getTalkgroup.set(key, rs);
|
||||||
talkg.filter((tgv) => tgv.tgid == tg && tgv.system_id == sys),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return this._getTalkgroup.get(key)!;
|
return this._getTalkgroup.get(key)!;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAlertConfig(t *testing.T) {
|
func TestAlertRules(t *testing.T) {
|
||||||
parseTests := []struct {
|
parseTests := []struct {
|
||||||
name string
|
name string
|
||||||
tg talkgroups.ID
|
tg talkgroups.ID
|
||||||
|
|
|
@ -245,6 +245,7 @@ func (a *Auth) routeAuth(w http.ResponseWriter, r *http.Request) {
|
||||||
Path: "/",
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: true,
|
Secure: true,
|
||||||
|
MaxAge: 60 * 60 * 24 * 30, // one month
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie.Domain = r.Host
|
cookie.Domain = r.Host
|
||||||
|
|
|
@ -30,7 +30,7 @@ INSERT INTO talkgroup_versions(time, created_by,
|
||||||
metadata,
|
metadata,
|
||||||
tags,
|
tags,
|
||||||
alert,
|
alert,
|
||||||
alert_config,
|
alert_rules,
|
||||||
weight,
|
weight,
|
||||||
learned
|
learned
|
||||||
) SELECT NOW(), $1,
|
) SELECT NOW(), $1,
|
||||||
|
@ -43,7 +43,7 @@ INSERT INTO talkgroup_versions(time, created_by,
|
||||||
tg.metadata,
|
tg.metadata,
|
||||||
tg.tags,
|
tg.tags,
|
||||||
tg.alert,
|
tg.alert,
|
||||||
tg.alert_config,
|
tg.alert_rules,
|
||||||
tg.weight,
|
tg.weight,
|
||||||
tg.learned
|
tg.learned
|
||||||
FROM talkgroups tg WHERE tg.system_id = $2 AND tg.tgid = $3
|
FROM talkgroups tg WHERE tg.system_id = $2 AND tg.tgid = $3
|
||||||
|
@ -98,7 +98,7 @@ func (b *StoreTGVersionBatchResults) Close() error {
|
||||||
|
|
||||||
const upsertTalkgroup = `-- name: UpsertTalkgroup :batchone
|
const upsertTalkgroup = `-- name: UpsertTalkgroup :batchone
|
||||||
INSERT INTO talkgroups AS tg (
|
INSERT INTO talkgroups AS tg (
|
||||||
system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_config, weight, learned
|
system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_rules, weight, learned
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1,
|
$1,
|
||||||
$2,
|
$2,
|
||||||
|
@ -122,10 +122,10 @@ SET
|
||||||
metadata = COALESCE($7, tg.metadata),
|
metadata = COALESCE($7, tg.metadata),
|
||||||
tags = COALESCE($8, tg.tags),
|
tags = COALESCE($8, tg.tags),
|
||||||
alert = COALESCE($9, tg.alert),
|
alert = COALESCE($9, tg.alert),
|
||||||
alert_config = COALESCE($10, tg.alert_config),
|
alert_rules = COALESCE($10, tg.alert_rules),
|
||||||
weight = COALESCE($11, tg.weight),
|
weight = COALESCE($11, tg.weight),
|
||||||
learned = COALESCE($12, tg.learned)
|
learned = COALESCE($12, tg.learned)
|
||||||
RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_config, weight, learned, ignored
|
RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_rules, weight, learned, ignored
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpsertTalkgroupBatchResults struct {
|
type UpsertTalkgroupBatchResults struct {
|
||||||
|
@ -144,7 +144,7 @@ type UpsertTalkgroupParams struct {
|
||||||
Metadata jsontypes.Metadata `json:"metadata"`
|
Metadata jsontypes.Metadata `json:"metadata"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
Alert interface{} `json:"alert"`
|
Alert interface{} `json:"alert"`
|
||||||
AlertConfig rules.AlertRules `json:"alert_config"`
|
AlertRules rules.AlertRules `json:"alert_rules"`
|
||||||
Weight pgtype.Numeric `json:"weight"`
|
Weight pgtype.Numeric `json:"weight"`
|
||||||
Learned *bool `json:"learned"`
|
Learned *bool `json:"learned"`
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ func (q *Queries) UpsertTalkgroup(ctx context.Context, arg []UpsertTalkgroupPara
|
||||||
a.Metadata,
|
a.Metadata,
|
||||||
a.Tags,
|
a.Tags,
|
||||||
a.Alert,
|
a.Alert,
|
||||||
a.AlertConfig,
|
a.AlertRules,
|
||||||
a.Weight,
|
a.Weight,
|
||||||
a.Learned,
|
a.Learned,
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ func (b *UpsertTalkgroupBatchResults) QueryRow(f func(int, Talkgroup, error)) {
|
||||||
&i.Metadata,
|
&i.Metadata,
|
||||||
&i.Tags,
|
&i.Tags,
|
||||||
&i.Alert,
|
&i.Alert,
|
||||||
&i.AlertConfig,
|
&i.AlertRules,
|
||||||
&i.Weight,
|
&i.Weight,
|
||||||
&i.Learned,
|
&i.Learned,
|
||||||
&i.Ignored,
|
&i.Ignored,
|
||||||
|
|
|
@ -180,6 +180,7 @@ FROM incidents_calls ic, LATERAL (
|
||||||
FROM swept_calls sc WHERE sc.id = ic.swept_call_id
|
FROM swept_calls sc WHERE sc.id = ic.swept_call_id
|
||||||
) c
|
) c
|
||||||
WHERE ic.incident_id = $1
|
WHERE ic.incident_id = $1
|
||||||
|
ORDER BY ic.call_date ASC
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetIncidentCallsRow struct {
|
type GetIncidentCallsRow struct {
|
||||||
|
|
|
@ -117,7 +117,7 @@ type Talkgroup struct {
|
||||||
Metadata jsontypes.Metadata `json:"metadata,omitempty"`
|
Metadata jsontypes.Metadata `json:"metadata,omitempty"`
|
||||||
Tags []string `json:"tags,omitempty"`
|
Tags []string `json:"tags,omitempty"`
|
||||||
Alert bool `json:"alert,omitempty"`
|
Alert bool `json:"alert,omitempty"`
|
||||||
AlertConfig rules.AlertRules `json:"alert_config,omitempty"`
|
AlertRules rules.AlertRules `json:"alert_rules,omitempty"`
|
||||||
Weight float32 `json:"weight,omitempty"`
|
Weight float32 `json:"weight,omitempty"`
|
||||||
Learned bool `json:"learned,omitempty"`
|
Learned bool `json:"learned,omitempty"`
|
||||||
Ignored bool `json:"ignored,omitempty"`
|
Ignored bool `json:"ignored,omitempty"`
|
||||||
|
@ -137,7 +137,7 @@ type TalkgroupVersion struct {
|
||||||
Metadata []byte `json:"metadata,omitempty"`
|
Metadata []byte `json:"metadata,omitempty"`
|
||||||
Tags []string `json:"tags,omitempty"`
|
Tags []string `json:"tags,omitempty"`
|
||||||
Alert *bool `json:"alert,omitempty"`
|
Alert *bool `json:"alert,omitempty"`
|
||||||
AlertConfig []byte `json:"alert_config,omitempty"`
|
AlertRules []byte `json:"alert_rules,omitempty"`
|
||||||
Weight *float32 `json:"weight,omitempty"`
|
Weight *float32 `json:"weight,omitempty"`
|
||||||
Learned *bool `json:"learned,omitempty"`
|
Learned *bool `json:"learned,omitempty"`
|
||||||
Ignored *bool `json:"ignored,omitempty"`
|
Ignored *bool `json:"ignored,omitempty"`
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (t *TGTuples) Append(sys, tg uint32) {
|
||||||
// Below queries are here because sqlc refuses to parse unnest(x, y)
|
// Below queries are here because sqlc refuses to parse unnest(x, y)
|
||||||
|
|
||||||
const getTalkgroupsWithLearnedBySysTGID = `SELECT
|
const getTalkgroupsWithLearnedBySysTGID = `SELECT
|
||||||
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_config, tg.weight, sys.id, sys.name, tg.learned, tg.ignored
|
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_rules, tg.weight, sys.id, sys.name, tg.learned, tg.ignored
|
||||||
FROM talkgroups tg
|
FROM talkgroups tg
|
||||||
JOIN systems sys ON tg.system_id = sys.id
|
JOIN systems sys ON tg.system_id = sys.id
|
||||||
JOIN UNNEST($1::INT4[], $2::INT4[]) AS tgt(sys, tg) ON (tg.system_id = tgt.sys AND tg.tgid = tgt.tg);`
|
JOIN UNNEST($1::INT4[], $2::INT4[]) AS tgt(sys, tg) ON (tg.system_id = tgt.sys AND tg.tgid = tgt.tg);`
|
||||||
|
@ -82,7 +82,7 @@ func (q *Queries) GetTalkgroupsWithLearnedBySysTGID(ctx context.Context, ids TGT
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.System.ID,
|
&i.System.ID,
|
||||||
&i.System.Name,
|
&i.System.Name,
|
||||||
|
@ -99,7 +99,7 @@ func (q *Queries) GetTalkgroupsWithLearnedBySysTGID(ctx context.Context, ids TGT
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTalkgroupsBySysTGID = `SELECT tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_config, tg.weight, tg.learned, tg.ignored, sys.id, sys.name FROM talkgroups tg
|
const getTalkgroupsBySysTGID = `SELECT tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_rules, tg.weight, tg.learned, tg.ignored, sys.id, sys.name FROM talkgroups tg
|
||||||
JOIN systems sys ON tg.system_id = sys.id
|
JOIN systems sys ON tg.system_id = sys.id
|
||||||
JOIN UNNEST($1::INT4[], $2::INT4[]) AS tgt(sys, tg) ON (tg.system_id = tgt.sys AND tg.tgid = tgt.tg)
|
JOIN UNNEST($1::INT4[], $2::INT4[]) AS tgt(sys, tg) ON (tg.system_id = tgt.sys AND tg.tgid = tgt.tg)
|
||||||
WHERE tg.learned IS NOT TRUE;`
|
WHERE tg.learned IS NOT TRUE;`
|
||||||
|
@ -124,7 +124,7 @@ func (q *Queries) GetTalkgroupsBySysTGID(ctx context.Context, ids TGTuples) ([]G
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
|
|
@ -27,7 +27,7 @@ INSERT INTO talkgroups(
|
||||||
$3,
|
$3,
|
||||||
$4,
|
$4,
|
||||||
$5
|
$5
|
||||||
) RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_config, weight, learned, ignored
|
) RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_rules, weight, learned, ignored
|
||||||
`
|
`
|
||||||
|
|
||||||
type AddLearnedTalkgroupParams struct {
|
type AddLearnedTalkgroupParams struct {
|
||||||
|
@ -58,7 +58,7 @@ func (q *Queries) AddLearnedTalkgroup(ctx context.Context, arg AddLearnedTalkgro
|
||||||
&i.Metadata,
|
&i.Metadata,
|
||||||
&i.Tags,
|
&i.Tags,
|
||||||
&i.Alert,
|
&i.Alert,
|
||||||
&i.AlertConfig,
|
&i.AlertRules,
|
||||||
&i.Weight,
|
&i.Weight,
|
||||||
&i.Learned,
|
&i.Learned,
|
||||||
&i.Ignored,
|
&i.Ignored,
|
||||||
|
@ -129,7 +129,7 @@ func (q *Queries) GetSystemName(ctx context.Context, systemID int) (string, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTalkgroup = `-- name: GetTalkgroup :one
|
const getTalkgroup = `-- name: GetTalkgroup :one
|
||||||
SELECT talkgroups.id, talkgroups.system_id, talkgroups.tgid, talkgroups.name, talkgroups.alpha_tag, talkgroups.tg_group, talkgroups.frequency, talkgroups.metadata, talkgroups.tags, talkgroups.alert, talkgroups.alert_config, talkgroups.weight, talkgroups.learned, talkgroups.ignored FROM talkgroups
|
SELECT talkgroups.id, talkgroups.system_id, talkgroups.tgid, talkgroups.name, talkgroups.alpha_tag, talkgroups.tg_group, talkgroups.frequency, talkgroups.metadata, talkgroups.tags, talkgroups.alert, talkgroups.alert_rules, talkgroups.weight, talkgroups.learned, talkgroups.ignored FROM talkgroups
|
||||||
WHERE (system_id, tgid) = ($1, $2)
|
WHERE (system_id, tgid) = ($1, $2)
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ func (q *Queries) GetTalkgroup(ctx context.Context, systemID int32, tGID int32)
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -205,7 +205,7 @@ func (q *Queries) GetTalkgroupTags(ctx context.Context, systemID int32, tGID int
|
||||||
|
|
||||||
const getTalkgroupWithLearned = `-- name: GetTalkgroupWithLearned :one
|
const getTalkgroupWithLearned = `-- name: GetTalkgroupWithLearned :one
|
||||||
SELECT
|
SELECT
|
||||||
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_config, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_rules, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
||||||
FROM talkgroups tg
|
FROM talkgroups tg
|
||||||
JOIN systems sys ON tg.system_id = sys.id
|
JOIN systems sys ON tg.system_id = sys.id
|
||||||
WHERE (tg.system_id, tg.tgid) = ($1, $2)
|
WHERE (tg.system_id, tg.tgid) = ($1, $2)
|
||||||
|
@ -230,7 +230,7 @@ func (q *Queries) GetTalkgroupWithLearned(ctx context.Context, systemID int32, t
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -241,7 +241,7 @@ func (q *Queries) GetTalkgroupWithLearned(ctx context.Context, systemID int32, t
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTalkgroupsWithAllTags = `-- name: GetTalkgroupsWithAllTags :many
|
const getTalkgroupsWithAllTags = `-- name: GetTalkgroupsWithAllTags :many
|
||||||
SELECT talkgroups.id, talkgroups.system_id, talkgroups.tgid, talkgroups.name, talkgroups.alpha_tag, talkgroups.tg_group, talkgroups.frequency, talkgroups.metadata, talkgroups.tags, talkgroups.alert, talkgroups.alert_config, talkgroups.weight, talkgroups.learned, talkgroups.ignored FROM talkgroups
|
SELECT talkgroups.id, talkgroups.system_id, talkgroups.tgid, talkgroups.name, talkgroups.alpha_tag, talkgroups.tg_group, talkgroups.frequency, talkgroups.metadata, talkgroups.tags, talkgroups.alert, talkgroups.alert_rules, talkgroups.weight, talkgroups.learned, talkgroups.ignored FROM talkgroups
|
||||||
WHERE tags && ARRAY[$1]
|
WHERE tags && ARRAY[$1]
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ func (q *Queries) GetTalkgroupsWithAllTags(ctx context.Context, tags []string) (
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -285,7 +285,7 @@ func (q *Queries) GetTalkgroupsWithAllTags(ctx context.Context, tags []string) (
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTalkgroupsWithAnyTags = `-- name: GetTalkgroupsWithAnyTags :many
|
const getTalkgroupsWithAnyTags = `-- name: GetTalkgroupsWithAnyTags :many
|
||||||
SELECT talkgroups.id, talkgroups.system_id, talkgroups.tgid, talkgroups.name, talkgroups.alpha_tag, talkgroups.tg_group, talkgroups.frequency, talkgroups.metadata, talkgroups.tags, talkgroups.alert, talkgroups.alert_config, talkgroups.weight, talkgroups.learned, talkgroups.ignored FROM talkgroups
|
SELECT talkgroups.id, talkgroups.system_id, talkgroups.tgid, talkgroups.name, talkgroups.alpha_tag, talkgroups.tg_group, talkgroups.frequency, talkgroups.metadata, talkgroups.tags, talkgroups.alert, talkgroups.alert_rules, talkgroups.weight, talkgroups.learned, talkgroups.ignored FROM talkgroups
|
||||||
WHERE tags @> ARRAY[$1]
|
WHERE tags @> ARRAY[$1]
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ func (q *Queries) GetTalkgroupsWithAnyTags(ctx context.Context, tags []string) (
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -330,7 +330,7 @@ func (q *Queries) GetTalkgroupsWithAnyTags(ctx context.Context, tags []string) (
|
||||||
|
|
||||||
const getTalkgroupsWithLearned = `-- name: GetTalkgroupsWithLearned :many
|
const getTalkgroupsWithLearned = `-- name: GetTalkgroupsWithLearned :many
|
||||||
SELECT
|
SELECT
|
||||||
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_config, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_rules, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
||||||
FROM talkgroups tg
|
FROM talkgroups tg
|
||||||
JOIN systems sys ON tg.system_id = sys.id
|
JOIN systems sys ON tg.system_id = sys.id
|
||||||
WHERE ignored IS NOT TRUE
|
WHERE ignored IS NOT TRUE
|
||||||
|
@ -361,7 +361,7 @@ func (q *Queries) GetTalkgroupsWithLearned(ctx context.Context) ([]GetTalkgroups
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -380,7 +380,7 @@ func (q *Queries) GetTalkgroupsWithLearned(ctx context.Context) ([]GetTalkgroups
|
||||||
|
|
||||||
const getTalkgroupsWithLearnedBySystem = `-- name: GetTalkgroupsWithLearnedBySystem :many
|
const getTalkgroupsWithLearnedBySystem = `-- name: GetTalkgroupsWithLearnedBySystem :many
|
||||||
SELECT
|
SELECT
|
||||||
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_config, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_rules, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
||||||
FROM talkgroups tg
|
FROM talkgroups tg
|
||||||
JOIN systems sys ON tg.system_id = sys.id
|
JOIN systems sys ON tg.system_id = sys.id
|
||||||
WHERE tg.system_id = $1
|
WHERE tg.system_id = $1
|
||||||
|
@ -411,7 +411,7 @@ func (q *Queries) GetTalkgroupsWithLearnedBySystem(ctx context.Context, system i
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -448,7 +448,7 @@ func (q *Queries) GetTalkgroupsWithLearnedBySystemCount(ctx context.Context, sys
|
||||||
|
|
||||||
const getTalkgroupsWithLearnedBySystemP = `-- name: GetTalkgroupsWithLearnedBySystemP :many
|
const getTalkgroupsWithLearnedBySystemP = `-- name: GetTalkgroupsWithLearnedBySystemP :many
|
||||||
SELECT
|
SELECT
|
||||||
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_config, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_rules, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
||||||
FROM talkgroups tg
|
FROM talkgroups tg
|
||||||
JOIN systems sys ON tg.system_id = sys.id
|
JOIN systems sys ON tg.system_id = sys.id
|
||||||
WHERE tg.system_id = $1 AND
|
WHERE tg.system_id = $1 AND
|
||||||
|
@ -512,7 +512,7 @@ func (q *Queries) GetTalkgroupsWithLearnedBySystemP(ctx context.Context, arg Get
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -549,7 +549,7 @@ func (q *Queries) GetTalkgroupsWithLearnedCount(ctx context.Context, filter *str
|
||||||
|
|
||||||
const getTalkgroupsWithLearnedP = `-- name: GetTalkgroupsWithLearnedP :many
|
const getTalkgroupsWithLearnedP = `-- name: GetTalkgroupsWithLearnedP :many
|
||||||
SELECT
|
SELECT
|
||||||
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_config, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
tg.id, tg.system_id, tg.tgid, tg.name, tg.alpha_tag, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alert, tg.alert_rules, tg.weight, tg.learned, tg.ignored, sys.id, sys.name
|
||||||
FROM talkgroups tg
|
FROM talkgroups tg
|
||||||
JOIN systems sys ON tg.system_id = sys.id
|
JOIN systems sys ON tg.system_id = sys.id
|
||||||
WHERE ignored IS NOT TRUE AND
|
WHERE ignored IS NOT TRUE AND
|
||||||
|
@ -611,7 +611,7 @@ func (q *Queries) GetTalkgroupsWithLearnedP(ctx context.Context, arg GetTalkgrou
|
||||||
&i.Talkgroup.Metadata,
|
&i.Talkgroup.Metadata,
|
||||||
&i.Talkgroup.Tags,
|
&i.Talkgroup.Tags,
|
||||||
&i.Talkgroup.Alert,
|
&i.Talkgroup.Alert,
|
||||||
&i.Talkgroup.AlertConfig,
|
&i.Talkgroup.AlertRules,
|
||||||
&i.Talkgroup.Weight,
|
&i.Talkgroup.Weight,
|
||||||
&i.Talkgroup.Learned,
|
&i.Talkgroup.Learned,
|
||||||
&i.Talkgroup.Ignored,
|
&i.Talkgroup.Ignored,
|
||||||
|
@ -639,7 +639,7 @@ INSERT INTO talkgroups(
|
||||||
metadata,
|
metadata,
|
||||||
tags,
|
tags,
|
||||||
alert,
|
alert,
|
||||||
alert_config,
|
alert_rules,
|
||||||
weight,
|
weight,
|
||||||
learned,
|
learned,
|
||||||
ignored
|
ignored
|
||||||
|
@ -654,7 +654,7 @@ SELECT
|
||||||
metadata,
|
metadata,
|
||||||
tags,
|
tags,
|
||||||
alert,
|
alert,
|
||||||
alert_config,
|
alert_rules,
|
||||||
weight,
|
weight,
|
||||||
learned,
|
learned,
|
||||||
ignored
|
ignored
|
||||||
|
@ -665,12 +665,12 @@ FROM talkgroup_versions tgv ON CONFLICT (system_id, tgid) DO UPDATE SET
|
||||||
metadata = excluded.metadata,
|
metadata = excluded.metadata,
|
||||||
tags = excluded.tags,
|
tags = excluded.tags,
|
||||||
alert = excluded.alert,
|
alert = excluded.alert,
|
||||||
alert_config = excluded.alert_config,
|
alert_rules = excluded.alert_rules,
|
||||||
weight = excluded.weight,
|
weight = excluded.weight,
|
||||||
learned = excluded.learner,
|
learned = excluded.learner,
|
||||||
ignored = excluded.ignored
|
ignored = excluded.ignored
|
||||||
WHERE tgv.id = ANY($1)
|
WHERE tgv.id = ANY($1)
|
||||||
RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_config, weight, learned, ignored
|
RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_rules, weight, learned, ignored
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) RestoreTalkgroupVersion(ctx context.Context, versionIds int) (Talkgroup, error) {
|
func (q *Queries) RestoreTalkgroupVersion(ctx context.Context, versionIds int) (Talkgroup, error) {
|
||||||
|
@ -687,7 +687,7 @@ func (q *Queries) RestoreTalkgroupVersion(ctx context.Context, versionIds int) (
|
||||||
&i.Metadata,
|
&i.Metadata,
|
||||||
&i.Tags,
|
&i.Tags,
|
||||||
&i.Alert,
|
&i.Alert,
|
||||||
&i.AlertConfig,
|
&i.AlertRules,
|
||||||
&i.Weight,
|
&i.Weight,
|
||||||
&i.Learned,
|
&i.Learned,
|
||||||
&i.Ignored,
|
&i.Ignored,
|
||||||
|
@ -730,11 +730,11 @@ SET
|
||||||
metadata = COALESCE($5, metadata),
|
metadata = COALESCE($5, metadata),
|
||||||
tags = COALESCE($6, tags),
|
tags = COALESCE($6, tags),
|
||||||
alert = COALESCE($7, alert),
|
alert = COALESCE($7, alert),
|
||||||
alert_config = COALESCE($8, alert_config),
|
alert_rules = COALESCE($8, alert_rules),
|
||||||
weight = COALESCE($9, weight),
|
weight = COALESCE($9, weight),
|
||||||
learned = COALESCE($10, learned)
|
learned = COALESCE($10, learned)
|
||||||
WHERE id = $11 OR (system_id = $12 AND tgid = $13)
|
WHERE id = $11 OR (system_id = $12 AND tgid = $13)
|
||||||
RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_config, weight, learned, ignored
|
RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_rules, weight, learned, ignored
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdateTalkgroupParams struct {
|
type UpdateTalkgroupParams struct {
|
||||||
|
@ -745,7 +745,7 @@ type UpdateTalkgroupParams struct {
|
||||||
Metadata jsontypes.Metadata `json:"metadata"`
|
Metadata jsontypes.Metadata `json:"metadata"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
Alert *bool `json:"alert"`
|
Alert *bool `json:"alert"`
|
||||||
AlertConfig rules.AlertRules `json:"alert_config"`
|
AlertRules rules.AlertRules `json:"alert_rules"`
|
||||||
Weight *float32 `json:"weight"`
|
Weight *float32 `json:"weight"`
|
||||||
Learned *bool `json:"learned"`
|
Learned *bool `json:"learned"`
|
||||||
ID *int32 `json:"id"`
|
ID *int32 `json:"id"`
|
||||||
|
@ -762,7 +762,7 @@ func (q *Queries) UpdateTalkgroup(ctx context.Context, arg UpdateTalkgroupParams
|
||||||
arg.Metadata,
|
arg.Metadata,
|
||||||
arg.Tags,
|
arg.Tags,
|
||||||
arg.Alert,
|
arg.Alert,
|
||||||
arg.AlertConfig,
|
arg.AlertRules,
|
||||||
arg.Weight,
|
arg.Weight,
|
||||||
arg.Learned,
|
arg.Learned,
|
||||||
arg.ID,
|
arg.ID,
|
||||||
|
@ -781,7 +781,7 @@ func (q *Queries) UpdateTalkgroup(ctx context.Context, arg UpdateTalkgroupParams
|
||||||
&i.Metadata,
|
&i.Metadata,
|
||||||
&i.Tags,
|
&i.Tags,
|
||||||
&i.Alert,
|
&i.Alert,
|
||||||
&i.AlertConfig,
|
&i.AlertRules,
|
||||||
&i.Weight,
|
&i.Weight,
|
||||||
&i.Learned,
|
&i.Learned,
|
||||||
&i.Ignored,
|
&i.Ignored,
|
||||||
|
|
|
@ -202,7 +202,7 @@ func (ia *incidentsAPI) getCallsM3U(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var b bytes.Buffer
|
b := new(bytes.Buffer)
|
||||||
|
|
||||||
callUrl := common.PtrTo(*ia.baseURL)
|
callUrl := common.PtrTo(*ia.baseURL)
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ func (ia *incidentsAPI) getCallsM3U(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
callUrl.Path = "/api/call/" + c.ID.String()
|
callUrl.Path = "/api/call/" + c.ID.String()
|
||||||
|
|
||||||
fmt.Fprintf(w, "#EXTINF:%d,%s%s (%s)\n%s\n\n",
|
fmt.Fprintf(b, "#EXTINF:%d,%s%s (%s)\n%s\n\n",
|
||||||
c.Duration.Seconds(),
|
c.Duration.Seconds(),
|
||||||
tg.StringTag(true),
|
tg.StringTag(true),
|
||||||
from,
|
from,
|
||||||
|
|
|
@ -414,7 +414,7 @@ func (t *cache) Weight(ctx context.Context, id tgsp.ID, tm time.Time) float64 {
|
||||||
|
|
||||||
m := float64(tg.Weight)
|
m := float64(tg.Weight)
|
||||||
|
|
||||||
m *= tg.AlertConfig.Apply(tm)
|
m *= tg.AlertRules.Apply(tm)
|
||||||
|
|
||||||
return float64(m)
|
return float64(m)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS talkgroups(
|
||||||
metadata JSONB,
|
metadata JSONB,
|
||||||
tags TEXT[] NOT NULL DEFAULT '{}',
|
tags TEXT[] NOT NULL DEFAULT '{}',
|
||||||
alert BOOLEAN NOT NULL DEFAULT 'true',
|
alert BOOLEAN NOT NULL DEFAULT 'true',
|
||||||
alert_config JSONB,
|
alert_rules JSONB,
|
||||||
weight REAL NOT NULL DEFAULT 1.0,
|
weight REAL NOT NULL DEFAULT 1.0,
|
||||||
learned BOOLEAN NOT NULL DEFAULT FALSE,
|
learned BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
ignored BOOLEAN NOT NULL DEFAULT FALSE,
|
ignored BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS talkgroup_versions(
|
||||||
metadata JSONB,
|
metadata JSONB,
|
||||||
tags TEXT[],
|
tags TEXT[],
|
||||||
alert BOOLEAN,
|
alert BOOLEAN,
|
||||||
alert_config JSONB,
|
alert_rules JSONB,
|
||||||
weight REAL,
|
weight REAL,
|
||||||
learned BOOLEAN,
|
learned BOOLEAN,
|
||||||
ignored BOOLEAN
|
ignored BOOLEAN
|
||||||
|
|
|
@ -141,7 +141,8 @@ FROM incidents_calls ic, LATERAL (
|
||||||
sc.transcript
|
sc.transcript
|
||||||
FROM swept_calls sc WHERE sc.id = ic.swept_call_id
|
FROM swept_calls sc WHERE sc.id = ic.swept_call_id
|
||||||
) c
|
) c
|
||||||
WHERE ic.incident_id = @id;
|
WHERE ic.incident_id = @id
|
||||||
|
ORDER BY ic.call_date ASC;
|
||||||
|
|
||||||
-- name: GetIncident :one
|
-- name: GetIncident :one
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -137,7 +137,7 @@ SET
|
||||||
metadata = COALESCE(sqlc.narg('metadata'), metadata),
|
metadata = COALESCE(sqlc.narg('metadata'), metadata),
|
||||||
tags = COALESCE(sqlc.narg('tags'), tags),
|
tags = COALESCE(sqlc.narg('tags'), tags),
|
||||||
alert = COALESCE(sqlc.narg('alert'), alert),
|
alert = COALESCE(sqlc.narg('alert'), alert),
|
||||||
alert_config = COALESCE(sqlc.narg('alert_config'), alert_config),
|
alert_rules = COALESCE(sqlc.narg('alert_rules'), alert_rules),
|
||||||
weight = COALESCE(sqlc.narg('weight'), weight),
|
weight = COALESCE(sqlc.narg('weight'), weight),
|
||||||
learned = COALESCE(sqlc.narg('learned'), learned)
|
learned = COALESCE(sqlc.narg('learned'), learned)
|
||||||
WHERE id = sqlc.narg('id') OR (system_id = sqlc.narg('system_id') AND tgid = sqlc.narg('tgid'))
|
WHERE id = sqlc.narg('id') OR (system_id = sqlc.narg('system_id') AND tgid = sqlc.narg('tgid'))
|
||||||
|
@ -145,7 +145,7 @@ RETURNING *;
|
||||||
|
|
||||||
-- name: UpsertTalkgroup :batchone
|
-- name: UpsertTalkgroup :batchone
|
||||||
INSERT INTO talkgroups AS tg (
|
INSERT INTO talkgroups AS tg (
|
||||||
system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_config, weight, learned
|
system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags, alert, alert_rules, weight, learned
|
||||||
) VALUES (
|
) VALUES (
|
||||||
@system_id,
|
@system_id,
|
||||||
@tgid,
|
@tgid,
|
||||||
|
@ -156,7 +156,7 @@ INSERT INTO talkgroups AS tg (
|
||||||
sqlc.narg('metadata'),
|
sqlc.narg('metadata'),
|
||||||
COALESCE(sqlc.narg('tags'), '{}'::text[])::text[],
|
COALESCE(sqlc.narg('tags'), '{}'::text[])::text[],
|
||||||
COALESCE(sqlc.narg('alert'), TRUE),
|
COALESCE(sqlc.narg('alert'), TRUE),
|
||||||
sqlc.narg('alert_config'),
|
sqlc.narg('alert_rules'),
|
||||||
COALESCE(sqlc.narg('weight'), 1.0)::numeric,
|
COALESCE(sqlc.narg('weight'), 1.0)::numeric,
|
||||||
COALESCE(sqlc.narg('learned'), FALSE)::boolean
|
COALESCE(sqlc.narg('learned'), FALSE)::boolean
|
||||||
)
|
)
|
||||||
|
@ -169,7 +169,7 @@ SET
|
||||||
metadata = COALESCE(sqlc.narg('metadata'), tg.metadata),
|
metadata = COALESCE(sqlc.narg('metadata'), tg.metadata),
|
||||||
tags = COALESCE(sqlc.narg('tags'), tg.tags),
|
tags = COALESCE(sqlc.narg('tags'), tg.tags),
|
||||||
alert = COALESCE(sqlc.narg('alert'), tg.alert),
|
alert = COALESCE(sqlc.narg('alert'), tg.alert),
|
||||||
alert_config = COALESCE(sqlc.narg('alert_config'), tg.alert_config),
|
alert_rules = COALESCE(sqlc.narg('alert_rules'), tg.alert_rules),
|
||||||
weight = COALESCE(sqlc.narg('weight'), tg.weight),
|
weight = COALESCE(sqlc.narg('weight'), tg.weight),
|
||||||
learned = COALESCE(sqlc.narg('learned'), tg.learned)
|
learned = COALESCE(sqlc.narg('learned'), tg.learned)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
@ -185,7 +185,7 @@ INSERT INTO talkgroup_versions(time, created_by,
|
||||||
metadata,
|
metadata,
|
||||||
tags,
|
tags,
|
||||||
alert,
|
alert,
|
||||||
alert_config,
|
alert_rules,
|
||||||
weight,
|
weight,
|
||||||
learned
|
learned
|
||||||
) SELECT NOW(), @submitter,
|
) SELECT NOW(), @submitter,
|
||||||
|
@ -198,7 +198,7 @@ INSERT INTO talkgroup_versions(time, created_by,
|
||||||
tg.metadata,
|
tg.metadata,
|
||||||
tg.tags,
|
tg.tags,
|
||||||
tg.alert,
|
tg.alert,
|
||||||
tg.alert_config,
|
tg.alert_rules,
|
||||||
tg.weight,
|
tg.weight,
|
||||||
tg.learned
|
tg.learned
|
||||||
FROM talkgroups tg WHERE tg.system_id = @system_id AND tg.tgid = @tgid;
|
FROM talkgroups tg WHERE tg.system_id = @system_id AND tg.tgid = @tgid;
|
||||||
|
@ -231,7 +231,7 @@ INSERT INTO talkgroups(
|
||||||
metadata,
|
metadata,
|
||||||
tags,
|
tags,
|
||||||
alert,
|
alert,
|
||||||
alert_config,
|
alert_rules,
|
||||||
weight,
|
weight,
|
||||||
learned,
|
learned,
|
||||||
ignored
|
ignored
|
||||||
|
@ -246,7 +246,7 @@ SELECT
|
||||||
metadata,
|
metadata,
|
||||||
tags,
|
tags,
|
||||||
alert,
|
alert,
|
||||||
alert_config,
|
alert_rules,
|
||||||
weight,
|
weight,
|
||||||
learned,
|
learned,
|
||||||
ignored
|
ignored
|
||||||
|
@ -257,7 +257,7 @@ FROM talkgroup_versions tgv ON CONFLICT (system_id, tgid) DO UPDATE SET
|
||||||
metadata = excluded.metadata,
|
metadata = excluded.metadata,
|
||||||
tags = excluded.tags,
|
tags = excluded.tags,
|
||||||
alert = excluded.alert,
|
alert = excluded.alert,
|
||||||
alert_config = excluded.alert_config,
|
alert_rules = excluded.alert_rules,
|
||||||
weight = excluded.weight,
|
weight = excluded.weight,
|
||||||
learned = excluded.learner,
|
learned = excluded.learner,
|
||||||
ignored = excluded.ignored
|
ignored = excluded.ignored
|
||||||
|
|
|
@ -27,7 +27,7 @@ sql:
|
||||||
go_type: "time.Time"
|
go_type: "time.Time"
|
||||||
- db_type: "pg_catalog.text"
|
- db_type: "pg_catalog.text"
|
||||||
go_type: "string"
|
go_type: "string"
|
||||||
- column: "talkgroups.alert_config"
|
- column: "talkgroups.alert_rules"
|
||||||
go_type:
|
go_type:
|
||||||
import: "dynatron.me/x/stillbox/pkg/alerting/rules"
|
import: "dynatron.me/x/stillbox/pkg/alerting/rules"
|
||||||
type: "AlertRules"
|
type: "AlertRules"
|
||||||
|
|
Loading…
Reference in a new issue