Replace exact blank_to_nil helpers
This commit is contained in:
1
AUDIT.md
1
AUDIT.md
@@ -46,6 +46,7 @@ after each item.
|
|||||||
- [x] `scripting/runtime.ex`
|
- [x] `scripting/runtime.ex`
|
||||||
- [x] `desktop/external_links.ex`
|
- [x] `desktop/external_links.ex`
|
||||||
- [x] `MapUtils.maybe_put/3` replacements
|
- [x] `MapUtils.maybe_put/3` replacements
|
||||||
|
- [x] `MapUtils.blank_to_nil/1` replacements (exact duplicate sites replaced; trim-sensitive local variants verified keep)
|
||||||
- [x] `desktop/error_html.ex` (verified keep: still required by Phoenix `render_errors` wiring)
|
- [x] `desktop/error_html.ex` (verified keep: still required by Phoenix `render_errors` wiring)
|
||||||
- [x] `desktop/health_controller.ex` (verified keep: current Phoenix route wiring still expects a controller module)
|
- [x] `desktop/health_controller.ex` (verified keep: current Phoenix route wiring still expects a controller module)
|
||||||
- [x] `desktop/folder_picker.ex` (verified keep: no equivalent `Desktop.OS` picker primitive exists to inline onto)
|
- [x] `desktop/folder_picker.ex` (verified keep: no equivalent `Desktop.OS` picker primitive exists to inline onto)
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
|
|||||||
|> assign(:taxonomy_edit, %{
|
|> assign(:taxonomy_edit, %{
|
||||||
type: type,
|
type: type,
|
||||||
name: name,
|
name: name,
|
||||||
value: mapped_to |> to_string() |> blank_to_nil()
|
value: mapped_to |> to_string() |> BDS.MapUtils.blank_to_nil()
|
||||||
})
|
})
|
||||||
|> build_data()
|
|> build_data()
|
||||||
|
|
||||||
@@ -1451,6 +1451,4 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
|
|||||||
|
|
||||||
defp present?(value), do: value not in [nil, ""]
|
defp present?(value), do: value not in [nil, ""]
|
||||||
defp blank?(value), do: value in [nil, ""]
|
defp blank?(value), do: value in [nil, ""]
|
||||||
defp blank_to_nil(""), do: nil
|
|
||||||
defp blank_to_nil(value), do: value
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
|
|||||||
Map.put(socket.assigns.import_editor_taxonomy_edits, definition_id, %{
|
Map.put(socket.assigns.import_editor_taxonomy_edits, definition_id, %{
|
||||||
type: type,
|
type: type,
|
||||||
name: name,
|
name: name,
|
||||||
value: mapped_to |> to_string() |> blank_to_nil()
|
value: mapped_to |> to_string() |> BDS.MapUtils.blank_to_nil()
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|> reload.(socket.assigns.workbench)
|
|> reload.(socket.assigns.workbench)
|
||||||
@@ -150,7 +150,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
|
|||||||
@spec update_taxonomy_mapping(term(), term(), term(), term()) :: term()
|
@spec update_taxonomy_mapping(term(), term(), term(), term()) :: term()
|
||||||
def update_taxonomy_mapping(report, type, name, mapped_to) do
|
def update_taxonomy_mapping(report, type, name, mapped_to) do
|
||||||
bucket_key = if(type == "categories", do: :categories, else: :tags)
|
bucket_key = if(type == "categories", do: :categories, else: :tags)
|
||||||
normalized_value = mapped_to |> to_string() |> String.trim() |> blank_to_nil()
|
normalized_value = mapped_to |> to_string() |> String.trim() |> BDS.MapUtils.blank_to_nil()
|
||||||
|
|
||||||
updated_report =
|
updated_report =
|
||||||
update_in(report, [:items, bucket_key], fn items ->
|
update_in(report, [:items, bucket_key], fn items ->
|
||||||
@@ -229,7 +229,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
|
|||||||
|
|
||||||
@spec normalize_taxonomy_mapping_value(term(), term(), term()) :: term()
|
@spec normalize_taxonomy_mapping_value(term(), term(), term()) :: term()
|
||||||
def normalize_taxonomy_mapping_value(project_id, type, mapped_to) do
|
def normalize_taxonomy_mapping_value(project_id, type, mapped_to) do
|
||||||
normalized_value = mapped_to |> to_string() |> String.trim() |> blank_to_nil()
|
normalized_value = mapped_to |> to_string() |> String.trim() |> BDS.MapUtils.blank_to_nil()
|
||||||
|
|
||||||
case normalized_value do
|
case normalized_value do
|
||||||
nil ->
|
nil ->
|
||||||
@@ -285,6 +285,4 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
|
|||||||
def maybe_put_option(opts, key, value), do: Keyword.put(opts, key, value)
|
def maybe_put_option(opts, key, value), do: Keyword.put(opts, key, value)
|
||||||
|
|
||||||
defp present?(value), do: value not in [nil, ""]
|
defp present?(value), do: value not in [nil, ""]
|
||||||
defp blank_to_nil(""), do: nil
|
|
||||||
defp blank_to_nil(value), do: value
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -175,11 +175,11 @@ defmodule BDS.ImportAnalysis do
|
|||||||
resolution: if(status == "conflict", do: "ignore", else: nil),
|
resolution: if(status == "conflict", do: "ignore", else: nil),
|
||||||
existing_id: existing && existing.id,
|
existing_id: existing && existing.id,
|
||||||
existing_title: existing && existing.title,
|
existing_title: existing && existing.title,
|
||||||
author: blank_to_nil(wxr_post.creator),
|
author: BDS.MapUtils.blank_to_nil(wxr_post.creator),
|
||||||
excerpt: blank_to_nil(wxr_post.excerpt),
|
excerpt: BDS.MapUtils.blank_to_nil(wxr_post.excerpt),
|
||||||
categories: wxr_post.categories,
|
categories: wxr_post.categories,
|
||||||
tags: wxr_post.tags,
|
tags: wxr_post.tags,
|
||||||
wp_status: blank_to_nil(wxr_post.status),
|
wp_status: BDS.MapUtils.blank_to_nil(wxr_post.status),
|
||||||
content_markdown: content_markdown,
|
content_markdown: content_markdown,
|
||||||
content_checksum: content_checksum,
|
content_checksum: content_checksum,
|
||||||
content_preview: String.slice(content_markdown, 0, 200),
|
content_preview: String.slice(content_markdown, 0, 200),
|
||||||
@@ -236,7 +236,7 @@ defmodule BDS.ImportAnalysis do
|
|||||||
existing_id: existing && existing.id,
|
existing_id: existing && existing.id,
|
||||||
existing_title: existing && existing.title,
|
existing_title: existing && existing.title,
|
||||||
mime_type: wxr_media.mime_type,
|
mime_type: wxr_media.mime_type,
|
||||||
description: blank_to_nil(wxr_media.description),
|
description: BDS.MapUtils.blank_to_nil(wxr_media.description),
|
||||||
parent_wp_id: wxr_media.parent_id,
|
parent_wp_id: wxr_media.parent_id,
|
||||||
source_file: source_file,
|
source_file: source_file,
|
||||||
checksum: checksum,
|
checksum: checksum,
|
||||||
@@ -546,7 +546,4 @@ defmodule BDS.ImportAnalysis do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp blank_to_nil(nil), do: nil
|
|
||||||
defp blank_to_nil(""), do: nil
|
|
||||||
defp blank_to_nil(value), do: value
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -329,9 +329,9 @@ defmodule BDS.WxrParser do
|
|||||||
slug: item.post_name,
|
slug: item.post_name,
|
||||||
content: item.content,
|
content: item.content,
|
||||||
excerpt: item.excerpt,
|
excerpt: item.excerpt,
|
||||||
pub_date: blank_to_nil(item.pub_date),
|
pub_date: BDS.MapUtils.blank_to_nil(item.pub_date),
|
||||||
post_date: blank_to_nil(item.post_date),
|
post_date: BDS.MapUtils.blank_to_nil(item.post_date),
|
||||||
post_modified: blank_to_nil(item.post_modified),
|
post_modified: BDS.MapUtils.blank_to_nil(item.post_modified),
|
||||||
creator: item.creator,
|
creator: item.creator,
|
||||||
status: item.status,
|
status: item.status,
|
||||||
post_type: item.post_type,
|
post_type: item.post_type,
|
||||||
@@ -342,7 +342,7 @@ defmodule BDS.WxrParser do
|
|||||||
|
|
||||||
defp parse_media_item(item) do
|
defp parse_media_item(item) do
|
||||||
attachment_url = item.attachment_url
|
attachment_url = item.attachment_url
|
||||||
filename = attachment_url |> Path.basename() |> blank_to_nil() || ""
|
filename = attachment_url |> Path.basename() |> BDS.MapUtils.blank_to_nil() || ""
|
||||||
|
|
||||||
%{
|
%{
|
||||||
wp_id: parse_integer(item.post_id),
|
wp_id: parse_integer(item.post_id),
|
||||||
@@ -350,7 +350,7 @@ defmodule BDS.WxrParser do
|
|||||||
url: attachment_url,
|
url: attachment_url,
|
||||||
filename: filename,
|
filename: filename,
|
||||||
relative_path: relative_upload_path(attachment_url),
|
relative_path: relative_upload_path(attachment_url),
|
||||||
pub_date: blank_to_nil(item.pub_date),
|
pub_date: BDS.MapUtils.blank_to_nil(item.pub_date),
|
||||||
parent_id: parse_integer(item.post_parent),
|
parent_id: parse_integer(item.post_parent),
|
||||||
mime_type: MIME.from_path(filename),
|
mime_type: MIME.from_path(filename),
|
||||||
description: item.content
|
description: item.content
|
||||||
@@ -373,6 +373,4 @@ defmodule BDS.WxrParser do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp blank_to_nil(""), do: nil
|
|
||||||
defp blank_to_nil(value), do: value
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user