@@ -11,6 +11,11 @@ def summaries?
1111 false
1212 end
1313
14+ # Does the match have replays?
15+ def replays?
16+ self . replays_count && self . replays_count > 0
17+ end
18+
1419 # TODO: when there is ample time, I want to generalize stuff like this via
1520 # something like Hashie, but Hashie::Mash just didn't work out right away
1621 # it's complicated.. the fact that we have a key called "map" alone..
@@ -34,44 +39,5 @@ def teams
3439 def duration_minutes
3540 return ( duration_seconds / 60.0 ) . round
3641 end
37-
38- # this function doesnt belong here. where does it belong?
39- def smooth ( indata , window_size )
40- window = [ ]
41- result = [ ]
42- runningavg = 0
43- for elm in indata
44- elm = 0 if elm . nil?
45- runningavg += elm
46- window . push ( elm )
47- if window . length > window_size
48- removedelm = window . shift
49- runningavg -= removedelm
50- end
51- windowavg = runningavg . to_f / window . length
52- result . push ( windowavg . round ( 2 ) )
53- end
54- return result
55- end
56-
57- # where does this function belong?
58- #
59- # MR says "[if it] deals directly with data on the model, it goes in the model"
60- #
61- # and yet this feels suspiciously like view logic.
62- #
63- def chart_data ( measure , smoothing_window )
64- entities . collect { |entity |
65- extracted_measures = [ ]
66- entity [ "minutes" ] . each { |minute , measures |
67- extracted_measures [ minute . to_i - 1 ] = measures [ measure ] . to_f unless minute == "0"
68- }
69- { :name => entity [ "identity" ] [ "name" ] ,
70- :data => smooth ( extracted_measures , smoothing_window ) ,
71- :color => "#" + entity [ "color" ] ,
72- :team => entity [ "team" ] ,
73- }
74- }
75- end
7642 end
7743end
0 commit comments