frfr

4a9b9fd · gmorell · 2023-07-28 05:07

5 files +9 -7

Files changed

modified apps/room_gtfs/lib/room_gtfs/gtfs_worker.ex
+9 −7
@@ -126,15 +126,12 @@ defmodule RoomGtfs.Worker do
126 126 {:ok, child_rt} = Parent.start_child({RoomGtfs.Worker.RT, opts})
127 127 {:ok, child_static} = Parent.start_child({RoomGtfs.Worker.Static, opts})
128 128
129 − {:ok, pid} = Postgrex.start_link(opts)
130 −
131 129 {:ok,
132 130 %{
133 131 id: opts[:name],
134 132 inst: nil,
135 133 child_rt: child_rt,
136 − child_static: child_static,
137 − pg_pid: pid,
134 + child_static: child_static
138 135 }}
139 136 end
140 137
@@ -405,9 +402,14 @@ defmodule RoomGtfs.Worker.Static do
405 402 end
406 403
407 404 def init(opts) do
405 +
406 + pgopts = RoomSanctum.Repo.config()
407 + {:ok, pid} = Postgrex.start_link(pgopts)
408 +
408 409 {:ok,
409 410 %{
410 − id: opts[:name]
411 + id: opts[:name],
412 + pg_pid: pid
411 413 }}
412 414 end
413 415
@@ -473,7 +475,7 @@ defmodule RoomGtfs.Worker.Static do
473 475 |> Enum.join(", ")
474 476 end
475 477
476 − defp write_file(contents, type, id, pid, via: :copy) do
478 + defp write_file(contents, type, id, pid) do
477 479 datetime = NaiveDateTime.local_now()
478 480 Logger.info("GTFS::#{id} writing #{type} (c)")
479 481
@@ -784,7 +786,7 @@ end
784 786 bcast(state.id, file_to_atom(e.file_name), file_to_order(e.file_name), 9)
785 787
786 788 Unzip.file_stream!(unzip, e.file_name)
787 − |> write_file(file_to_atom(e.file_name), state.id, state.pg_pid, via: :copy)
789 + |> write_file(file_to_atom(e.file_name), state.id, state.pg_pid)
788 790
789 791 # bcast(state.id, :stop_times, 8, 9)
790 792 end

Parents: e9be9f2