fix: flatten nested case blocks with with chains (CSM-020)

Replace deeply nested case expressions with flat with chains in
import_definitions, publishing, and templates modules. Also replaced
Repo.update!() with Repo.update() in the publishing update_job handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 12:36:42 +02:00
parent b6f9cf58e1
commit 7c00279b9d
5 changed files with 171 additions and 100 deletions

View File

@@ -55,16 +55,12 @@ defmodule BDS.ImportDefinitions do
end
def delete_definition(definition_id) when is_binary(definition_id) do
case Repo.get(ImportDefinition, definition_id) do
nil ->
{:error, :not_found}
%ImportDefinition{} = definition ->
Repo.delete(definition)
|> case do
{:ok, _deleted} -> {:ok, :deleted}
error -> error
end
with %ImportDefinition{} = definition <- Repo.get(ImportDefinition, definition_id),
{:ok, _deleted} <- Repo.delete(definition) do
{:ok, :deleted}
else
nil -> {:error, :not_found}
{:error, _} = error -> error
end
end