-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
196 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
class Dataset < ActiveRecord::Base | ||
belongs_to :city | ||
|
||
# calculo el parámetro que falta en caso de que falte sólo uno, hay varios así | ||
def before_save | ||
modes = ['pedestrian_share', 'motorized_share', 'public_transport_share', 'bike_share'] | ||
|
||
modes.each do |mode| | ||
modes2 = modes - [mode] | ||
# si el valor actual es nil y el resto de valores no lo son... | ||
if eval("self.#{mode}").nil? and modes2.delete_if { |met| eval("self.#{met}.nil?") }.size == 3 | ||
sum = 0 | ||
modes2.each { |meth| sum += eval("self.#{meth}") } | ||
eval("self.#{mode} = 100.0 - sum") | ||
end | ||
end | ||
end | ||
|
||
def bike_rank | ||
Dataset.count :conditions => ['city_id != ? and bike_share >= ?', self.id, self.bike_share], :order => 'bike_share desc' | ||
end | ||
def pedestrian_rank | ||
Dataset.count :conditions => ['city_id != ? and pedestrian_share >= ? and year = ?', self.id, self.pedestrian_share, self.year], :order => 'pedestrian_share desc' | ||
end | ||
def motorized_rank | ||
Dataset.count :conditions => ['city_id != ? and motorized_share >= ? and year = ?', self.id, self.motorized_share, self.year], :order => 'motorized_share desc' | ||
end | ||
def public_transport_rank | ||
Dataset.count :conditions => ['city_id != ? and public_transport_share >= ? and year = ?', self.id, self.public_transport_share, self.year], :order => 'public_transport_share desc' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class="rankings"> | ||
<h2>Los que más se mueven a pie</h2> | ||
<ol> | ||
<% @pedestrian_rank.each do |dataset| %> | ||
<li><%= link_to dataset.city.name, city_path(dataset.city) %> <span><%= dataset.pedestrian_share %></span></li> | ||
<% end %> | ||
</ol> | ||
|
||
<h2>Los que más se mueven en coche</h2> | ||
<ol> | ||
<% @car_rank.each do |dataset| %> | ||
<li><%= link_to dataset.city.name, city_path(dataset.city) %> <span><%= dataset.motorized_share %></span></li> | ||
<% end %> | ||
</ol> | ||
|
||
<h2>Los que más se mueven en bici</h2> | ||
<ol> | ||
<% @bike_rank.each do |dataset| %> | ||
<li><%= link_to dataset.city.name, city_path(dataset.city) %> <span><%= dataset.bike_share %></span></li> | ||
<% end %> | ||
</ol> | ||
|
||
<h2>Los que más se mueven en transporte público</h2> | ||
<ol> | ||
<% @bus_rank.each do |dataset| %> | ||
<li><%= link_to dataset.city.name, city_path(dataset.city) %> <span><%= dataset.public_transport_share %></span></li> | ||
<% end %> | ||
</ol> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p class="claim" style="width: 100%;""> | ||
Modal Kombat es una aplicación construida a partir de datos publicados en el <a href="http://epp.eurostat.ec.europa.eu/">portal Eurostat</a>, concretamente de la sección dedicada al proyecto <a href="http://www.urbanaudit.org">Urban Audit</a>. Los datos están un poco desactualizados, pero sirven para sacar conclusiones sobre la forma que tenemos de desplazarnos en las ciudades europeas. | ||
</p> | ||
<p class="claim" style="width: 100%;""> | ||
Gracias a la gente de <a href="http://www.abredatos.es">Abredatos</a> por darnos una excusa para pasar un fin de semana pensando en <a href="http://en.wikipedia.org/wiki/Open_Data">Open Data</a> :-) | ||
</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters