Harden monitoring TG reanalyze reset
This commit is contained in:
@@ -778,7 +778,13 @@ func (a *app) reanalyzeChannel(ctx context.Context, w http.ResponseWriter, r *ht
|
||||
return
|
||||
}
|
||||
key := verdictKey(ch.Vertical)
|
||||
tag, err := a.db.Exec(ctx, `UPDATE messages SET extracted = COALESCE(extracted, '{}'::jsonb) - $1 WHERE channel_id = $2`, key, id)
|
||||
tag, err := a.db.Exec(ctx, `
|
||||
UPDATE messages
|
||||
SET extracted = (
|
||||
CASE WHEN jsonb_typeof(extracted) = 'object' THEN extracted ELSE '{}'::jsonb END
|
||||
) - $1
|
||||
WHERE channel_id = $2
|
||||
`, key, id)
|
||||
if err != nil {
|
||||
writeDBError(w, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user