Merge branch 'partmanIntvl115' of git.dynatron.me:amigan/stillbox into partmanIntvl115

This commit is contained in:
Daniel Ponte 2025-02-22 17:28:03 -05:00
commit 5310780f05
5 changed files with 25 additions and 6 deletions

View file

@ -204,6 +204,7 @@ type CallsParams struct {
TagsNot []string `json:"tagsNot"`
TGFilter *string `json:"tgFilter"`
AtLeastSeconds *float32 `json:"atLeastSeconds"`
UnknownTG bool `json:"unknownTG"`
}
func (s *postgresStore) Calls(ctx context.Context, p CallsParams) (rows []database.ListCallsPRow, totalCount int, err error) {
@ -224,6 +225,7 @@ func (s *postgresStore) Calls(ctx context.Context, p CallsParams) (rows []databa
PerPage: perPage,
Direction: p.Direction.DirString(common.DirAsc),
TGFilter: p.TGFilter,
UnknownTG: p.UnknownTG,
}
if p.AtLeastSeconds != nil {
@ -245,6 +247,7 @@ func (s *postgresStore) Calls(ctx context.Context, p CallsParams) (rows []databa
TagsNot: par.TagsNot,
TGFilter: par.TGFilter,
LongerThan: par.LongerThan,
UnknownTG: par.UnknownTG,
})
if err != nil {
return err

View file

@ -319,6 +319,9 @@ CASE WHEN $4::TEXT[] IS NOT NULL THEN
) ELSE TRUE END) AND
(CASE WHEN $6::NUMERIC IS NOT NULL THEN (
c.duration > $6
) ELSE TRUE END) AND
(CASE WHEN $7::BOOLEAN = TRUE THEN (
tgs.tgid IS NULL
) ELSE TRUE END)
`
@ -329,6 +332,7 @@ type ListCallsCountParams struct {
TagsNot []string `json:"tagsNot"`
TGFilter *string `json:"tgFilter"`
LongerThan pgtype.Numeric `json:"longerThan"`
UnknownTG bool `json:"unknownTg"`
}
func (q *Queries) ListCallsCount(ctx context.Context, arg ListCallsCountParams) (int64, error) {
@ -339,6 +343,7 @@ func (q *Queries) ListCallsCount(ctx context.Context, arg ListCallsCountParams)
arg.TagsNot,
arg.TGFilter,
arg.LongerThan,
arg.UnknownTG,
)
var count int64
err := row.Scan(&count)
@ -374,13 +379,16 @@ CASE WHEN $4::TEXT[] IS NOT NULL THEN
) ELSE TRUE END) AND
(CASE WHEN $6::NUMERIC IS NOT NULL THEN (
c.duration > $6
) ELSE TRUE END) AND
(CASE WHEN $7::BOOLEAN = TRUE THEN (
tgs.tgid IS NULL
) ELSE TRUE END)
GROUP BY c.id, c.call_date
ORDER BY
CASE WHEN $7::TEXT = 'asc' THEN c.call_date END ASC,
CASE WHEN $7 = 'desc' THEN c.call_date END DESC
OFFSET $8 ROWS
FETCH NEXT $9 ROWS ONLY
CASE WHEN $8::TEXT = 'asc' THEN c.call_date END ASC,
CASE WHEN $8 = 'desc' THEN c.call_date END DESC
OFFSET $9 ROWS
FETCH NEXT $10 ROWS ONLY
`
type ListCallsPParams struct {
@ -390,6 +398,7 @@ type ListCallsPParams struct {
TagsNot []string `json:"tagsNot"`
TGFilter *string `json:"tgFilter"`
LongerThan pgtype.Numeric `json:"longerThan"`
UnknownTG bool `json:"unknownTg"`
Direction string `json:"direction"`
Offset int32 `json:"offset"`
PerPage int32 `json:"perPage"`
@ -413,6 +422,7 @@ func (q *Queries) ListCallsP(ctx context.Context, arg ListCallsPParams) ([]ListC
arg.TagsNot,
arg.TGFilter,
arg.LongerThan,
arg.UnknownTG,
arg.Direction,
arg.Offset,
arg.PerPage,

View file

@ -203,7 +203,7 @@ FROM incidents_calls ic, LATERAL (
sc.audio_url,
sc.frequency,
sc.frequencies,
c.talker_alias,
sc.talker_alias,
sc.patches,
sc.source,
sc.transcript

View file

@ -127,6 +127,9 @@ CASE WHEN sqlc.narg('tags_not')::TEXT[] IS NOT NULL THEN
) ELSE TRUE END) AND
(CASE WHEN sqlc.narg('longer_than')::NUMERIC IS NOT NULL THEN (
c.duration > @longer_than
) ELSE TRUE END) AND
(CASE WHEN @unknown_tg::BOOLEAN = TRUE THEN (
tgs.tgid IS NULL
) ELSE TRUE END)
GROUP BY c.id, c.call_date
ORDER BY
@ -157,6 +160,9 @@ CASE WHEN sqlc.narg('tags_not')::TEXT[] IS NOT NULL THEN
) ELSE TRUE END) AND
(CASE WHEN sqlc.narg('longer_than')::NUMERIC IS NOT NULL THEN (
c.duration > @longer_than
) ELSE TRUE END) AND
(CASE WHEN @unknown_tg::BOOLEAN = TRUE THEN (
tgs.tgid IS NULL
) ELSE TRUE END)
;

View file

@ -151,7 +151,7 @@ FROM incidents_calls ic, LATERAL (
sc.audio_url,
sc.frequency,
sc.frequencies,
c.talker_alias,
sc.talker_alias,
sc.patches,
sc.source,
sc.transcript