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.
gbfs stats actually correct.
50ea0c6 · gmorell · 2024-02-19 15:52
Files changed
modified
README.md
+10
−3
@@ -3,23 +3,30 @@
| 3 | 3 | |
| 4 | 4 | A generalized automated data collection platform, for the purpose of collecting and displaying timely data for wherever you may be. |
| 5 | 5 | |
| 6 | −It supports the creation of offerings data from 8 generalized sources at this time: | |
| 6 | +It supports the creation of offerings data from 8+ generalized sources, with more to come: | |
| 7 | 7 | |
| 8 | 8 | - GTFS (+RT) |
| 9 | −- GBFS | |
| 9 | +- GBFS (+EBikes) | |
| 10 | 10 | - iCal |
| 11 | 11 | - Tidal |
| 12 | 12 | - Ephem |
| 13 | 13 | - AirNow |
| 14 | 14 | - OpenWeather |
| 15 | 15 | - Cronos |
| 16 | +- Gitlab | |
| 16 | 17 | |
| 17 | 18 | These can be formed into reusable Queries that can be grouped into Visions. |
| 18 | 19 | Visions are interpreted by the Pythiae who forward them to clients via Ankyra. |
| 20 | +Foci are anchors for querying in physical space | |
| 21 | +Plani can be configured to provide the equivalent to an unanchored Foci updated via Ankyra | |
| 19 | 22 | |
| 20 | 23 | ## Public Demo |
| 21 | 24 | |
| 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 | |
| 25 | +The public demo instance https://ac.gmp.io/ is here, and the landing data displays queries for various entities around | |
| 26 | +- Assembly Row, Somerville | |
| 27 | +- Union Square, NYC | |
| 28 | +- Mission, SF | |
| 29 | +- Lincoln Park, Chicago | |
| 23 | 30 | |
| 24 | 31 | |
| 25 | 32 | ### Development |
modified
apps/room_gbfs/lib/room_gbfs/gbfs_worker.ex
+11
−7
@@ -197,6 +197,7 @@ defmodule RoomGbfs.Worker do
| 197 | 197 | cs |> Map.put(:ebikes, eb) |
| 198 | 198 | end) |
| 199 | 199 | |
| 200 | + RoomSanctum.Storage.truncate_ebikes_at_stations(id) | |
| 200 | 201 | Repo.insert_all( |
| 201 | 202 | RoomSanctum.Storage.GBFS.V1.EbikesAtStations, |
| 202 | 203 | data, |
@@ -378,19 +379,22 @@ defmodule RoomGbfs.Worker do
| 378 | 379 | defp via_tuple(name), do: {:via, Registry, {@registry, name}} |
| 379 | 380 | |
| 380 | 381 | def sys_info_as_stats(id) do |
| 382 | + s = Storage.get_sys_info!(:src, id) | |
| 381 | 383 | %{ |
| 382 | − operator: "balls" | |
| 384 | + name: s.name, | |
| 385 | + start_date: s.start_date, | |
| 386 | + system_id: s.system_id, | |
| 387 | + operator: s.operator, | |
| 388 | + tz: s.timezone, | |
| 383 | 389 | } |
| 384 | 390 | end |
| 385 | 391 | |
| 386 | 392 | def source_stats(id) do |
| 387 | 393 | %{ |
| 388 | − calendars: Storage.count_calendars(id), | |
| 389 | − directions: Storage.count_directions(id), | |
| 390 | − routes: Storage.count_routes(id), | |
| 391 | − stops: Storage.count_stops(id), | |
| 392 | − stop_times: Storage.count_stop_times(id), | |
| 393 | − trips: Storage.count_calendars(id) | |
| 394 | + stations: Storage.count_gbfs_stations(id), | |
| 395 | + slots: Storage.count_gbfs_slots(id), | |
| 396 | + bikes: Storage.count_gbfs_bikes(id), | |
| 397 | + ebikes: Storage.count_gbfs_ebikes(id), | |
| 394 | 398 | } |
| 395 | 399 | end |
| 396 | 400 | end |
modified
apps/room_sanctum/lib/room_sanctum/storage.ex
+46
−0
@@ -1144,6 +1144,11 @@ defmodule RoomSanctum.Storage do
| 1144 | 1144 | """ |
| 1145 | 1145 | def get_sys_info!(id), do: Repo.get!(SysInfo, id) |
| 1146 | 1146 | |
| 1147 | + def get_sys_info!(:src, source_id) do | |
| 1148 | + from(s in SysInfo, where: s.source_id == ^source_id) | |
| 1149 | + |> Repo.one() | |
| 1150 | + end | |
| 1151 | + | |
| 1147 | 1152 | @doc """ |
| 1148 | 1153 | Creates a sys_info. |
| 1149 | 1154 |
@@ -1649,6 +1654,11 @@ defmodule RoomSanctum.Storage do
| 1649 | 1654 | EbikesAtStations.changeset(ebikes_at_stations, attrs) |
| 1650 | 1655 | end |
| 1651 | 1656 | |
| 1657 | + def truncate_ebikes_at_stations(source_id) do | |
| 1658 | + from(e in EbikesAtStations, where: e.source_id == ^source_id) | |
| 1659 | + |> Repo.delete_all() | |
| 1660 | + end | |
| 1661 | + | |
| 1652 | 1662 | def get_current_information_for_bikestop(source_id, stop_id) do |
| 1653 | 1663 | q = |
| 1654 | 1664 | from st in StationStatus, |
@@ -1683,6 +1693,42 @@ defmodule RoomSanctum.Storage do
| 1683 | 1693 | Repo.one(q) |
| 1684 | 1694 | end |
| 1685 | 1695 | |
| 1696 | + def count_gbfs_stations(source_id) do | |
| 1697 | + from(s in StationInfo, | |
| 1698 | + where: | |
| 1699 | + s.source_id == ^source_id, | |
| 1700 | + select: fragment("count(*)") | |
| 1701 | + ) | |
| 1702 | + |> Repo.one() | |
| 1703 | + end | |
| 1704 | + | |
| 1705 | + def count_gbfs_slots(source_id) do | |
| 1706 | + from(s in StationStatus, | |
| 1707 | + where: | |
| 1708 | + s.source_id == ^source_id, | |
| 1709 | + select: fragment("sum(abs(?))", s.num_docks_available) | |
| 1710 | + ) | |
| 1711 | + |> Repo.one() | |
| 1712 | + end | |
| 1713 | + | |
| 1714 | + def count_gbfs_bikes(source_id) do | |
| 1715 | + from(s in StationStatus, | |
| 1716 | + where: | |
| 1717 | + s.source_id == ^source_id, | |
| 1718 | + select: fragment("sum(abs(?))", s.num_bikes_available) | |
| 1719 | + ) | |
| 1720 | + |> Repo.one() | |
| 1721 | + end | |
| 1722 | + | |
| 1723 | + def count_gbfs_ebikes(source_id) do | |
| 1724 | + from(s in StationStatus, | |
| 1725 | + where: | |
| 1726 | + s.source_id == ^source_id, | |
| 1727 | + select: fragment("sum(abs(?))", s.num_ebikes_available) | |
| 1728 | + ) | |
| 1729 | + |> Repo.one() | |
| 1730 | + end | |
| 1731 | + | |
| 1686 | 1732 | alias RoomSanctum.Storage.AirNow.ReportingArea |
| 1687 | 1733 | |
| 1688 | 1734 | @doc """ |
modified
apps/room_sanctum/lib/room_sanctum_web/icon_helpers.ex
+3
−0
@@ -67,6 +67,9 @@ defmodule RoomSanctumWeb.IconHelpers do
| 67 | 67 | |
| 68 | 68 | :cronos -> |
| 69 | 69 | "f017" |
| 70 | + | |
| 71 | + :gitlab -> | |
| 72 | + "f126" | |
| 70 | 73 | end |
| 71 | 74 | end |
| 72 | 75 | end |
Parents: 227b4d7