ok, fixed gitlab !

252a2eb · gmorell · 2024-02-04 23:38

17 files +25 -9

Files changed

modified apps/room_gitlab/lib/room_gitlab/gitlab_worker.ex
+6 −4
@@ -40,8 +40,6 @@ defmodule RoomGitlab.Worker do
40 40 initial_delay: 6
41 41 )
42 42
43 − IO.puts("gottem")
44 −
45 43 {:ok,
46 44 %{
47 45 id: opts[:name],
@@ -176,7 +174,7 @@ defmodule RoomGitlab.Worker do
176 174 end
177 175
178 176 def handle_cast(:query_projects, state) do
179 − # IO.inspect({state, state |> Map.get(:inst)})
177 + Logger.info("GLab::#{state.inst.id} Querying Projects")
180 178
181 179 case state |> Map.get(:inst, %{}) |> Map.get(:enabled) do
182 180 true ->
@@ -198,10 +196,12 @@ defmodule RoomGitlab.Worker do
198 196
199 197 def handle_cast(:query_commits, state) do
200 198 if state |> Map.get(:inst, %{}) |> Map.get(:enabled) do
199 + IO.inspect(state.projects)
201 200 all =
202 201 state.projects
203 202 |> Enum.map(
204 203 fn p ->
204 + Logger.info("GLab::#{state.inst.id} Querying Commits for #{p["name"]}")
205 205 {:ok, ref} =
206 206 do_gitlab_reqa(state.inst.config.url, state.inst.config.pat, :commits, p["id"])
207 207
@@ -227,14 +227,16 @@ defmodule RoomGitlab.Worker do
227 227 def handle_cast({:query_jobs, query}, state) do
228 228 case state |> Map.get(:inst, %{}) |> Map.get(:enabled) do
229 229 x when x in [false, nil] ->
230 − Logger.debug("Instance not populated")
230 + Logger.info("Instance not populated")
231 231 {:noreply, state}
232 232
233 233 true ->
234 + Logger.info("GLab::#{state.inst.id} Querying Jobs")
234 235 all =
235 236 state.commits
236 237 |> Enum.filter(fn {k, v} -> v end)
237 238 |> Enum.map(fn {id, enabled} ->
239 + Logger.debug("GLab::#{state.inst.id} Querying Jobs for #{id}")
238 240 {:ok, ref} = do_gitlab_reqa(state.inst.config.url, state.inst.config.pat, :jobs, id)
239 241
240 242 {:ok, fd} = StringIO.open("")
modified apps/room_sanctum/lib/room_sanctum/workers/vision_worker.ex
+3 −3
@@ -101,10 +101,10 @@ defmodule RoomSanctum.Worker.Vision do
101 101 RoomCronos.Worker.query_cronos(q.id, q.query)
102 102
103 103 :gitlab ->
104 − case RoomGitlab.Worker.pid(q.id) do
104 + case RoomGitlab.Worker.pid(q.source.id) do
105 105 nil -> []
106 − val -> (Process.alive?(RoomGitlab.Worker.pid(q.id)) &&
107 − RoomGitlab.Worker.read_jobs(q.id, q.query)) || []
106 + val -> (Process.alive?(RoomGitlab.Worker.pid(q.source.id)) &&
107 + RoomGitlab.Worker.read_jobs(q.source.id, q.query)) || []
108 108 end
109 109 end
110 110
modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_query_live/show.ex
+2 −2
@@ -65,13 +65,13 @@ defmodule RoomSanctumWeb.QueryLive.Show do
65 65 :cronos ->
66 66 RoomCronos.Worker.query_cronos(
67 67 # we want the query's name here
68 − socket.assigns.query.id,
68 + socket.assigns.query.source.id,
69 69 socket.assigns.query.query
70 70 )
71 71
72 72 :gitlab ->
73 73 RoomGitlab.Worker.read_jobs(
74 − socket.assigns.query.id,
74 + socket.assigns.query.source.id,
75 75 socket.assigns.query.query
76 76 )
77 77 end
modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_source_live/show.ex
+4 −0
@@ -69,6 +69,10 @@ defmodule RoomSanctumWeb.SourceLive.Show do
69 69
70 70 "ical" ->
71 71 RoomCalendar.Worker.update_static_data(id)
72 + "gitlab-projects" ->
73 + RoomGitlab.Worker.query_projects(id)
74 + "gitlab-commits" ->
75 + RoomGitlab.Worker.query_commits(id)
72 76 end
73 77
74 78 {:noreply, socket}
modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_source_live/show.html.heex
+10 −0
@@ -76,6 +76,16 @@
76 76 <button class="btn btn-secondary" phx-click="do-update" phx-value-type="ical" phx-value-id={@source.id}>
77 77 Update
78 78 </button>
79 + <% :gitlab -> %>
80 + <button class="btn btn-secondary" phx-click="do-update" phx-value-type="gitlab-projects" phx-value-id={@source.id}>
81 + Projects
82 + </button>
83 + <button class="btn btn-secondary" phx-click="do-update" phx-value-type="gitlab-commits" phx-value-id={@source.id}>
84 + Commits
85 + </button>
86 + <button class="btn btn-secondary" phx-click="do-update" phx-value-type="gitlab-jobs" phx-value-id={@source.id}>
87 + Jobs
88 + </button>
79 89 <% _default -> %>
80 90
81 91 <% end %>

Parents: 2c7620f