Complete incidents functionality #97
4 changed files with 6 additions and 6 deletions
|
@ -42,18 +42,18 @@ type CallAudio struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Call struct {
|
type Call struct {
|
||||||
ID uuid.UUID `json:"-"`
|
ID uuid.UUID `json:"id"`
|
||||||
Audio []byte `json:"audio,omitempty" filenameField:"AudioName"`
|
Audio []byte `json:"audio,omitempty" filenameField:"AudioName"`
|
||||||
AudioName string `json:"audioName,omitempty"`
|
AudioName string `json:"audioName,omitempty"`
|
||||||
AudioType string `json:"audioType,omitempty"`
|
AudioType string `json:"audioType,omitempty"`
|
||||||
Duration CallDuration `json:"-"`
|
Duration CallDuration `json:"duration,omitempty"`
|
||||||
DateTime time.Time `json:"dateTime,omitempty"`
|
DateTime time.Time `json:"dateTime,omitempty"`
|
||||||
Frequencies []int `json:"frequencies,omitempty"`
|
Frequencies []int `json:"frequencies,omitempty"`
|
||||||
Frequency int `json:"frequency,omitempty"`
|
Frequency int `json:"frequency,omitempty"`
|
||||||
Patches []int `json:"patches,omitempty"`
|
Patches []int `json:"patches,omitempty"`
|
||||||
Source int `json:"source,omitempty"`
|
Source int `json:"source,omitempty"`
|
||||||
System int `json:"system,omitempty"`
|
System int `json:"system,omitempty"`
|
||||||
Submitter *auth.UserID `json:"-,omitempty"`
|
Submitter *auth.UserID `json:"submitter,omitempty"`
|
||||||
SystemLabel string `json:"systemLabel,omitempty"`
|
SystemLabel string `json:"systemLabel,omitempty"`
|
||||||
Talkgroup int `json:"talkgroup,omitempty"`
|
Talkgroup int `json:"talkgroup,omitempty"`
|
||||||
TalkgroupGroup *string `json:"talkgroupGroup,omitempty"`
|
TalkgroupGroup *string `json:"talkgroupGroup,omitempty"`
|
||||||
|
|
|
@ -147,7 +147,6 @@ WITH to_sweep AS (
|
||||||
WHERE call_id IN (SELECT id FROM to_sweep)
|
WHERE call_id IN (SELECT id FROM to_sweep)
|
||||||
`
|
`
|
||||||
|
|
||||||
// This is used to sweep calls that are part of an incident prior to pruning a partition.
|
|
||||||
func (q *Queries) CleanupSweptCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error) {
|
func (q *Queries) CleanupSweptCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error) {
|
||||||
result, err := q.db.Exec(ctx, cleanupSweptCalls, rangeStart, rangeEnd)
|
result, err := q.db.Exec(ctx, cleanupSweptCalls, rangeStart, rangeEnd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -366,6 +365,7 @@ WITH to_sweep AS (
|
||||||
) INSERT INTO swept_calls SELECT id, submitter, system, talkgroup, call_date, audio_name, audio_blob, duration, audio_type, audio_url, frequency, frequencies, patches, tg_label, tg_alpha_tag, tg_group, source, transcript FROM to_sweep
|
) INSERT INTO swept_calls SELECT id, submitter, system, talkgroup, call_date, audio_name, audio_blob, duration, audio_type, audio_url, frequency, frequencies, patches, tg_label, tg_alpha_tag, tg_group, source, transcript FROM to_sweep
|
||||||
`
|
`
|
||||||
|
|
||||||
|
// This is used to sweep calls that are part of an incident prior to pruning a partition.
|
||||||
func (q *Queries) SweepCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error) {
|
func (q *Queries) SweepCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error) {
|
||||||
result, err := q.db.Exec(ctx, sweepCalls, rangeStart, rangeEnd)
|
result, err := q.db.Exec(ctx, sweepCalls, rangeStart, rangeEnd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -16,7 +16,6 @@ type Querier interface {
|
||||||
AddCall(ctx context.Context, arg AddCallParams) error
|
AddCall(ctx context.Context, arg AddCallParams) error
|
||||||
AddLearnedTalkgroup(ctx context.Context, arg AddLearnedTalkgroupParams) (Talkgroup, error)
|
AddLearnedTalkgroup(ctx context.Context, arg AddLearnedTalkgroupParams) (Talkgroup, error)
|
||||||
AddToIncident(ctx context.Context, incidentID uuid.UUID, callIds []uuid.UUID, notes [][]byte) error
|
AddToIncident(ctx context.Context, incidentID uuid.UUID, callIds []uuid.UUID, notes [][]byte) error
|
||||||
// This is used to sweep calls that are part of an incident prior to pruning a partition.
|
|
||||||
CleanupSweptCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error)
|
CleanupSweptCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, 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)
|
||||||
CreateIncident(ctx context.Context, arg CreateIncidentParams) (Incident, error)
|
CreateIncident(ctx context.Context, arg CreateIncidentParams) (Incident, error)
|
||||||
|
@ -62,6 +61,7 @@ type Querier interface {
|
||||||
SetTalkgroupTags(ctx context.Context, tags []string, systemID int32, tGID int32) error
|
SetTalkgroupTags(ctx context.Context, tags []string, systemID int32, tGID int32) error
|
||||||
StoreDeletedTGVersion(ctx context.Context, systemID *int32, tGID *int32, submitter *int32) error
|
StoreDeletedTGVersion(ctx context.Context, systemID *int32, tGID *int32, submitter *int32) error
|
||||||
StoreTGVersion(ctx context.Context, arg []StoreTGVersionParams) *StoreTGVersionBatchResults
|
StoreTGVersion(ctx context.Context, arg []StoreTGVersionParams) *StoreTGVersionBatchResults
|
||||||
|
// This is used to sweep calls that are part of an incident prior to pruning a partition.
|
||||||
SweepCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error)
|
SweepCalls(ctx context.Context, rangeStart pgtype.Timestamptz, rangeEnd pgtype.Timestamptz) (int64, error)
|
||||||
UpdateCallIncidentNotes(ctx context.Context, notes []byte, incidentID uuid.UUID, callID uuid.UUID) error
|
UpdateCallIncidentNotes(ctx context.Context, notes []byte, incidentID uuid.UUID, callID uuid.UUID) error
|
||||||
UpdateIncident(ctx context.Context, arg UpdateIncidentParams) (Incident, error)
|
UpdateIncident(ctx context.Context, arg UpdateIncidentParams) (Incident, error)
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (ia *incidentsAPI) listIncidents(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
res := struct {
|
res := struct {
|
||||||
Incidents []incstore.Incident `json:"incidents"`
|
Incidents []incstore.Incident `json:"incidents"`
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
res.Incidents, res.Count, err = incs.Incidents(ctx, p)
|
res.Incidents, res.Count, err = incs.Incidents(ctx, p)
|
||||||
|
|
Loading…
Add table
Reference in a new issue