From e01f20f1fc3bcdfcbd4f10c19fb8cb95b78017bf Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Fri, 10 Jan 2025 20:20:00 -0500 Subject: [PATCH] incident call order --- pkg/database/batch.go | 22 ++++++------ pkg/database/incidents.sql.go | 1 + pkg/database/models.go | 58 +++++++++++++++--------------- pkg/database/talkgroups.sql.go | 24 ++++++------- sql/postgres/queries/incidents.sql | 3 +- 5 files changed, 55 insertions(+), 53 deletions(-) diff --git a/pkg/database/batch.go b/pkg/database/batch.go index 7b42a46..3001e0d 100644 --- a/pkg/database/batch.go +++ b/pkg/database/batch.go @@ -135,18 +135,18 @@ type UpsertTalkgroupBatchResults struct { } type UpsertTalkgroupParams struct { - SystemID int32 `json:"system_id"` - TGID int32 `json:"tgid"` - Name *string `json:"name"` - AlphaTag *string `json:"alpha_tag"` - TGGroup *string `json:"tg_group"` - Frequency *int32 `json:"frequency"` - Metadata jsontypes.Metadata `json:"metadata"` - Tags []string `json:"tags"` - Alert interface{} `json:"alert"` + SystemID int32 `json:"system_id"` + TGID int32 `json:"tgid"` + Name *string `json:"name"` + AlphaTag *string `json:"alpha_tag"` + TGGroup *string `json:"tg_group"` + Frequency *int32 `json:"frequency"` + Metadata jsontypes.Metadata `json:"metadata"` + Tags []string `json:"tags"` + Alert interface{} `json:"alert"` AlertRules rules.AlertRules `json:"alert_rules"` - Weight pgtype.Numeric `json:"weight"` - Learned *bool `json:"learned"` + Weight pgtype.Numeric `json:"weight"` + Learned *bool `json:"learned"` } func (q *Queries) UpsertTalkgroup(ctx context.Context, arg []UpsertTalkgroupParams) *UpsertTalkgroupBatchResults { diff --git a/pkg/database/incidents.sql.go b/pkg/database/incidents.sql.go index 28a46a2..d422db0 100644 --- a/pkg/database/incidents.sql.go +++ b/pkg/database/incidents.sql.go @@ -180,6 +180,7 @@ FROM incidents_calls ic, LATERAL ( FROM swept_calls sc WHERE sc.id = ic.swept_call_id ) c WHERE ic.incident_id = $1 +ORDER BY ic.call_date ASC ` type GetIncidentCallsRow struct { diff --git a/pkg/database/models.go b/pkg/database/models.go index fdc390b..66ff0ed 100644 --- a/pkg/database/models.go +++ b/pkg/database/models.go @@ -107,40 +107,40 @@ type System struct { } type Talkgroup struct { - ID int `json:"id,omitempty"` - SystemID int32 `json:"system_id,omitempty"` - TGID int32 `json:"tgid,omitempty"` - Name *string `json:"name,omitempty"` - AlphaTag *string `json:"alpha_tag,omitempty"` - TGGroup *string `json:"tg_group,omitempty"` - Frequency *int32 `json:"frequency,omitempty"` - Metadata jsontypes.Metadata `json:"metadata,omitempty"` - Tags []string `json:"tags,omitempty"` - Alert bool `json:"alert,omitempty"` + ID int `json:"id,omitempty"` + SystemID int32 `json:"system_id,omitempty"` + TGID int32 `json:"tgid,omitempty"` + Name *string `json:"name,omitempty"` + AlphaTag *string `json:"alpha_tag,omitempty"` + TGGroup *string `json:"tg_group,omitempty"` + Frequency *int32 `json:"frequency,omitempty"` + Metadata jsontypes.Metadata `json:"metadata,omitempty"` + Tags []string `json:"tags,omitempty"` + Alert bool `json:"alert,omitempty"` AlertRules rules.AlertRules `json:"alert_rules,omitempty"` - Weight float32 `json:"weight,omitempty"` - Learned bool `json:"learned,omitempty"` - Ignored bool `json:"ignored,omitempty"` + Weight float32 `json:"weight,omitempty"` + Learned bool `json:"learned,omitempty"` + Ignored bool `json:"ignored,omitempty"` } type TalkgroupVersion struct { - ID int `json:"id,omitempty"` - Time pgtype.Timestamptz `json:"time,omitempty"` - CreatedBy *int32 `json:"created_by,omitempty"` - Deleted *bool `json:"deleted,omitempty"` - SystemID *int32 `json:"system_id,omitempty"` - TGID *int32 `json:"tgid,omitempty"` - Name *string `json:"name,omitempty"` - AlphaTag *string `json:"alpha_tag,omitempty"` - TGGroup *string `json:"tg_group,omitempty"` - Frequency *int32 `json:"frequency,omitempty"` - Metadata []byte `json:"metadata,omitempty"` - Tags []string `json:"tags,omitempty"` - Alert *bool `json:"alert,omitempty"` + ID int `json:"id,omitempty"` + Time pgtype.Timestamptz `json:"time,omitempty"` + CreatedBy *int32 `json:"created_by,omitempty"` + Deleted *bool `json:"deleted,omitempty"` + SystemID *int32 `json:"system_id,omitempty"` + TGID *int32 `json:"tgid,omitempty"` + Name *string `json:"name,omitempty"` + AlphaTag *string `json:"alpha_tag,omitempty"` + TGGroup *string `json:"tg_group,omitempty"` + Frequency *int32 `json:"frequency,omitempty"` + Metadata []byte `json:"metadata,omitempty"` + Tags []string `json:"tags,omitempty"` + Alert *bool `json:"alert,omitempty"` AlertRules []byte `json:"alert_rules,omitempty"` - Weight *float32 `json:"weight,omitempty"` - Learned *bool `json:"learned,omitempty"` - Ignored *bool `json:"ignored,omitempty"` + Weight *float32 `json:"weight,omitempty"` + Learned *bool `json:"learned,omitempty"` + Ignored *bool `json:"ignored,omitempty"` } type User struct { diff --git a/pkg/database/talkgroups.sql.go b/pkg/database/talkgroups.sql.go index 458edcc..bc378e5 100644 --- a/pkg/database/talkgroups.sql.go +++ b/pkg/database/talkgroups.sql.go @@ -738,19 +738,19 @@ RETURNING id, system_id, tgid, name, alpha_tag, tg_group, frequency, metadata, t ` type UpdateTalkgroupParams struct { - Name *string `json:"name"` - AlphaTag *string `json:"alpha_tag"` - TGGroup *string `json:"tg_group"` - Frequency *int32 `json:"frequency"` - Metadata jsontypes.Metadata `json:"metadata"` - Tags []string `json:"tags"` - Alert *bool `json:"alert"` + Name *string `json:"name"` + AlphaTag *string `json:"alpha_tag"` + TGGroup *string `json:"tg_group"` + Frequency *int32 `json:"frequency"` + Metadata jsontypes.Metadata `json:"metadata"` + Tags []string `json:"tags"` + Alert *bool `json:"alert"` AlertRules rules.AlertRules `json:"alert_rules"` - Weight *float32 `json:"weight"` - Learned *bool `json:"learned"` - ID *int32 `json:"id"` - SystemID *int32 `json:"system_id"` - TGID *int32 `json:"tgid"` + Weight *float32 `json:"weight"` + Learned *bool `json:"learned"` + ID *int32 `json:"id"` + SystemID *int32 `json:"system_id"` + TGID *int32 `json:"tgid"` } func (q *Queries) UpdateTalkgroup(ctx context.Context, arg UpdateTalkgroupParams) (Talkgroup, error) { diff --git a/sql/postgres/queries/incidents.sql b/sql/postgres/queries/incidents.sql index f504919..214a123 100644 --- a/sql/postgres/queries/incidents.sql +++ b/sql/postgres/queries/incidents.sql @@ -141,7 +141,8 @@ FROM incidents_calls ic, LATERAL ( sc.transcript FROM swept_calls sc WHERE sc.id = ic.swept_call_id ) c -WHERE ic.incident_id = @id; +WHERE ic.incident_id = @id +ORDER BY ic.call_date ASC; -- name: GetIncident :one SELECT