Skip to content

Commit a32e14a

Browse files
committed
Add read() step to migration
1 parent 8841963 commit a32e14a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/vyasa/corpus/migrator/restore.ex

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule Vyasa.Corpus.Migrator.Restore do
66

77
def run(source) do
88
source
9+
|> read()
910
|> Enum.map(fn x ->
1011
t =
1112
x["translations"]
@@ -18,24 +19,24 @@ defmodule Vyasa.Corpus.Migrator.Restore do
1819
%{
1920
x
2021
| "chapters" =>
21-
Enum.map(x["chapters"], fn %{"no" => no} = c ->
22-
c
23-
|> Map.put("translations", t[{"chapters", no}])
24-
|> Map.put(
25-
"voices",
26-
(is_list(v[no]) && v[no] |> Enum.map(fn %{"id" => _} = v -> v end)) || []
27-
)
28-
end),
29-
"verses" =>
30-
Enum.map(x["verses"], fn %{"id" => id} = v ->
31-
v |> Map.put("translations", t[{"verses", id}])
32-
end)
22+
Enum.map(x["chapters"], fn %{"no" => no} = c ->
23+
c
24+
|> Map.put("translations", t[{"chapters", no}])
25+
|> Map.put(
26+
"voices",
27+
(is_list(v[no]) && v[no] |> Enum.map(fn %{"id" => _} = v -> v end)) || []
28+
)
29+
end),
30+
"verses" =>
31+
Enum.map(x["verses"], fn %{"id" => id} = v ->
32+
v |> Map.put("translations", t[{"verses", id}])
33+
end)
3334
}
3435
end)
3536
|> Enum.map(
3637
&(%Vyasa.Written.Source{}
37-
|> Vyasa.Written.Source.gen_changeset(&1)
38-
|> Vyasa.Repo.insert!())
38+
|> Vyasa.Written.Source.gen_changeset(&1)
39+
|> Vyasa.Repo.insert!())
3940
)
4041

4142
# events are dependent on both verse and voice

0 commit comments

Comments
 (0)