File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -2,18 +2,6 @@ class StatsController < ApplicationController
22
33 # GET /stats[.json]
44 def show
5-
6- # GET /stats.json
7- # NOTE: Draft API that returns required-to-share data upon requests from other repos.
8- if request . url . end_with? '.json'
9- @stats_data = {
10- active_dojos : Dojo . active_dojos_count ,
11- }
12-
13- render json : @stats_data
14- return
15- end
16-
175 # 2012年1月1日〜2024年12月31日までの集計結果
186 @period_start = 2012
197 @period_end = 2024
@@ -116,6 +104,20 @@ def show
116104 @data_by_prefecture [ p . name ] = Dojo . active . where ( prefecture_id : p . id ) . sum ( :counter )
117105 end
118106 @data_by_prefecture_count = @data_by_prefecture . select { |k , v | v >0 } . count
107+
108+ respond_to do |format |
109+ # No corresponding View for now.
110+ # Only for API: GET /dojos.json
111+ format . html # => app/views/stats/show.html.erb
112+ format . json { render json : {
113+ # NOTE: Add JSON data upon requests
114+ active_dojos : @sum_of_dojos , # Required by other repos
115+ total_events : @sum_of_events ,
116+ total_ninjas : @sum_of_participants ,
117+ active_dojos_by_region : @data_by_prefecture ,
118+ }
119+ }
120+ end
119121 end
120122end
121123
You can’t perform that action at this time.
0 commit comments