Skip to content

Commit 858f178

Browse files
author
Simon Funke
committed
improved api
1 parent cab3020 commit 858f178

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/controllers/country_maps_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class CountryMapsController < ApplicationController
22
# GET /country_maps
33
# GET /country_maps.json
44
def index
5-
@country_maps = CountryMap.all
5+
@country_maps = CountryMap.select([:name]).all
66

77
respond_to do |format|
88
format.html # index.html.erb

app/controllers/country_measurements_controller.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ class CountryMeasurementsController < ApplicationController
22
# GET /country_measurements
33
# GET /country_measurements.json
44
def index
5-
@country_measurements = CountryMeasurement.where(:country => params["country_map_id"])
5+
if params["country"].nil?
6+
@country_measurements = CountryMeasurement.select([:month, :NumberOfClientsSplitByClientAndByServer]).all
7+
else
8+
country = CountryMap.find_by_name(params["country"])
9+
if country.nil?
10+
@country_measurements = []
11+
else
12+
@country_measurements = CountryMeasurement.select([:month, :NumberOfClientsSplitByClientAndByServer]).where(:country => country.id)
13+
end
14+
end
615

716
respond_to do |format|
817
format.html # index.html.erb

0 commit comments

Comments
 (0)