Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Basic stats page #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/assets/stylesheets/v1.css.erb
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,28 @@ table.plaque_list td.geo {}
margin-bottom: 8px;
}

.stats {
max-width: 400px;
margin: 0 auto;
}

.stats .figure {
display: inline-block;
font-size: 50px;
font-weight: bold;
vertical-align: middle;
padding-right: 10px;
width: 200px;
text-align: right;
}

.stats .description {
font-size: 20px;
font-weight: bold;
vertical-align: middle;

}

/*********/

.alternate_formats {font-size: .8em; text-align: center; color: #888; margin-top: 2em; margin-bottom: 1em;}
Expand Down
34 changes: 34 additions & 0 deletions app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class StatsController < ApplicationController

def show

@plaques_count = Plaque.count
@people_count = Person.count
@countries_count = Area.count('country_id', :distinct => true)
@places_count = Area.count
@languages_count = Plaque.count('language_id', :distinct => true)
@organisations_count = Organisation.count
@photos_count = Photo.count
@users_count = User.count

respond_to do |format|
format.html
format.json {
render :json => {
'stats' => {
'plaques_count' => @plaques_count,
'people_count' => @people_count,
'countries_count' => @countries_count,
'places_count' => @places_count,
'languages_count' => @languages_count,
'organisations_count' => @organisations_count,
'photos_count' => @photos_count,
'users_count' => @users_count
}
}
}
end

end

end
42 changes: 42 additions & 0 deletions app/views/stats/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<article class="panel">
<header>
<h1>Open Plaques stats</h1>
</header>

<div class="stats">
<div>
<span class="figure"><%= @plaques_count %></span>
<span class="description">Total plaques</span>
</div>
<div>
<span class="figure"><%= @people_count %></span>
<span class="description">People mentioned</span>
</div>
<div>
<span class="figure"><%= @organisations_count %></span>
<span class="description">Organisations</span>
</div>
<div>
<span class="figure"><%= @countries_count %></span>
<span class="description">Countries</span>
</div>
<div>
<span class="figure"><%= @places_count %></span>
<span class="description">Cities and towns</span>
</div>
<div>
<span class="figure"><%= @photos_count %></span>
<span class="description">Photos</span>
</div>
<div>
<span class="figure"><%= @users_count %></span>
<span class="description">Contributors</span>
</div>
<div>
<span class="figure"><%= @languages_count %></span>
<span class="description">Languages</span>
</div>

</div>

</article>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
resource :contribute, :controller => :pages, :id => "contribute", :as => "contribute", :only => :show
resource :explore, :controller => :explore, :only => :show

resource :stats, :controller => :stats, :only => :show

# Generic resource for all pages
resources :pages

Expand Down