Refactor subscriber delete query to support UUIDs
This commit is contained in:
parent
7d9758c3f5
commit
81fe874ee7
|
@ -107,8 +107,8 @@ INSERT INTO subscriber_lists (subscriber_id, list_id, status)
|
||||||
SET status = (CASE WHEN $4='blacklisted' THEN 'unsubscribed'::subscription_status ELSE 'unconfirmed' END);
|
SET status = (CASE WHEN $4='blacklisted' THEN 'unsubscribed'::subscription_status ELSE 'unconfirmed' END);
|
||||||
|
|
||||||
-- name: delete-subscribers
|
-- name: delete-subscribers
|
||||||
-- Delete one or more subscribers.
|
-- Delete one or more subscribers by ID or UUID.
|
||||||
DELETE FROM subscribers WHERE id = ANY($1);
|
DELETE FROM subscribers WHERE CASE WHEN ARRAY_LENGTH($1::INT[], 1) > 0 THEN id = ANY($1) ELSE uuid = ANY($2::UUID[]) END;
|
||||||
|
|
||||||
-- name: blacklist-subscribers
|
-- name: blacklist-subscribers
|
||||||
WITH b AS (
|
WITH b AS (
|
||||||
|
|
|
@ -327,7 +327,7 @@ func handleDeleteSubscribers(c echo.Context) error {
|
||||||
IDs = i
|
IDs = i
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := app.Queries.DeleteSubscribers.Exec(IDs); err != nil {
|
if _, err := app.Queries.DeleteSubscribers.Exec(IDs, nil); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError,
|
return echo.NewHTTPError(http.StatusInternalServerError,
|
||||||
fmt.Sprintf("Error deleting: %v", err))
|
fmt.Sprintf("Error deleting: %v", err))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue