alpha tag

This commit is contained in:
Daniel Ponte 2024-08-23 14:28:47 -04:00
parent 692dcf98da
commit ddff9f4a6a
12 changed files with 60 additions and 40 deletions

View file

@ -47,7 +47,7 @@ type Call struct {
Talkgroup int Talkgroup int
TalkgroupGroup *string TalkgroupGroup *string
TalkgroupLabel *string TalkgroupLabel *string
TalkgroupTag *string TGAlphaTag *string
shouldStore bool shouldStore bool
} }

View file

@ -28,7 +28,7 @@ INSERT INTO calls (
frequencies, frequencies,
patches, patches,
tg_label, tg_label,
tg_tag, tg_alpha_tag,
tg_group, tg_group,
source source
) VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) ) VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
@ -49,7 +49,7 @@ type AddCallParams struct {
Frequencies []int `json:"frequencies"` Frequencies []int `json:"frequencies"`
Patches []int `json:"patches"` Patches []int `json:"patches"`
TgLabel *string `json:"tg_label"` TgLabel *string `json:"tg_label"`
TgTag *string `json:"tg_tag"` TgAlphaTag *string `json:"tg_alpha_tag"`
TgGroup *string `json:"tg_group"` TgGroup *string `json:"tg_group"`
Source int `json:"source"` Source int `json:"source"`
} }
@ -69,7 +69,7 @@ func (q *Queries) AddCall(ctx context.Context, arg AddCallParams) (uuid.UUID, er
arg.Frequencies, arg.Frequencies,
arg.Patches, arg.Patches,
arg.TgLabel, arg.TgLabel,
arg.TgTag, arg.TgAlphaTag,
arg.TgGroup, arg.TgGroup,
arg.Source, arg.Source,
) )

View file

@ -35,7 +35,7 @@ type Call struct {
Frequencies []int `json:"frequencies"` Frequencies []int `json:"frequencies"`
Patches []int `json:"patches"` Patches []int `json:"patches"`
TgLabel *string `json:"tg_label"` TgLabel *string `json:"tg_label"`
TgTag *string `json:"tg_tag"` TgAlphaTag *string `json:"tg_alpha_tag"`
TgGroup *string `json:"tg_group"` TgGroup *string `json:"tg_group"`
Source int `json:"source"` Source int `json:"source"`
Transcript *string `json:"transcript"` Transcript *string `json:"transcript"`
@ -73,6 +73,7 @@ type Talkgroup struct {
SystemID int32 `json:"system_id"` SystemID int32 `json:"system_id"`
Tgid int32 `json:"tgid"` Tgid int32 `json:"tgid"`
Name *string `json:"name"` Name *string `json:"name"`
AlphaTag *string `json:"alpha_tag"`
TgGroup *string `json:"tg_group"` TgGroup *string `json:"tg_group"`
Frequency *int32 `json:"frequency"` Frequency *int32 `json:"frequency"`
Metadata []byte `json:"metadata"` Metadata []byte `json:"metadata"`
@ -84,7 +85,7 @@ type TalkgroupsLearned struct {
SystemID int `json:"system_id"` SystemID int `json:"system_id"`
Tgid int `json:"tgid"` Tgid int `json:"tgid"`
Name string `json:"name"` Name string `json:"name"`
GroupTag *string `json:"group_tag"` AlphaTag *string `json:"alpha_tag"`
Ignored *bool `json:"ignored"` Ignored *bool `json:"ignored"`
} }

View file

@ -20,7 +20,7 @@ func (q *Queries) BulkSetTalkgroupTags(ctx context.Context, iD int64, tags []str
} }
const getTalkgroup = `-- name: GetTalkgroup :one const getTalkgroup = `-- name: GetTalkgroup :one
SELECT id, system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups SELECT id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags FROM talkgroups
WHERE id = systg2id($1, $2) WHERE id = systg2id($1, $2)
` `
@ -32,6 +32,7 @@ func (q *Queries) GetTalkgroup(ctx context.Context, systemID int, tgid int) (Tal
&i.SystemID, &i.SystemID,
&i.Tgid, &i.Tgid,
&i.Name, &i.Name,
&i.AlphaTag,
&i.TgGroup, &i.TgGroup,
&i.Frequency, &i.Frequency,
&i.Metadata, &i.Metadata,
@ -87,7 +88,7 @@ func (q *Queries) GetTalkgroupTags(ctx context.Context, sys int, tg int) ([]stri
const getTalkgroupWithLearned = `-- name: GetTalkgroupWithLearned :one const getTalkgroupWithLearned = `-- name: GetTalkgroupWithLearned :one
SELECT SELECT
tg.id, tg.system_id, sys.name system_name, tg.tgid, tg.name, tg.id, tg.system_id, sys.name system_name, tg.tgid, tg.name,
tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alpha_tag,
FALSE learned FALSE learned
FROM talkgroups tg FROM talkgroups tg
JOIN systems sys ON tg.system_id = sys.id JOIN systems sys ON tg.system_id = sys.id
@ -96,7 +97,7 @@ UNION
SELECT SELECT
tgl.id::INT8, tgl.system_id::INT4, sys.name system_name, tgl.tgid::INT4, tgl.name, tgl.id::INT8, tgl.system_id::INT4, sys.name system_name, tgl.tgid::INT4, tgl.name,
tgl.group_tag, NULL::INTEGER, NULL::JSONB, tgl.group_tag, NULL::INTEGER, NULL::JSONB,
CASE WHEN tgl.group_tag IS NULL THEN NULL ELSE ARRAY[tgl.group_tag] END, CASE WHEN tgl.group_tag IS NULL THEN NULL ELSE ARRAY[tgl.group_tag] END, tgl.alpha_tag,
TRUE learned TRUE learned
FROM talkgroups_learned tgl FROM talkgroups_learned tgl
JOIN systems sys ON tgl.system_id = sys.id JOIN systems sys ON tgl.system_id = sys.id
@ -113,6 +114,7 @@ type GetTalkgroupWithLearnedRow struct {
Frequency *int32 `json:"frequency"` Frequency *int32 `json:"frequency"`
Metadata []byte `json:"metadata"` Metadata []byte `json:"metadata"`
Tags []string `json:"tags"` Tags []string `json:"tags"`
AlphaTag *string `json:"alpha_tag"`
Learned bool `json:"learned"` Learned bool `json:"learned"`
} }
@ -129,13 +131,14 @@ func (q *Queries) GetTalkgroupWithLearned(ctx context.Context, systemID int, tgi
&i.Frequency, &i.Frequency,
&i.Metadata, &i.Metadata,
&i.Tags, &i.Tags,
&i.AlphaTag,
&i.Learned, &i.Learned,
) )
return i, err return i, err
} }
const getTalkgroupsWithAllTags = `-- name: GetTalkgroupsWithAllTags :many const getTalkgroupsWithAllTags = `-- name: GetTalkgroupsWithAllTags :many
SELECT id, system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups SELECT id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags FROM talkgroups
WHERE tags && ARRAY[$1] WHERE tags && ARRAY[$1]
` `
@ -153,6 +156,7 @@ func (q *Queries) GetTalkgroupsWithAllTags(ctx context.Context, tags []string) (
&i.SystemID, &i.SystemID,
&i.Tgid, &i.Tgid,
&i.Name, &i.Name,
&i.AlphaTag,
&i.TgGroup, &i.TgGroup,
&i.Frequency, &i.Frequency,
&i.Metadata, &i.Metadata,
@ -169,7 +173,7 @@ func (q *Queries) GetTalkgroupsWithAllTags(ctx context.Context, tags []string) (
} }
const getTalkgroupsWithAnyTags = `-- name: GetTalkgroupsWithAnyTags :many const getTalkgroupsWithAnyTags = `-- name: GetTalkgroupsWithAnyTags :many
SELECT id, system_id, tgid, name, tg_group, frequency, metadata, tags FROM talkgroups SELECT id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, tags FROM talkgroups
WHERE tags @> ARRAY[$1] WHERE tags @> ARRAY[$1]
` `
@ -187,6 +191,7 @@ func (q *Queries) GetTalkgroupsWithAnyTags(ctx context.Context, tags []string) (
&i.SystemID, &i.SystemID,
&i.Tgid, &i.Tgid,
&i.Name, &i.Name,
&i.AlphaTag,
&i.TgGroup, &i.TgGroup,
&i.Frequency, &i.Frequency,
&i.Metadata, &i.Metadata,

View file

@ -73,6 +73,7 @@ func (c *client) Talkgroup(ctx context.Context, tg *pb.Talkgroup) error {
Metadata: md, Metadata: md,
Tags: tgi.Tags, Tags: tgi.Tags,
Learned: tgi.Learned, Learned: tgi.Learned,
AlphaTag: tgi.AlphaTag,
SystemName: tgi.SystemName, SystemName: tgi.SystemName,
} }

View file

@ -52,7 +52,7 @@ func (s *DatabaseSink) toAddCallParams(call *calls.Call) database.AddCallParams
Frequencies: call.Frequencies, Frequencies: call.Frequencies,
Patches: call.Patches, Patches: call.Patches,
TgLabel: call.TalkgroupLabel, TgLabel: call.TalkgroupLabel,
TgTag: call.TalkgroupTag, TgAlphaTag: call.TGAlphaTag,
TgGroup: call.TalkgroupGroup, TgGroup: call.TalkgroupGroup,
Source: call.Source, Source: call.Source,
} }

View file

@ -87,7 +87,7 @@ func (car *callUploadRequest) toCall(submitter auth.UserID) (*calls.Call, error)
Frequencies: car.Frequencies, Frequencies: car.Frequencies,
Patches: car.Patches, Patches: car.Patches,
TalkgroupLabel: common.PtrOrNull(car.TalkgroupLabel), TalkgroupLabel: common.PtrOrNull(car.TalkgroupLabel),
TalkgroupTag: common.PtrOrNull(car.TalkgroupTag), TGAlphaTag: common.PtrOrNull(car.TalkgroupTag),
TalkgroupGroup: common.PtrOrNull(car.TalkgroupGroup), TalkgroupGroup: common.PtrOrNull(car.TalkgroupGroup),
Source: car.Source, Source: car.Source,
}, !car.DontStore) }, !car.DontStore)

View file

@ -598,10 +598,11 @@ type TalkgroupInfo struct {
SystemName string `protobuf:"bytes,2,opt,name=system_name,json=systemName,proto3" json:"system_name,omitempty"` SystemName string `protobuf:"bytes,2,opt,name=system_name,json=systemName,proto3" json:"system_name,omitempty"`
Name *string `protobuf:"bytes,3,opt,name=name,proto3,oneof" json:"name,omitempty"` Name *string `protobuf:"bytes,3,opt,name=name,proto3,oneof" json:"name,omitempty"`
Group *string `protobuf:"bytes,4,opt,name=group,proto3,oneof" json:"group,omitempty"` Group *string `protobuf:"bytes,4,opt,name=group,proto3,oneof" json:"group,omitempty"`
Frequency *int32 `protobuf:"varint,5,opt,name=frequency,proto3,oneof" json:"frequency,omitempty"` AlphaTag *string `protobuf:"bytes,5,opt,name=alpha_tag,json=alphaTag,proto3,oneof" json:"alpha_tag,omitempty"`
Tags []string `protobuf:"bytes,6,rep,name=tags,proto3" json:"tags,omitempty"` Frequency *int32 `protobuf:"varint,6,opt,name=frequency,proto3,oneof" json:"frequency,omitempty"`
Metadata *structpb.Struct `protobuf:"bytes,7,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"` Tags []string `protobuf:"bytes,7,rep,name=tags,proto3" json:"tags,omitempty"`
Learned bool `protobuf:"varint,8,opt,name=learned,proto3" json:"learned,omitempty"` Metadata *structpb.Struct `protobuf:"bytes,8,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"`
Learned bool `protobuf:"varint,9,opt,name=learned,proto3" json:"learned,omitempty"`
} }
func (x *TalkgroupInfo) Reset() { func (x *TalkgroupInfo) Reset() {
@ -664,6 +665,13 @@ func (x *TalkgroupInfo) GetGroup() string {
return "" return ""
} }
func (x *TalkgroupInfo) GetAlphaTag() string {
if x != nil && x.AlphaTag != nil {
return *x.AlphaTag
}
return ""
}
func (x *TalkgroupInfo) GetFrequency() int32 { func (x *TalkgroupInfo) GetFrequency() int32 {
if x != nil && x.Frequency != nil { if x != nil && x.Frequency != nil {
return *x.Frequency return *x.Frequency
@ -994,7 +1002,7 @@ var file_stillbox_proto_rawDesc = []byte{
0x61, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x61, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x69, 0x6c,
0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x54, 0x61, 0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x48, 0x00, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x54, 0x61, 0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x48, 0x00,
0x52, 0x09, 0x74, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x42, 0x09, 0x0a, 0x07, 0x63, 0x52, 0x09, 0x74, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x42, 0x09, 0x0a, 0x07, 0x63,
0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0xc2, 0x02, 0x0a, 0x0d, 0x54, 0x61, 0x6c, 0x6b, 0x67, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0xf2, 0x02, 0x0a, 0x0d, 0x54, 0x61, 0x6c, 0x6b, 0x67,
0x72, 0x6f, 0x75, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x23, 0x0a, 0x02, 0x74, 0x67, 0x18, 0x01, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x23, 0x0a, 0x02, 0x74, 0x67, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x62, 0x6f, 0x78, 0x2e,
0x54, 0x61, 0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x02, 0x74, 0x67, 0x12, 0x1f, 0x0a, 0x54, 0x61, 0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x02, 0x74, 0x67, 0x12, 0x1f, 0x0a,
@ -1003,16 +1011,19 @@ var file_stillbox_proto_rawDesc = []byte{
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x88, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x88,
0x01, 0x01, 0x12, 0x21, 0x0a, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x01, 0x12, 0x20, 0x0a, 0x09, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x5f, 0x74, 0x61, 0x67, 0x18,
0x05, 0x20, 0x01, 0x28, 0x05, 0x48, 0x02, 0x52, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x08, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x54, 0x61,
0x63, 0x79, 0x88, 0x01, 0x01, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x06, 0x20, 0x67, 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63,
0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x38, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x48, 0x03, 0x52, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75,
0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x65, 0x6e, 0x63, 0x79, 0x88, 0x01, 0x01, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x38, 0x0a, 0x08, 0x6d,
0x72, 0x75, 0x63, 0x74, 0x48, 0x03, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e,
0x88, 0x01, 0x01, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x08, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64, 0x42, 0x07, 0x0a, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x04, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61,
0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x74, 0x61, 0x88, 0x01, 0x01, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64,
0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x72, 0x6e, 0x65, 0x64, 0x42,
0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x67, 0x72, 0x6f,
0x75, 0x70, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x5f, 0x74, 0x61, 0x67,
0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x0b, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x0b,
0x0a, 0x09, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x7a, 0x0a, 0x04, 0x4c, 0x0a, 0x09, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x7a, 0x0a, 0x04, 0x4c,
0x69, 0x76, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x69, 0x76, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01,

View file

@ -58,10 +58,11 @@ message TalkgroupInfo {
string system_name = 2; string system_name = 2;
optional string name = 3; optional string name = 3;
optional string group = 4; optional string group = 4;
optional int32 frequency = 5; optional string alpha_tag = 5;
repeated string tags = 6; optional int32 frequency = 6;
optional google.protobuf.Struct metadata = 7; repeated string tags = 7;
bool learned = 8; optional google.protobuf.Struct metadata = 8;
bool learned = 9;
} }
enum LiveState { enum LiveState {

View file

@ -49,6 +49,7 @@ CREATE TABLE IF NOT EXISTS talkgroups(
system_id INT4 REFERENCES systems(id) NOT NULL GENERATED ALWAYS AS (id >> 32) STORED, system_id INT4 REFERENCES systems(id) NOT NULL GENERATED ALWAYS AS (id >> 32) STORED,
tgid INT4 NOT NULL GENERATED ALWAYS AS (id & x'ffffffff'::BIGINT) STORED, tgid INT4 NOT NULL GENERATED ALWAYS AS (id & x'ffffffff'::BIGINT) STORED,
name TEXT, name TEXT,
alpha_tag TEXT,
tg_group TEXT, tg_group TEXT,
frequency INTEGER, frequency INTEGER,
metadata JSONB, metadata JSONB,
@ -64,7 +65,7 @@ CREATE TABLE IF NOT EXISTS talkgroups_learned(
system_id INTEGER REFERENCES systems(id) NOT NULL, system_id INTEGER REFERENCES systems(id) NOT NULL,
tgid INTEGER NOT NULL, tgid INTEGER NOT NULL,
name TEXT NOT NULL, name TEXT NOT NULL,
group_tag TEXT, alpha_tag TEXT,
ignored BOOLEAN, ignored BOOLEAN,
UNIQUE (system_id, tgid, name) UNIQUE (system_id, tgid, name)
); );
@ -73,12 +74,12 @@ CREATE OR REPLACE FUNCTION learn_talkgroup()
RETURNS TRIGGER AS $$ RETURNS TRIGGER AS $$
BEGIN BEGIN
IF NOT EXISTS ( IF NOT EXISTS (
SELECT tg.system_id, tg.tgid, tg.name FROM talkgroups tg WHERE tg.system_id = NEW.system AND tg.tgid = NEW.talkgroup SELECT tg.system_id, tg.tgid, tg.name, tg.alpha_tag FROM talkgroups tg WHERE tg.system_id = NEW.system AND tg.tgid = NEW.talkgroup
UNION UNION
SELECT tgl.system_id, tgl.tgid, tgl.name FROM talkgroups_learned tgl WHERE tgl.system_id = NEW.system AND tgl.tgid = NEW.talkgroup SELECT tgl.system_id, tgl.tgid, tgl.name, tg.alpha_tag FROM talkgroups_learned tgl WHERE tgl.system_id = NEW.system AND tgl.tgid = NEW.talkgroup
) THEN ) THEN
INSERT INTO talkgroups_learned(system_id, tgid, name, group_tag) VALUES( INSERT INTO talkgroups_learned(system_id, tgid, name, group_tag) VALUES(
NEW.system, NEW.talkgroup, NEW.tg_label, NEW.tg_tag NEW.system, NEW.talkgroup, NEW.tg_label, NEW.alpha_tag
) ON CONFLICT DO NOTHING; ) ON CONFLICT DO NOTHING;
END IF; END IF;
RETURN NEW; RETURN NEW;
@ -100,7 +101,7 @@ CREATE TABLE IF NOT EXISTS calls(
frequencies INTEGER[], frequencies INTEGER[],
patches INTEGER[], patches INTEGER[],
tg_label TEXT, tg_label TEXT,
tg_tag TEXT, tg_alpha_tag TEXT,
tg_group TEXT, tg_group TEXT,
source INTEGER NOT NULL, source INTEGER NOT NULL,
transcript TEXT transcript TEXT

View file

@ -14,7 +14,7 @@ INSERT INTO calls (
frequencies, frequencies,
patches, patches,
tg_label, tg_label,
tg_tag, tg_alpha_tag,
tg_group, tg_group,
source source
) VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) ) VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)

View file

@ -31,7 +31,7 @@ WHERE id = systg2id(sqlc.arg(system_id), sqlc.arg(tgid));
-- name: GetTalkgroupWithLearned :one -- name: GetTalkgroupWithLearned :one
SELECT SELECT
tg.id, tg.system_id, sys.name system_name, tg.tgid, tg.name, tg.id, tg.system_id, sys.name system_name, tg.tgid, tg.name,
tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.tg_group, tg.frequency, tg.metadata, tg.tags, tg.alpha_tag,
FALSE learned FALSE learned
FROM talkgroups tg FROM talkgroups tg
JOIN systems sys ON tg.system_id = sys.id JOIN systems sys ON tg.system_id = sys.id
@ -40,7 +40,7 @@ UNION
SELECT SELECT
tgl.id::INT8, tgl.system_id::INT4, sys.name system_name, tgl.tgid::INT4, tgl.name, tgl.id::INT8, tgl.system_id::INT4, sys.name system_name, tgl.tgid::INT4, tgl.name,
tgl.group_tag, NULL::INTEGER, NULL::JSONB, tgl.group_tag, NULL::INTEGER, NULL::JSONB,
CASE WHEN tgl.group_tag IS NULL THEN NULL ELSE ARRAY[tgl.group_tag] END, CASE WHEN tgl.group_tag IS NULL THEN NULL ELSE ARRAY[tgl.group_tag] END, tgl.alpha_tag,
TRUE learned TRUE learned
FROM talkgroups_learned tgl FROM talkgroups_learned tgl
JOIN systems sys ON tgl.system_id = sys.id JOIN systems sys ON tgl.system_id = sys.id