parent
c4df60a89a
commit
3f133e152a
7 changed files with 134 additions and 85 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"dynatron.me/x/stillbox/pkg/pb"
|
"dynatron.me/x/stillbox/pkg/pb"
|
||||||
"dynatron.me/x/stillbox/pkg/talkgroups"
|
"dynatron.me/x/stillbox/pkg/talkgroups"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ func (d CallDuration) Seconds() int32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Call struct {
|
type Call struct {
|
||||||
|
ID uuid.UUID
|
||||||
Audio []byte
|
Audio []byte
|
||||||
AudioName string
|
AudioName string
|
||||||
AudioType string
|
AudioType string
|
||||||
|
@ -68,6 +70,7 @@ func Make(call *Call, dontStore bool) (*Call, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
call.shouldStore = dontStore
|
call.shouldStore = dontStore
|
||||||
|
call.ID = uuid.New()
|
||||||
|
|
||||||
return call, nil
|
return call, nil
|
||||||
}
|
}
|
||||||
|
@ -92,6 +95,7 @@ func toInt32Slice(s []int) []int32 {
|
||||||
|
|
||||||
func (c *Call) ToPB() *pb.Call {
|
func (c *Call) ToPB() *pb.Call {
|
||||||
return &pb.Call{
|
return &pb.Call{
|
||||||
|
Id: c.ID.String(),
|
||||||
AudioName: c.AudioName,
|
AudioName: c.AudioName,
|
||||||
AudioType: c.AudioType,
|
AudioType: c.AudioType,
|
||||||
DateTime: timestamppb.New(c.DateTime),
|
DateTime: timestamppb.New(c.DateTime),
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (q *Queries) AddAlert(ctx context.Context, arg AddAlertParams) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
const addCall = `-- name: AddCall :one
|
const addCall = `-- name: AddCall :exec
|
||||||
INSERT INTO calls (
|
INSERT INTO calls (
|
||||||
id,
|
id,
|
||||||
submitter,
|
submitter,
|
||||||
|
@ -71,11 +71,29 @@ INSERT INTO calls (
|
||||||
tg_alpha_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 (
|
||||||
RETURNING id
|
$1,
|
||||||
|
$2,
|
||||||
|
$3,
|
||||||
|
$4,
|
||||||
|
$5,
|
||||||
|
$6,
|
||||||
|
$7,
|
||||||
|
$8,
|
||||||
|
$9,
|
||||||
|
$10,
|
||||||
|
$11,
|
||||||
|
$12,
|
||||||
|
$13,
|
||||||
|
$14,
|
||||||
|
$15,
|
||||||
|
$16,
|
||||||
|
$17
|
||||||
|
)
|
||||||
`
|
`
|
||||||
|
|
||||||
type AddCallParams struct {
|
type AddCallParams struct {
|
||||||
|
ID uuid.UUID `json:"id"`
|
||||||
Submitter *int32 `json:"submitter"`
|
Submitter *int32 `json:"submitter"`
|
||||||
System int `json:"system"`
|
System int `json:"system"`
|
||||||
Talkgroup int `json:"talkgroup"`
|
Talkgroup int `json:"talkgroup"`
|
||||||
|
@ -94,8 +112,9 @@ type AddCallParams struct {
|
||||||
Source int `json:"source"`
|
Source int `json:"source"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) AddCall(ctx context.Context, arg AddCallParams) (uuid.UUID, error) {
|
func (q *Queries) AddCall(ctx context.Context, arg AddCallParams) error {
|
||||||
row := q.db.QueryRow(ctx, addCall,
|
_, err := q.db.Exec(ctx, addCall,
|
||||||
|
arg.ID,
|
||||||
arg.Submitter,
|
arg.Submitter,
|
||||||
arg.System,
|
arg.System,
|
||||||
arg.Talkgroup,
|
arg.Talkgroup,
|
||||||
|
@ -113,9 +132,7 @@ func (q *Queries) AddCall(ctx context.Context, arg AddCallParams) (uuid.UUID, er
|
||||||
arg.TgGroup,
|
arg.TgGroup,
|
||||||
arg.Source,
|
arg.Source,
|
||||||
)
|
)
|
||||||
var id uuid.UUID
|
return err
|
||||||
err := row.Scan(&id)
|
|
||||||
return id, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDatabaseSize = `-- name: GetDatabaseSize :one
|
const getDatabaseSize = `-- name: GetDatabaseSize :one
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
type Querier interface {
|
type Querier interface {
|
||||||
AddAlert(ctx context.Context, arg AddAlertParams) error
|
AddAlert(ctx context.Context, arg AddAlertParams) error
|
||||||
AddCall(ctx context.Context, arg AddCallParams) (uuid.UUID, error)
|
AddCall(ctx context.Context, arg AddCallParams) error
|
||||||
BulkSetTalkgroupTags(ctx context.Context, iD int64, tags []string) error
|
BulkSetTalkgroupTags(ctx context.Context, iD int64, tags []string) error
|
||||||
CreateAPIKey(ctx context.Context, owner int, expires pgtype.Timestamp, disabled *bool) (ApiKey, error)
|
CreateAPIKey(ctx context.Context, owner int, expires pgtype.Timestamp, disabled *bool) (ApiKey, error)
|
||||||
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
|
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
|
||||||
|
|
|
@ -288,18 +288,19 @@ type Call struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
AudioName string `protobuf:"bytes,1,opt,name=audioName,proto3" json:"audioName,omitempty"`
|
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
AudioType string `protobuf:"bytes,2,opt,name=audioType,proto3" json:"audioType,omitempty"`
|
AudioName string `protobuf:"bytes,2,opt,name=audioName,proto3" json:"audioName,omitempty"`
|
||||||
DateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=date_time,json=dateTime,proto3" json:"date_time,omitempty"`
|
AudioType string `protobuf:"bytes,3,opt,name=audioType,proto3" json:"audioType,omitempty"`
|
||||||
System int32 `protobuf:"varint,4,opt,name=system,proto3" json:"system,omitempty"`
|
DateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=date_time,json=dateTime,proto3" json:"date_time,omitempty"`
|
||||||
Talkgroup int32 `protobuf:"varint,5,opt,name=talkgroup,proto3" json:"talkgroup,omitempty"`
|
System int32 `protobuf:"varint,5,opt,name=system,proto3" json:"system,omitempty"`
|
||||||
Source int32 `protobuf:"varint,6,opt,name=source,proto3" json:"source,omitempty"`
|
Talkgroup int32 `protobuf:"varint,6,opt,name=talkgroup,proto3" json:"talkgroup,omitempty"`
|
||||||
Frequency int64 `protobuf:"varint,7,opt,name=frequency,proto3" json:"frequency,omitempty"`
|
Source int32 `protobuf:"varint,7,opt,name=source,proto3" json:"source,omitempty"`
|
||||||
Frequencies []int64 `protobuf:"varint,8,rep,packed,name=frequencies,proto3" json:"frequencies,omitempty"`
|
Frequency int64 `protobuf:"varint,8,opt,name=frequency,proto3" json:"frequency,omitempty"`
|
||||||
Patches []int32 `protobuf:"varint,9,rep,packed,name=patches,proto3" json:"patches,omitempty"`
|
Frequencies []int64 `protobuf:"varint,9,rep,packed,name=frequencies,proto3" json:"frequencies,omitempty"`
|
||||||
Sources []int32 `protobuf:"varint,10,rep,packed,name=sources,proto3" json:"sources,omitempty"`
|
Patches []int32 `protobuf:"varint,10,rep,packed,name=patches,proto3" json:"patches,omitempty"`
|
||||||
Duration *int32 `protobuf:"varint,11,opt,name=duration,proto3,oneof" json:"duration,omitempty"`
|
Sources []int32 `protobuf:"varint,11,rep,packed,name=sources,proto3" json:"sources,omitempty"`
|
||||||
Audio []byte `protobuf:"bytes,12,opt,name=audio,proto3" json:"audio,omitempty"`
|
Duration *int32 `protobuf:"varint,12,opt,name=duration,proto3,oneof" json:"duration,omitempty"`
|
||||||
|
Audio []byte `protobuf:"bytes,13,opt,name=audio,proto3" json:"audio,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Call) Reset() {
|
func (x *Call) Reset() {
|
||||||
|
@ -334,6 +335,13 @@ func (*Call) Descriptor() ([]byte, []int) {
|
||||||
return file_stillbox_proto_rawDescGZIP(), []int{2}
|
return file_stillbox_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *Call) GetId() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (x *Call) GetAudioName() string {
|
func (x *Call) GetAudioName() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.AudioName
|
return x.AudioName
|
||||||
|
@ -1187,29 +1195,30 @@ var file_stillbox_proto_rawDesc = []byte{
|
||||||
0x6f, 0x75, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x06, 0x74, 0x67, 0x49, 0x6e, 0x66,
|
0x6f, 0x75, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x06, 0x74, 0x67, 0x49, 0x6e, 0x66,
|
||||||
0x6f, 0x42, 0x12, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5f, 0x72, 0x65, 0x73,
|
0x6f, 0x42, 0x12, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5f, 0x72, 0x65, 0x73,
|
||||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
|
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
|
||||||
0x64, 0x5f, 0x69, 0x64, 0x22, 0x81, 0x03, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x1c, 0x0a,
|
0x64, 0x5f, 0x69, 0x64, 0x22, 0x91, 0x03, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0e, 0x0a,
|
||||||
0x09, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a,
|
||||||
|
0x09, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x52, 0x09, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61,
|
0x52, 0x09, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61,
|
||||||
0x75, 0x64, 0x69, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
0x75, 0x64, 0x69, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||||
0x61, 0x75, 0x64, 0x69, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x12, 0x37, 0x0a, 0x09, 0x64, 0x61, 0x74,
|
0x61, 0x75, 0x64, 0x69, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x12, 0x37, 0x0a, 0x09, 0x64, 0x61, 0x74,
|
||||||
0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
|
0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
|
||||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
|
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69,
|
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69,
|
||||||
0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x04, 0x20, 0x01,
|
0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x05, 0x20, 0x01,
|
||||||
0x28, 0x05, 0x52, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x61,
|
0x28, 0x05, 0x52, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x61,
|
||||||
0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74,
|
0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74,
|
||||||
0x61, 0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72,
|
0x61, 0x6c, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72,
|
||||||
0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
|
0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
|
||||||
0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x07, 0x20,
|
0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x08, 0x20,
|
||||||
0x01, 0x28, 0x03, 0x52, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x20,
|
0x01, 0x28, 0x03, 0x52, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x20,
|
||||||
0x0a, 0x0b, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x18, 0x08, 0x20,
|
0x0a, 0x0b, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x18, 0x09, 0x20,
|
||||||
0x03, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73,
|
0x03, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73,
|
||||||
0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28,
|
0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28,
|
||||||
0x05, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6f,
|
0x05, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6f,
|
||||||
0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x05, 0x52, 0x07, 0x73, 0x6f, 0x75,
|
0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x05, 0x52, 0x07, 0x73, 0x6f, 0x75,
|
||||||
0x72, 0x63, 0x65, 0x73, 0x12, 0x1f, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
0x72, 0x63, 0x65, 0x73, 0x12, 0x1f, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||||
0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69,
|
0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69,
|
||||||
0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x18, 0x0c,
|
0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x18, 0x0d,
|
||||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x42, 0x0b, 0x0a, 0x09, 0x5f,
|
0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x42, 0x0b, 0x0a, 0x09, 0x5f,
|
||||||
0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3e, 0x0a, 0x05, 0x48, 0x65, 0x6c, 0x6c,
|
0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3e, 0x0a, 0x05, 0x48, 0x65, 0x6c, 0x6c,
|
||||||
0x6f, 0x12, 0x35, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f,
|
0x6f, 0x12, 0x35, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f,
|
||||||
|
|
|
@ -24,18 +24,19 @@ message CommandResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
message Call {
|
message Call {
|
||||||
string audioName = 1;
|
string id = 1;
|
||||||
string audioType = 2;
|
string audioName = 2;
|
||||||
google.protobuf.Timestamp date_time = 3;
|
string audioType = 3;
|
||||||
int32 system = 4;
|
google.protobuf.Timestamp date_time = 4;
|
||||||
int32 talkgroup = 5;
|
int32 system = 5;
|
||||||
int32 source = 6;
|
int32 talkgroup = 6;
|
||||||
int64 frequency = 7;
|
int32 source = 7;
|
||||||
repeated int64 frequencies = 8;
|
int64 frequency = 8;
|
||||||
repeated int32 patches = 9;
|
repeated int64 frequencies = 9;
|
||||||
repeated int32 sources = 10;
|
repeated int32 patches = 10;
|
||||||
optional int32 duration = 11;
|
repeated int32 sources = 11;
|
||||||
bytes audio = 12;
|
optional int32 duration = 12;
|
||||||
|
bytes audio = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Hello {
|
message Hello {
|
||||||
|
|
|
@ -26,12 +26,12 @@ func (s *DatabaseSink) Call(ctx context.Context, call *calls.Call) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dbCall, err := s.db.AddCall(ctx, s.toAddCallParams(call))
|
err := s.db.AddCall(ctx, s.toAddCallParams(call))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("add call: %w", err)
|
return fmt.Errorf("add call: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Str("id", dbCall.String()).Int("system", call.System).Int("tgid", call.Talkgroup).Msg("stored")
|
log.Debug().Str("id", call.ID.String()).Int("system", call.System).Int("tgid", call.Talkgroup).Msg("stored")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ func (s *DatabaseSink) SinkType() string {
|
||||||
|
|
||||||
func (s *DatabaseSink) toAddCallParams(call *calls.Call) database.AddCallParams {
|
func (s *DatabaseSink) toAddCallParams(call *calls.Call) database.AddCallParams {
|
||||||
return database.AddCallParams{
|
return database.AddCallParams{
|
||||||
|
ID: call.ID,
|
||||||
Submitter: call.Submitter.Int32Ptr(),
|
Submitter: call.Submitter.Int32Ptr(),
|
||||||
System: call.System,
|
System: call.System,
|
||||||
Talkgroup: call.Talkgroup,
|
Talkgroup: call.Talkgroup,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- name: AddCall :one
|
-- name: AddCall :exec
|
||||||
INSERT INTO calls (
|
INSERT INTO calls (
|
||||||
id,
|
id,
|
||||||
submitter,
|
submitter,
|
||||||
|
@ -17,8 +17,25 @@ INSERT INTO calls (
|
||||||
tg_alpha_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 (
|
||||||
RETURNING id;
|
@id,
|
||||||
|
@submitter,
|
||||||
|
@system,
|
||||||
|
@talkgroup,
|
||||||
|
@call_date,
|
||||||
|
@audio_name,
|
||||||
|
@audio_blob,
|
||||||
|
@audio_type,
|
||||||
|
@audio_url,
|
||||||
|
@duration,
|
||||||
|
@frequency,
|
||||||
|
@frequencies,
|
||||||
|
@patches,
|
||||||
|
@tg_label,
|
||||||
|
@tg_alpha_tag,
|
||||||
|
@tg_group,
|
||||||
|
@source
|
||||||
|
);
|
||||||
|
|
||||||
-- name: SetCallTranscript :exec
|
-- name: SetCallTranscript :exec
|
||||||
UPDATE calls SET transcript = $2 WHERE id = $1;
|
UPDATE calls SET transcript = $2 WHERE id = $1;
|
||||||
|
|
Loading…
Reference in a new issue