neiam
/apollos_crib
It's Apollo's Crib
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions failure · Badges · Packages
⭐
Log in to mark this repository.
add stats calculator framework to get a better feel of how long imports are taking
a7c4807 · gmorell · 2023-06-16 23:31
Files changed
modified
README.md
+10
−1
@@ -19,4 +19,13 @@ Visions are interpreted by the Pythiae who forward them to clients via Ankyra.
| 19 | 19 | |
| 20 | 20 | ## Public Demo |
| 21 | 21 | |
| 22 | −The public demo instance https://ac.gmp.io/ is here, and the landing data displays queries for various entities around Assembly Row, Somerville, MA, US | |
| 22 | +The public demo instance https://ac.gmp.io/ is here, and the landing data displays queries for various entities around Assembly Row, Somerville, MA, US | |
| 23 | + | |
| 24 | + | |
| 25 | +### Development | |
| 26 | + | |
| 27 | +Debian/Ubuntu users may need to isntall `erlang-xmerl` | |
| 28 | + | |
| 29 | +#### Migrations | |
| 30 | + | |
| 31 | +Migrations need to be run from within the `room_sanctum`/`room_hermes` directories in that order. |
modified
apps/room_gtfs/lib/room_gtfs/gtfs_worker.ex
+12
−0
@@ -152,6 +152,18 @@ defmodule RoomGtfs.Worker do
| 152 | 152 | end |
| 153 | 153 | |
| 154 | 154 | defp via_tuple(name), do: {:via, Registry, {@registry, name}} |
| 155 | + | |
| 156 | + def source_stats(id) do | |
| 157 | + | |
| 158 | + %{ | |
| 159 | + calendars: Storage.count_calendars(id), | |
| 160 | + directions: Storage.count_directions(id), | |
| 161 | + routes: Storage.count_routes(id), | |
| 162 | + stops: Storage.count_stops(id), | |
| 163 | + stop_times: Storage.count_stop_times(id), | |
| 164 | + trips: Storage.count_calendars(id), | |
| 165 | + } | |
| 166 | + end | |
| 155 | 167 | end |
| 156 | 168 | |
| 157 | 169 | defmodule RoomGtfs.Worker.RT do |
modified
apps/room_sanctum/lib/room_sanctum/storage.ex
+54
−0
@@ -132,6 +132,15 @@ defmodule RoomSanctum.Storage do
| 132 | 132 | Repo.all(Calendar) |
| 133 | 133 | end |
| 134 | 134 | |
| 135 | + def list_calendars(source_id) do | |
| 136 | + from(p in Calendar, where: p.source_id == ^source_id) | |
| 137 | + |> Repo.all | |
| 138 | + end | |
| 139 | + | |
| 140 | + def count_calendars(source_id) do | |
| 141 | + Repo.one(from p in Calendar, where: p.source_id == ^source_id, select: count(p.id)) | |
| 142 | + end | |
| 143 | + | |
| 135 | 144 | @doc """ |
| 136 | 145 | Gets a single calendar. |
| 137 | 146 |
@@ -242,6 +251,15 @@ defmodule RoomSanctum.Storage do
| 242 | 251 | Repo.all(Direction) |
| 243 | 252 | end |
| 244 | 253 | |
| 254 | + def list_directions(source_id) do | |
| 255 | + from(p in Direction, where: p.source_id == ^source_id) | |
| 256 | + |> Repo.all | |
| 257 | + end | |
| 258 | + | |
| 259 | + def count_directions(source_id) do | |
| 260 | + Repo.one(from p in Direction, where: p.source_id == ^source_id, select: count(p.id)) | |
| 261 | + end | |
| 262 | + | |
| 245 | 263 | @doc """ |
| 246 | 264 | Gets a single direction. |
| 247 | 265 |
@@ -352,6 +370,15 @@ defmodule RoomSanctum.Storage do
| 352 | 370 | Repo.all(Route) |
| 353 | 371 | end |
| 354 | 372 | |
| 373 | + def list_routes(source_id) do | |
| 374 | + from(p in Route, where: p.source_id == ^source_id) | |
| 375 | + |> Repo.all | |
| 376 | + end | |
| 377 | + | |
| 378 | + def count_routes(source_id) do | |
| 379 | + Repo.one(from p in Route, where: p.source_id == ^source_id, select: count(p.id)) | |
| 380 | + end | |
| 381 | + | |
| 355 | 382 | @doc """ |
| 356 | 383 | Gets a single route. |
| 357 | 384 |
@@ -462,6 +489,15 @@ defmodule RoomSanctum.Storage do
| 462 | 489 | Repo.all(StopTime) |
| 463 | 490 | end |
| 464 | 491 | |
| 492 | + def list_stop_times(source_id) do | |
| 493 | + from(p in StopTime, where: p.source_id == ^source_id) | |
| 494 | + |> Repo.all | |
| 495 | + end | |
| 496 | + | |
| 497 | + def count_stop_times(source_id) do | |
| 498 | + Repo.one(from p in StopTime, where: p.source_id == ^source_id, select: count(p.id)) | |
| 499 | + end | |
| 500 | + | |
| 465 | 501 | @doc """ |
| 466 | 502 | Gets a single stop_time. |
| 467 | 503 |
@@ -591,6 +627,15 @@ defmodule RoomSanctum.Storage do
| 591 | 627 | Repo.all(Stop) |
| 592 | 628 | end |
| 593 | 629 | |
| 630 | + def list_stops(source_id) do | |
| 631 | + from(p in Stop, where: p.source_id == ^source_id) | |
| 632 | + |> Repo.all | |
| 633 | + end | |
| 634 | + | |
| 635 | + def count_stops(source_id) do | |
| 636 | + Repo.one(from p in Stop, where: p.source_id == ^source_id, select: count(p.id)) | |
| 637 | + end | |
| 638 | + | |
| 594 | 639 | @doc """ |
| 595 | 640 | Gets a single stop. |
| 596 | 641 |
@@ -701,6 +746,15 @@ defmodule RoomSanctum.Storage do
| 701 | 746 | Repo.all(Trip) |
| 702 | 747 | end |
| 703 | 748 | |
| 749 | + def list_trips(source_id) do | |
| 750 | + from(p in Trip, where: p.source_id == ^source_id) | |
| 751 | + |> Repo.all | |
| 752 | + end | |
| 753 | + | |
| 754 | + def count_trips(source_id) do | |
| 755 | + Repo.one(from p in Trip, where: p.source_id == ^source_id, select: count(p.id)) | |
| 756 | + end | |
| 757 | + | |
| 704 | 758 | @doc """ |
| 705 | 759 | Gets a single trip. |
| 706 | 760 |
modified
apps/room_sanctum/lib/room_sanctum_web/live/cfg_source_live/show.html.heex
+18
−5
@@ -104,18 +104,31 @@
| 104 | 104 | </div> |
| 105 | 105 | </div> |
| 106 | 106 | </div> |
| 107 | − <!-- | |
| 108 | − <%= if @stats != nil do %> | |
| 107 | + | |
| 108 | + <%= if @stats != %{} do %> | |
| 109 | 109 | <div class="flex"> |
| 110 | 110 | <div class="card card-compact w-full bg-base-100 shadow-xl m-2"> |
| 111 | 111 | <div class="card-body"> |
| 112 | − <h3 class="card-title">Calculated Results</h3> | |
| 113 | − <%= @stats %> | |
| 112 | + <h3 class="card-title">Stats Results</h3> | |
| 113 | + <div class="flex"> | |
| 114 | + <%= for {type,data} <- @stats do %> | |
| 115 | + <div> | |
| 116 | + <div class="font-bold uppercase"><%= type %> </div> | |
| 117 | + <ul class="menu bg-primary"> | |
| 118 | + <%= for {data_k, data_v} <- data do %> | |
| 119 | + <li class="text-primary-content uppercase"> | |
| 120 | + <a><%= data_k %> <span class="text-accent"><%= data_v %></span></a> | |
| 121 | + </li> | |
| 122 | + <% end %> | |
| 123 | + </ul> | |
| 124 | + </div> | |
| 125 | + <% end %> | |
| 126 | + </div> | |
| 114 | 127 | </div> |
| 115 | 128 | </div> |
| 116 | 129 | </div> |
| 117 | 130 | <% end %> |
| 118 | − --> | |
| 131 | + | |
| 119 | 132 | <div class="flex"> |
| 120 | 133 | <div class="card card-compact w-full bg-base-100 shadow-xl m-2"> |
| 121 | 134 | <div class="card-body"> |
modified
docker-compose.yml
+1
−1
@@ -8,7 +8,7 @@ services:
| 8 | 8 | volumes: |
| 9 | 9 | - pgdata:/var/lib/postgresql/data/ |
| 10 | 10 | environment: |
| 11 | − - POSTGRES_DB=postgres | |
| 11 | + - POSTGRES_DB=room_sanctum_dev | |
| 12 | 12 | - POSTGRES_USER=postgres |
| 13 | 13 | - POSTGRES_PASSWORD=postgres |
| 14 | 14 | - POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology |
Parents: ffe18a8