Skip to content

Commit 3ae409b

Browse files
committed
Fix #992: 連名道場のタグ数もタグ分布に加算
1 parent 3d929f8 commit 3ae409b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/controllers/stats_controller.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ def show
2727
# TODO: Use 'tally' method when using Ruby 2.7.0 or higher
2828
# cf. https://twitter.com/yasulab/status/1154566199511941120
2929
tags = Dojo.active.map(&:tags).flatten.group_by(&:itself).transform_values(&:count)
30-
.sort_by(&:last).reverse.to_h
30+
31+
# Add tags for multiple dojos: https://github.com/coderdojo-japan/coderdojo.jp/issues/992
32+
Dojo.where('counter > 1').each do |dojo|
33+
dojo.tags.each {|tag| tags[tag] += (dojo.counter - 1) }
34+
end
35+
tags = tags.sort_by{|key, value| value}.reverse.to_h
36+
3137
f.xAxis categories: tags.keys.take(number_of_tags).reverse
3238
f.yAxis title: { text: '' }, showInLegend: false, opposite: true,
33-
tickInterval: 30, max: 210
39+
tickInterval: 40, max: 240
3440
f.series type: 'column', name: "対応道場数", yAxis: 0, showInLegend: false,
3541
data: tags.values.take(number_of_tags).reverse,
3642
dataLabels: { enabled: true, y: 20, align: 'center' }

0 commit comments

Comments
 (0)