Skip to content

Instantly share code, notes, and snippets.

@bjvoth
Created July 12, 2018 18:43
Show Gist options
  • Save bjvoth/a9eac34f884fb9297aee23e6ea16aeb5 to your computer and use it in GitHub Desktop.
Save bjvoth/a9eac34f884fb9297aee23e6ea16aeb5 to your computer and use it in GitHub Desktop.
Toro Task Error code snippets
{:ok, since} = DateTime.from_naive(~N[2018-05-01 13:26:08.003], "Etc/UTC")
iex(packlane@127.0.0.1)7> since
#DateTime<2018-05-01 13:26:08.003Z>
success_tasks = Toro.Task.find_by_inserted_at(since) |> Toro.Task.by_status("success") |> Lumbergh.Repo.all
iex(packlane@127.0.0.1)8> success_tasks |> Enum.count
10000
error_tasks = Toro.Task.find_by_inserted_at(since) |> Toro.Task.by_status("error") |> Lumbergh.Repo.all
iex(packlane@127.0.0.1)9> error_tasks |> Enum.count
556
easypost_error_tasks = error_tasks |> Enum.filter(fn task -> task.subtype == "easypost" end)
iex(packlane@127.0.0.1)10> easypost_error_tasks |> Enum.count
517
by_shipment_ids = Enum.group_by(easypost_error_tasks, fn task -> Map.get(task, :payload)["params"]["result"]["shipment_id"] end)
iex(packlane@127.0.0.1)11> Enum.count(by_shipment_ids)
143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment