Skip to content

Commit

Permalink
Fix issues with string/atom mix in changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanIvanoff committed Jan 15, 2025
1 parent cc5a3cf commit c01ea08
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/sanbase/metric/registry/change_suggestion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ defmodule Sanbase.Metric.Registry.ChangeSuggestion do
# After change suggestion is applied, put the metric in a unverified state and mark
# is as not synced. Someone needs to manually verify the metric after it is tested.
# When the data is synced between stage and prod, the sync status will be updated.
# Note: Keep the keys as strings, not atoms, so the map is not mixed

# Convert all keys to strings so we don't get error if atom keys come from some caller
params = Map.new(params, fn {k, v} -> {to_string(k), v} end)
params = Map.merge(params, %{"is_verified" => false, "sync_status" => "not_synced"})

case Registry.changeset(registry, params) do
Expand Down
2 changes: 1 addition & 1 deletion lib/sanbase/metric/registry/sync.ex
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ defmodule Sanbase.Metric.Registry.Sync do
end

defp start_sync(sync) do
url = get_sync_target_url() |> IO.inspect()
url = get_sync_target_url()

json = %{
"sync_uuid" => sync.uuid,
Expand Down
2 changes: 0 additions & 2 deletions test/sanbase/metric_registry/metric_registry_sync_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ defmodule Sanbase.MetricRegistrySyncTest do
alias Sanbase.Metric.Registry

test "syncing", context do
Req.post("http://localhost:4000/sync_metric_registry?secret=secret_only_on_prod")

[m1_id, m2_id] = create_sync_requirements()

{:ok, m1} = Registry.by_id(m1_id)
Expand Down
2 changes: 1 addition & 1 deletion test/sanbase/metric_registry/metric_registry_test.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dsefmodule Sanbase.MetricRegistyTest do
defmodule Sanbase.MetricRegistyTest do
use Sanbase.DataCase
import ExUnit.CaptureLog

Expand Down

0 comments on commit c01ea08

Please sign in to comment.