Skip to content

Commit

Permalink
Fix sync status
Browse files Browse the repository at this point in the history
  • Loading branch information
tspenov committed Jan 14, 2025
1 parent 686c66e commit 3c2ca5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions lib/sanbase/metric/registry/sync.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ defmodule Sanbase.Metric.Registry.Sync do
:ok <- check_initiate_env(),
{:ok, content} <- get_sync_content(metric_registry_ids),
{:ok, sync} <- store_sync_in_db(content),
:ok <- start_sync(sync),
{:ok, sync} <- Registry.SyncSchema.update_status(sync, "executing") do
{:ok, sync} <- Registry.SyncSchema.update_status(sync, "executing"),
:ok <- start_sync(sync) do
{:ok, sync}
end
end
Expand All @@ -50,7 +50,7 @@ defmodule Sanbase.Metric.Registry.Sync do
with :ok <- check_apply_env(),
{:ok, list} when is_list(list) <- Jason.decode(params["content"]),
:ok <- do_apply_sync_content(list),
:ok <- send_sync_completed_confirmation(params["confirmation_endpoint"]) do
{:ok, _} <- send_sync_completed_confirmation(params["confirmation_endpoint"]) do
:ok
end
end
Expand Down Expand Up @@ -106,10 +106,6 @@ defmodule Sanbase.Metric.Registry.Sync do

case Req.post(url, json: json) do
{:ok, %Req.Response{status: 200}} ->
# The status is set to executing and it will be set to completed
# once the other side responds to the /mark_metric_registry_sync_as_finished
# endpoint
{:ok, _} = Registry.SyncSchema.update_status(sync, "executing")
:ok

{:ok, %Req.Response{status: status, body: body}} ->
Expand Down
2 changes: 1 addition & 1 deletion lib/sanbase_web/controllers/metric_registry_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule SanbaseWeb.MetricRegistryController do
case Sanbase.Metric.Registry.Sync.apply_sync(
Map.take(params, ["content", "confirmation_endpoint"])
) do
{:ok, _sync} ->
:ok ->
conn
|> resp(200, "OK")
|> send_resp()
Expand Down

0 comments on commit 3c2ca5e

Please sign in to comment.