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
34
34
def annual_dojos_chart ( lang = 'ja' )
35
35
# 各年末時点でアクティブだったDojoを集計(過去の非アクティブDojoも含む)
36
36
# 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 )
38
42
end
39
43
40
44
# 各年末時点でアクティブだったDojo数を集計(過去の非アクティブDojoも含む)
@@ -46,6 +50,17 @@ def annual_dojos_with_historical_data
46
50
hash [ year . to_s ] = count
47
51
end
48
52
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
49
64
50
65
def annual_event_histories_chart ( lang = 'ja' )
51
66
HighChartsBuilder . build_annual_event_histories ( annual_count_of_event_histories , lang )
You can’t perform that action at this time.
0 commit comments