chore: refactoring of Repo.get/get! usages

This commit is contained in:
2026-05-01 17:20:08 +02:00
parent f6425de51d
commit 3505355980
23 changed files with 192 additions and 89 deletions

View File

@@ -5,10 +5,11 @@ defmodule BDS.Desktop.ShellLive.PanelRenderer do
alias BDS.Desktop.ShellData
alias BDS.Git
alias BDS.Media.Media
alias BDS.Media
alias BDS.Media.Media, as: MediaRecord
alias BDS.PostLinks
alias BDS.Posts
alias BDS.Posts.Post
alias BDS.Repo
@doc "Render the active panel tab body."
def render_panel_body(assigns) do
@@ -208,7 +209,7 @@ defmodule BDS.Desktop.ShellLive.PanelRenderer do
defp related_posts(links, key) do
Enum.map(links, fn link ->
case Repo.get(Post, Map.fetch!(link, key)) do
case Posts.get_post(Map.fetch!(link, key)) do
%Post{} = post -> %{id: post.id, title: post.title || post.slug || post.id, text: link.link_text || post.slug || post.id}
_other -> nil
end
@@ -230,15 +231,15 @@ defmodule BDS.Desktop.ShellLive.PanelRenderer do
end
defp git_history_target(%{type: :post, id: post_id}) do
case Repo.get(Post, post_id) do
case Posts.get_post(post_id) do
%Post{project_id: project_id, file_path: file_path} when file_path not in [nil, ""] -> {project_id, file_path}
_other -> nil
end
end
defp git_history_target(%{type: :media, id: media_id}) do
case Repo.get(Media, media_id) do
%Media{project_id: project_id, file_path: file_path} when file_path not in [nil, ""] -> {project_id, file_path}
case Media.get_media(media_id) do
%MediaRecord{project_id: project_id, file_path: file_path} when file_path not in [nil, ""] -> {project_id, file_path}
_other -> nil
end
end