-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
_range.html.erb
237 lines (227 loc) · 9.46 KB
/
_range.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<h5>Choose a starting and an ending date in the field below to see activity during that range</h5>
<%= form_tag request.url, method: 'get', enforce_utf8: false do %>
<div class="row">
<div class="col-md-4">
<label>Starting</label>
<input data-provide="datepicker" data-date="<%= DateTime.now.strftime("%d-%m-%Y") %>" value="<%= @start.strftime("%d-%m-%Y") %>" data-date-format="dd-mm-yyyy" tabindex="1" class="form-control" type="text" name="start">
</div>
<div class="col-md-4">
<label>Ending</label>
<input data-provide="datepicker" data-date="<%= DateTime.now.strftime("%d-%m-%Y") %>" value="<%[email protected]("%d-%m-%Y") %>" data-date-format="dd-mm-yyyy" tabindex="1" class="form-control" type="text" name="end">
</div>
<div class="col-md-1">
<%= submit_tag "Go" , class: 'btn btn-primary', :style=>'margin-top:2em;' %>
</div>
</div>
<% end %>
<hr />
<h4>
<%= raw t('notes.stats.notes_wikis_comments', :notes_count => @notes, :wikis_count => @wikis, :comments_count => @comments) %>
</h4>
<hr>
<h4>
<%= raw t('notes.stats.members_and_contributors', :member_count => @people, :people_count => @contributors) %>
</h4>
<hr>
<%if @questions.present? %>
<div id="chart2"> </div>
<% end %>
<% if current_user && (current_user.role == "admin") %>
<div class="row">
<div class="col-md-4 col-md-offset-1">
<div class="btn-group">
<button type="button" class="btn btn-lg btn-default">
<i class="fa fa-cloud-download" style="color:blue"> </i>
Download as json
</button>
<button type="button" class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li>
<%= link_to "Notes", stats_notes_path(format: 'json', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Wikis", stats_wikis_path(format: 'json', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Comments", stats_comments_path(format: 'json', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Users", stats_users_path(format: 'json', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Questions Asked", stats_questions_path(format: 'json', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Questions Answered", stats_answers_path(format: 'json', start: params[:start], end: params[:end]) %>
</li>
</ul>
</div>
</div>
 
<div class="col-md-3">
<div class="btn-group">
<button type="button" class="btn btn-lg btn-default">
<i class="fa fa-cloud-download" style="color:purple"> </i>
Download as csv
</button>
<button type="button" class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li>
<%= link_to "Notes", stats_notes_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Wikis", stats_wikis_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Comments", stats_comments_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<li>
<%= link_to "Users", stats_users_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Questions Asked", stats_questions_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
<li>
<%= link_to "Questions Answered", stats_answers_path(format: 'csv', start: params[:start], end: params[:end]) %>
</li>
</ul>
</div>
</div>
</div>
<br><br> <br>
<% end %>
<div class="row">
<h5> Move back or forward using the buttons below </h5>
<div class="col-md-4 col-md-offset-1">
<div class="btn-group" role="group" aria-label="Basic example">
<a href="<%= "?start="+(@start - 1.year).to_formatted_s(:long) %> <%= "&end="+(@end - 1.year).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title= "1 year back">
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
<a>
<a href="<%= "?start="+(@start - 3.months).to_formatted_s(:long) %> <%= "&end="+(@end - 3.months).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title="3 months back">
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
<a href="<%= "?start="+(@start - 1.month).to_formatted_s(:long) %> <%= "&end="+(@end - 1.month).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title="1 month back">
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
<a href="<%= "?start="+(@start - 1.week).to_formatted_s(:long) %> <%= "&end="+(@end - 1.week).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title="1 week back">
<i class="fa fa-caret-left fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
</div>
</div>
 
<div class="col-md-3">
<div class="btn-group" role="group" aria-label="Basic example">
<a href="<%= "?start="+(@start + 1.week).to_formatted_s(:long) %> <%= "&end="+(@end + 1.week).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title="1 week forward">
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
<a href="<%= "?start="+(@start + 1.month).to_formatted_s(:long) %> <%= "&end="+(@end + 1.month).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title="1 month forward">
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
<a href="<%= "?start="+(@start + 3.months).to_formatted_s(:long) %> <%= "&end="+(@end + 3.months).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title="3 months forward">
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
<%# <a href="/stats/range/<%= (@start + 1.year).to_formatted_s(:long) %1>/<%= (@end + 1.year).to_formatted_s(:long) %1>"> %>
<a href="<%= "?start="+(@start + 1.year).to_formatted_s(:long) %> <%= "&end="+(@end + 1.year).to_formatted_s(:long) %>">
<button type="button" class="btn btn-secondary" title="1 year forward">
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
<i class="fa fa-caret-right fa-2x" style="color:#3071a9;"> </i>
</button>
</a>
</div>
<br> <br> <br>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<script>
var questions = [<%= @questions.count %>];
var answers = [<%= @answers %>];
var options = {
chart: {
type: 'bar',
height: 130,
width: '90%',
stacked: true,
stackType: '100%'
},
plotOptions: {
bar: {
horizontal: true,
},
},
stroke: {
width: 1,
colors: ['#fff']
},
series: [{
name: 'Questions asked',
data: questions
},{
name: 'Questions answered',
data: answers
}],
fill: {
opacity: 1
},
title: {
text: "Questions asked vs Answered in this period",
},
legend: {
show: false,
},
grid: {
show: false,
},
xaxis: {
labels: {
show: false,
},
axisBorder: {
show: false
},
lines: {
show: false,
}
},
yaxis: {
labels: {
show: false,
}
}
}
var chart2 = new ApexCharts(document.querySelector("#chart2"),options);
chart2.render();
</script>