File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,11 @@ def annual_sum_of_participants
3434 def annual_dojos_chart ( lang = 'ja' )
3535 # 各年末時点でアクティブだったDojoを集計(過去の非アクティブDojoも含む)
3636 # YAMLマスターデータには既にinactivated_atが含まれているため、常にこの方式を使用
37- HighChartsBuilder . build_annual_dojos ( annual_dojos_with_historical_data , lang )
37+ data = {
38+ active_dojos : annual_dojos_with_historical_data ,
39+ new_dojos : annual_new_dojos_count
40+ }
41+ HighChartsBuilder . build_annual_dojos ( data , lang )
3842 end
3943
4044 # 各年末時点でアクティブだったDojo数を集計(過去の非アクティブDojoも含む)
@@ -46,6 +50,17 @@ def annual_dojos_with_historical_data
4650 hash [ year . to_s ] = count
4751 end
4852 end
53+
54+ # 各年に新規開設されたDojo数を集計
55+ def annual_new_dojos_count
56+ ( @period . first . year ..@period . last . year ) . each_with_object ( { } ) do |year , hash |
57+ start_of_year = Time . zone . local ( year ) . beginning_of_year
58+ end_of_year = Time . zone . local ( year ) . end_of_year
59+ # その年に作成されたDojoの数を集計
60+ count = Dojo . where ( created_at : start_of_year ..end_of_year ) . sum ( :counter )
61+ hash [ year . to_s ] = count
62+ end
63+ end
4964
5065 def annual_event_histories_chart ( lang = 'ja' )
5166 HighChartsBuilder . build_annual_event_histories ( annual_count_of_event_histories , lang )
You can’t perform that action at this time.
0 commit comments