Commit 9d30d2f586010d95b939d6527d5effd76ee4c7d8
Exists in
staging
and in
4 other branches
Merge branch 'AI3220_proposals' into stable
Showing
2 changed files
with
12 additions
and
55 deletions
Show diff stats
plugins/proposals_discussion/lib/proposals_discussion_plugin/topic.rb
... | ... | @@ -44,11 +44,21 @@ class ProposalsDiscussionPlugin::Topic < Folder |
44 | 44 | end |
45 | 45 | |
46 | 46 | def proposals_per_day |
47 | - proposals.group("date(created_at)").count | |
47 | + result = proposals.group("date(created_at)").count | |
48 | + fill_empty_days(result) | |
48 | 49 | end |
49 | 50 | |
50 | 51 | def comments_per_day |
51 | - proposals.joins(:comments).group('date(comments.created_at)').count('comments.id') | |
52 | + result = proposals.joins(:comments).group('date(comments.created_at)').count('comments.id') | |
53 | + fill_empty_days(result) | |
54 | + end | |
55 | + | |
56 | + def fill_empty_days(result) | |
57 | + from = created_at.to_date | |
58 | + (from..Date.today).inject({}) do |h, date| | |
59 | + h[date.to_s] = result[date.to_s] || 0 | |
60 | + h | |
61 | + end | |
52 | 62 | end |
53 | 63 | |
54 | 64 | def cache_key_with_person(params = {}, user = nil, language = 'en') | ... | ... |
plugins/proposals_discussion/public/proposals_graph.js~
... | ... | @@ -1,53 +0,0 @@ |
1 | -(function basic_time(container) { | |
2 | - | |
3 | - var | |
4 | - d1 = [], | |
5 | - start = new Date("2009/01/01 01:00").getTime(), | |
6 | - options, | |
7 | - graph, | |
8 | - i, x, o; | |
9 | - | |
10 | - for (i = 0; i < 100; i++) { | |
11 | - x = start+(i*1000*3600*24*36.5); | |
12 | - d1.push([x, i+Math.random()*30+Math.sin(i/20+Math.random()*2)*20+Math.sin(i/10+Math.random())*10]); | |
13 | - } | |
14 | - | |
15 | - options = { | |
16 | - xaxis : { | |
17 | - mode : 'time', | |
18 | - labelsAngle : 45 | |
19 | - }, | |
20 | - selection : { | |
21 | - mode : 'x' | |
22 | - }, | |
23 | - HtmlText : false, | |
24 | - title : 'Time' | |
25 | - }; | |
26 | - | |
27 | - // Draw graph with default options, overwriting with passed options | |
28 | - function drawGraph (opts) { | |
29 | - | |
30 | - // Clone the options, so the 'options' variable always keeps intact. | |
31 | - o = Flotr._.extend(Flotr._.clone(options), opts || {}); | |
32 | - | |
33 | - // Return a new graph. | |
34 | - return Flotr.draw( | |
35 | - container, | |
36 | - [ d1 ], | |
37 | - o | |
38 | - ); | |
39 | - } | |
40 | - | |
41 | - graph = drawGraph(); | |
42 | - | |
43 | - Flotr.EventAdapter.observe(container, 'flotr:select', function(area){ | |
44 | - // Draw selected area | |
45 | - graph = drawGraph({ | |
46 | - xaxis : { min : area.x1, max : area.x2, mode : 'time', labelsAngle : 45 }, | |
47 | - yaxis : { min : area.y1, max : area.y2 } | |
48 | - }); | |
49 | - }); | |
50 | - | |
51 | - // When graph is clicked, draw the graph with default area. | |
52 | - Flotr.EventAdapter.observe(container, 'flotr:click', function () { graph = drawGraph(); }); | |
53 | -})(document.getElementById("editor-render-0")); |