Skip to content

Commit

Permalink
Refactor "Records" Page -> "Metrics"
Browse files Browse the repository at this point in the history
It was feeling like there wasn't enough semantic difference between
"Archives" (as in Sweep Ops Archives) and "Records". Archives are / can
be Records and vice versa. Metrics makes it more clear, I think, while
also being more encompassing of different kinds of scores, rankings,
etc. (Naming things is hard.)

"Record" is also a bit confusing as a programmer. Especially in a
framework that uses ActiveRecord at its core.
  • Loading branch information
Paul DobbinSchmaltz committed Oct 28, 2024
1 parent 87dc989 commit 0c8a8f0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
7 changes: 7 additions & 0 deletions app/controllers/metrics_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class MetricsController < ApplicationController
def index
@view = Metrics::Index.new
end
end
7 changes: 0 additions & 7 deletions app/controllers/records_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/application/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<span class="max-sm:hidden">Sweep Ops Archive</span>
<% end %>
</li>
<li><%= active_link_to("Records", records_path) %></li>
<li><%= active_link_to("Metrics", metrics_path) %></li>
</ul>

<%= render("application/username") %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<% title("Records") %>
<% title("Metrics") %>
<% cache_unless(App.debug?, @view.cache_key) do %>
<div class="container mx-auto space-y-12">
<h1><%= title %></h1>

<div class="space-y-6">
<div class="space-y-10">
<h2
class="
border-b border-dotted
border-b-300 dark:border-b-neutral-600
"
>Engagements</h2>

<h3 class="h2">Top Scores</h3>

<div class="flex max-lg:flex-col gap-x-24 gap-y-6">
<% @view.top_games_by_type.each do |top_games| %>
<div class="space-y-3">
<h3><%= top_games.type %></h3>
<h4 class="h3"><%= top_games.type %></h4>

<table
class="
Expand Down
22 changes: 11 additions & 11 deletions app/views/records/index.rb → app/views/metrics/index.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Records::Index is a View Model for displaying the Records Index page.
class Records::Index
# Metrics::Index is a View Model for displaying the Metrics Index page.
class Metrics::Index
TOP_RECORDS_LIMIT = 3
NO_VALUE_INDICATOR = "—"

Expand All @@ -19,8 +19,8 @@ def top_games_by_type

def no_value_indicator = NO_VALUE_INDICATOR

# Records::Index::TopGames
class TopGames
# Metrics::Index::Games
class Games
include AbstractBaseClassBehaviors

as_abstract_class
Expand All @@ -37,7 +37,7 @@ def base_arel
Game.for_status_alliance_wins.by_score_asc.limit(TOP_RECORDS_LIMIT)
end

# Records::Index::TopGames::Listing
# Metrics::Index::Games::Listing
class Listing
include WrapMethodBehaviors

Expand All @@ -58,20 +58,20 @@ def to_model = @model
end
end

# Records::Index::BeginnerGames
class BeginnerGames < Records::Index::TopGames
# Metrics::Index::BeginnerGames
class BeginnerGames < Metrics::Index::Games
def type = Board::Settings::BEGINNER
def arel = base_arel.for_beginner_type
end

# Records::Index::IntermediateGames
class IntermediateGames < Records::Index::TopGames
# Metrics::Index::IntermediateGames
class IntermediateGames < Metrics::Index::Games
def type = Board::Settings::INTERMEDIATE
def arel = base_arel.for_intermediate_type
end

# Records::Index::ExpertGames
class ExpertGames < Records::Index::TopGames
# Metrics::Index::ExpertGames
class ExpertGames < Metrics::Index::Games
def type = Board::Settings::EXPERT
def arel = base_arel.for_expert_type
end
Expand Down
6 changes: 3 additions & 3 deletions app/views/pwa/manifest.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"icons": [{ "src": "<%= image_url("heroicons/archive-box.svg") %>", "sizes": "any" }]
},
{
"name": "Records",
"description": "Players & Games Ranking",
"url": "<%= records_path %>",
"name": "Metrics",
"description": "Top Players & Games",
"url": "<%= metrics_path %>",
"icons": [{ "src": "<%= image_url("heroicons/trophy.svg") %>", "sizes": "any" }]
},
{
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
resources :games, only: :show, module: :users
end

resources :records, only: :index
resources :metrics, only: :index

resource :about, controller: :about, only: :show

Expand Down

0 comments on commit 0c8a8f0

Please sign in to comment.