Skip to content

Commit 6af1063

Browse files
committed
added chart_data() to permit charting of a match's per-minute data
1 parent 8065993 commit 6af1063

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/esdb/match.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,24 @@ class Match < ESDB::Resource
33
def duration_minutes
44
return (duration_seconds / 60.0).round
55
end
6+
7+
# where does this function belong?
8+
#
9+
# MR says "[if it] deals directly with data on the model, it goes in the model"
10+
#
11+
# and yet this feels suspiciously like view logic.
12+
#
13+
def chart_data(measure)
14+
entities.collect {|entity|
15+
extracted_measures = []
16+
entity["minutes"].each {|minute, measures|
17+
extracted_measures[minute.to_i] = measures[measure].to_f
18+
}
19+
{:name => entity["identity"]["name"],
20+
:data => extracted_measures,
21+
:color => "#" + entity["color"],
22+
}
23+
}.to_json
24+
end
625
end
726
end

0 commit comments

Comments
 (0)