[84152] branches/gsoc11-statistics/stats-server/app
derek at macports.org
derek at macports.org
Mon Sep 19 10:38:31 PDT 2011
Revision: 84152
http://trac.macports.org/changeset/84152
Author: derek at macports.org
Date: 2011-09-19 10:38:30 -0700 (Mon, 19 Sep 2011)
Log Message:
-----------
Moved gather_frequencies from OsStatistic controller to model, where it belongs.
gather_frequencies is now OsStatistic.frequencies
Modified Paths:
--------------
branches/gsoc11-statistics/stats-server/app/controllers/os_statistics_controller.rb
branches/gsoc11-statistics/stats-server/app/models/os_statistic.rb
Modified: branches/gsoc11-statistics/stats-server/app/controllers/os_statistics_controller.rb
===================================================================
--- branches/gsoc11-statistics/stats-server/app/controllers/os_statistics_controller.rb 2011-09-19 17:35:11 UTC (rev 84151)
+++ branches/gsoc11-statistics/stats-server/app/controllers/os_statistics_controller.rb 2011-09-19 17:38:30 UTC (rev 84152)
@@ -15,37 +15,9 @@
end
end
- # Returns a hash of frequency hashes with a key for each column
- # The frequency hash contains counts of the number of times a value has
- # appeared in its column.
- # e.g. If "2.0.0" appears 8 times in the "macports_version" column then
- # frequencies["macports_version"]["2.0.0"] == 8
- def gather_frequencies
-
- columns = { "macports_version" => Hash.new(0),
- "osx_version" => Hash.new(0),
- "os_arch" => Hash.new(0),
- "os_platform" => Hash.new(0),
- "build_arch" => Hash.new(0),
- "gcc_version" => Hash.new(0),
- "xcode_version" => Hash.new(0)
- }
-
- OsStatistic.find_each do |os_stat|
- # For each column in OsStatistics count the number of occurrences of a particular value
- columns.each do |column, hash|
- value = os_stat.attributes[column]
- hash[value] = hash[value] + 1
- end
- end
-
- return columns
- end
-
-
def index
@charts = Hash.new
- frequencies = gather_frequencies
+ frequencies = OsStatistic.frequencies
# Add charts for each type of data
frequencies.each do |column, data_hash|
Modified: branches/gsoc11-statistics/stats-server/app/models/os_statistic.rb
===================================================================
--- branches/gsoc11-statistics/stats-server/app/models/os_statistic.rb 2011-09-19 17:35:11 UTC (rev 84151)
+++ branches/gsoc11-statistics/stats-server/app/models/os_statistic.rb 2011-09-19 17:38:30 UTC (rev 84152)
@@ -53,4 +53,31 @@
return os_stats.save
end
+ # Returns a hash of frequency hashes with a key for each column
+ # The frequency hash contains counts of the number of times a value has
+ # appeared in its column.
+ # e.g. If "2.0.0" appears 8 times in the "macports_version" column then
+ # frequencies["macports_version"]["2.0.0"] == 8
+ def self.frequencies
+
+ columns = { "macports_version" => Hash.new(0),
+ "osx_version" => Hash.new(0),
+ "os_arch" => Hash.new(0),
+ "os_platform" => Hash.new(0),
+ "build_arch" => Hash.new(0),
+ "gcc_version" => Hash.new(0),
+ "xcode_version" => Hash.new(0)
+ }
+
+ OsStatistic.find_each do |os_stat|
+ # For each column in OsStatistics count the number of occurrences of a particular value
+ columns.each do |column, hash|
+ value = os_stat.attributes[column]
+ hash[value] = hash[value] + 1
+ end
+ end
+
+ return columns
+ end
+
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110919/f4c186c2/attachment.html>
More information about the macports-changes
mailing list