~ihabunek/triglav

248d445efaf6ff9a19f9fc8c8ed4359a87aeb85b — Ivan Habunek 11 months ago 447e986
Data status page
M assets/css/app.scss => assets/css/app.scss +5 -0
@@ 46,6 46,10 @@ table {
    background-color: WhiteSmoke;
    text-align: left;
  }

  tr:hover {
    background-color: WhiteSmoke;
  }
}

summary {


@@ 161,6 165,7 @@ a.josm-remote {
.tag { color: DimGray; white-space: nowrap; }
.smaller { font-size: 0.9rem; }
.hidden { visibility: hidden; }
.w-full { width: 100%; }

// Phoenix crap


A lib/triglav/schemas/osmosis/replication_changes.ex => lib/triglav/schemas/osmosis/replication_changes.ex +38 -0
@@ 0,0 1,38 @@
defmodule Triglav.Schemas.Osmosis.ReplicationChanges do
  use Ecto.Schema

  @schema_prefix :osmosis

  @type t() :: %__MODULE__{
          __meta__: Ecto.Schema.Metadata.t(),
          tstamp: DateTime.t(),
          nodes_modified: integer(),
          nodes_added: integer(),
          nodes_deleted: integer(),
          ways_modified: integer(),
          ways_added: integer(),
          ways_deleted: integer(),
          relations_modified: integer(),
          relations_added: integer(),
          relations_deleted: integer(),
          changesets_applied: [integer()],
          earliest_timestamp: DateTime.t(),
          latest_timestamp: DateTime.t()
        }

  schema "replication_changes" do
    field :tstamp, :utc_datetime
    field :nodes_modified, :integer
    field :nodes_added, :integer
    field :nodes_deleted, :integer
    field :ways_modified, :integer
    field :ways_added, :integer
    field :ways_deleted, :integer
    field :relations_modified, :integer
    field :relations_added, :integer
    field :relations_deleted, :integer
    field :changesets_applied, {:array, :integer}
    field :earliest_timestamp, :utc_datetime
    field :latest_timestamp, :utc_datetime
  end
end

M lib/triglav/zet/osmosis.ex => lib/triglav/zet/osmosis.ex +8 -0
@@ 5,6 5,7 @@ defmodule Triglav.Zet.Osmosis do
  alias Triglav.Repo
  alias Triglav.Schemas.Osmosis.Node
  alias Triglav.Schemas.Osmosis.Relation
  alias Triglav.Schemas.Osmosis.ReplicationChanges
  alias Triglav.Schemas.Osmosis.Way

  import Ecto.Query


@@ 17,6 18,13 @@ defmodule Triglav.Zet.Osmosis do
    |> Repo.all()
  end

  def list_replication_changes(opts \\ []) do
    limit = Keyword.get(opts, :limit, 100)

    from(rc in ReplicationChanges, order_by: [desc: :tstamp], limit: ^limit)
    |> Repo.all()
  end

  defp pt_relations() do
    from(r in Relation,
      where:

M lib/triglav_web/controllers/home_controller.ex => lib/triglav_web/controllers/home_controller.ex +8 -0
@@ 1,7 1,15 @@
defmodule TriglavWeb.HomeController do
  use TriglavWeb, :controller

  alias Triglav.Zet.Osmosis

  def index(conn, _params) do
    render(conn, "index.html")
  end

  def data(conn, _params) do
    replication_changes = Osmosis.list_replication_changes()

    render(conn, "data.html", replication_changes: replication_changes)
  end
end

D lib/triglav_web/controllers/zet/home_controller.ex => lib/triglav_web/controllers/zet/home_controller.ex +0 -3
@@ 1,3 0,0 @@
defmodule TriglavWeb.Zet.HomeController do
  use TriglavWeb, :controller
end

M lib/triglav_web/router.ex => lib/triglav_web/router.ex +1 -0
@@ 17,6 17,7 @@ defmodule TriglavWeb.Router do
    pipe_through :browser

    get "/", HomeController, :index
    get "/data", HomeController, :data

    scope "/zet", alias: Zet, as: :zet do
      get "/routes", RoutesController, :index

A lib/triglav_web/templates/home/data.html.eex => lib/triglav_web/templates/home/data.html.eex +54 -0
@@ 0,0 1,54 @@
<style>
  .bl { border-left: 1px dotted gray }
</style>

<main role="main" class="container">
  <h1>Data overview</h1>

  <h2>OSM updates</h2>

  <p>Data is updated daily from Geofabrik.</p>

  <table class="w-full">
    <thead>
      <tr>
        <th rowspan="2">Updated at</th>
        <th colspan="3" class="bl">Nodes</th>
        <th colspan="3" class="bl">Ways</th>
        <th colspan="3" class="bl">Relations</th>
        <th rowspan="2" class="bl">Earliest timestamp</th>
        <th rowspan="2">Latest timestamp</th>
      </tr>
      <tr>
        <th class="bl">Add</th>
        <th>Del</th>
        <th>Mod</th>
        <th class="bl">Add</th>
        <th>Del</th>
        <th>Mod</th>
        <th class="bl">Add</th>
        <th>Del</th>
        <th>Mod</th>
      </tr>
    </thead>
    <tbody>
      <%= for changes <- @replication_changes do %>
      <tr>
        <td><%= changes.tstamp %></td>
        <td class="bl"><%= changes.nodes_added %></td>
        <td><%= changes.nodes_deleted %></td>
        <td><%= changes.nodes_modified %></td>
        <td class="bl"><%= changes.ways_added %></td>
        <td><%= changes.ways_deleted %></td>
        <td><%= changes.ways_modified %></td>
        <td class="bl"><%= changes.relations_added %></td>
        <td><%= changes.relations_deleted %></td>
        <td><%= changes.relations_modified %></td>
        <td class="bl"><%= changes.earliest_timestamp %></td>
        <td><%= changes.latest_timestamp %></td>
      </tr>
      <% end %>
    </tbody>
  </table>

</main>

M lib/triglav_web/views/home_view.ex => lib/triglav_web/views/home_view.ex +2 -1
@@ 1,5 1,6 @@
defmodule TriglavWeb.HomeView do
  use TriglavWeb, :view

  def title(_, _), do: "Home"
  def title("index.html", _), do: "Home"
  def title("data.html", _), do: "Data overview"
end