Skip to content

Commit 592b20c

Browse files
committed
PR feeback
1 parent ce6e17a commit 592b20c

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

lib/realtime_web/controllers/fallback_controller.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ defmodule RealtimeWeb.FallbackController do
1111
import RealtimeWeb.ErrorHelpers
1212

1313
def call(conn, {:error, :not_found}) do
14+
log_error("TenantNotFound", "Tenant not found")
15+
1416
conn
1517
|> put_status(:not_found)
1618
|> put_view(RealtimeWeb.ErrorView)

lib/realtime_web/controllers/tenant_controller.ex

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,8 @@ defmodule RealtimeWeb.TenantController do
7777
tenant = Api.get_tenant_by_external_id(id)
7878

7979
case tenant do
80-
%Tenant{} = tenant ->
81-
render(conn, "show.json", tenant: tenant)
82-
83-
nil ->
84-
conn
85-
|> put_status(404)
86-
|> render("not_found.json", tenant: nil)
80+
%Tenant{} = tenant -> render(conn, "show.json", tenant: tenant)
81+
nil -> {:error, :not_found}
8782
end
8883
end
8984

@@ -201,7 +196,6 @@ defmodule RealtimeWeb.TenantController do
201196
send_resp(conn, 204, "")
202197
else
203198
nil ->
204-
log_error("TenantNotFound", "Tenant not found")
205199
send_resp(conn, 204, "")
206200

207201
err ->
@@ -234,10 +228,7 @@ defmodule RealtimeWeb.TenantController do
234228
case Api.get_tenant_by_external_id(tenant_id, use_replica?: false) do
235229
nil ->
236230
log_error("TenantNotFound", "Tenant not found")
237-
238-
conn
239-
|> put_status(404)
240-
|> render("not_found.json", tenant: nil)
231+
{:error, :not_found}
241232

242233
tenant ->
243234
PostgresCdc.stop_all(tenant, @stop_timeout)
@@ -271,14 +262,10 @@ defmodule RealtimeWeb.TenantController do
271262
case Api.get_tenant_by_external_id(tenant_id, use_replica?: false) do
272263
nil ->
273264
log_error("TenantNotFound", "Tenant not found")
274-
275-
conn
276-
|> put_status(404)
277-
|> render("not_found.json", tenant: nil)
265+
{:error, :not_found}
278266

279267
tenant ->
280268
Connect.shutdown(tenant.external_id)
281-
SocketDisconnect.distributed_disconnect(tenant.external_id)
282269
send_resp(conn, 204, "")
283270
end
284271
end
@@ -313,10 +300,7 @@ defmodule RealtimeWeb.TenantController do
313300

314301
{:error, :tenant_not_found} ->
315302
log_error("TenantNotFound", "Tenant not found")
316-
317-
conn
318-
|> put_status(404)
319-
|> render("not_found.json", tenant: nil)
303+
{:error, :not_found}
320304
end
321305
end
322306

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
44
def project do
55
[
66
app: :realtime,
7-
version: "2.74.2",
7+
version: "2.74.3",
88
elixir: "~> 1.18",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
start_permanent: Mix.env() == :prod,

0 commit comments

Comments
 (0)