rails_server_analytics 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2ad5b69aac05847b33c764c3e15b0e80a0d385d854270d27b741ef3cc28a719
4
- data.tar.gz: 4a8057197fb0d6827987e4ce8125a1f6f6f3fd09e58e1b9ace6d24bbe6e9d731
3
+ metadata.gz: 013b7e598bba87a4ca28a1d98ed7170b474afa7fd09d77e817479f7650b26870
4
+ data.tar.gz: 065ff1d2e022cc1c495c8b16453b5797c31a962915ccb3cb9da1a356c9ed321d
5
5
  SHA512:
6
- metadata.gz: 40dc5596ed1dc6b3fdf9db9e65f34e3e356ab3cf001c54c67f3f9e4d0295f0d924f0d0f3983de578a4eb7d5872237a462e7f5aac6df920080b583d84a6a5cb30
7
- data.tar.gz: '084f68a4b4da79339afbaf05ab7df7ac0a4ab3791e33f286432821de83e301e0dd0e54179f197f6a9633a3d403286886190b4c56c9840d2ab2c808597e14ae53'
6
+ metadata.gz: f1560256caf4c5ae65dde73e2741fe41e7125ee90a3a873f57afa54177af2b07b67f0a56cc43f8dcaf29d2da86a51ced5535ddf1507e8b21c6c47e653e29fee5
7
+ data.tar.gz: 268e2eb5295be08fd42d91eebe4aa57872fc9fcc7ce65f5e4ecf9457e0a4c20654f5f175a44295dba6dcc1d0c9ef4bce8f774955208a7ce8e1ef27d343842515
@@ -155,28 +155,10 @@
155
155
  </div>
156
156
  </div>
157
157
 
158
- <!-- Chart Card -->
159
- <div class="chart-container card">
160
- <h2>Requests per Day</h2>
161
- <div class="chart">
162
- <%%
163
- # You would need to implement chart rendering here
164
- # You could use Chart.js or any other JavaScript charting library
165
- # For now, we'll show the data in a table format
166
- %>
167
- <table style="width: 100%; border-collapse: collapse;">
168
- <thead>
169
- <tr>
170
- <th style="text-align: left; padding: 8px; border-bottom: 1px solid #ddd;">Date</th>
171
- <th style="text-align: right; padding: 8px; border-bottom: 1px solid #ddd;">Requests</th>
172
- </tr>
173
- </thead>
174
- <tbody>
175
- <tr>
176
- <td><%% @analytics_json[:total_request_per_day] %></td>
177
- </tr>
178
- </tbody>
179
- </table>
158
+ <div class="card">
159
+ <h3>Request Methods Distribution</h3>
160
+ <div class="chart-container">
161
+ <canvas id="methodChart"></canvas>
180
162
  </div>
181
163
  </div>
182
164
 
@@ -202,11 +184,47 @@
202
184
  </div>
203
185
  </div>
204
186
 
205
- <%% if @analytics_json[:auto_refresh] %>
206
- <script>
207
- setTimeout(function() {
208
- window.location.reload();
209
- }, 5000);
210
- </script>
187
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
188
+
189
+ <script>
190
+ const analyticsData = <%%= raw @analytics.to_json %>;
191
+ const methodCounts = analyticsData.reduce((acc, curr) => {
192
+ const method = curr.analytics_data.request_method.toUpperCase();
193
+ acc[method] = (acc[method] || 0) + 1;
194
+ return acc;
195
+ }, {});
196
+
197
+ const methodChartCtx = document.getElementById('methodChart').getContext('2d');
198
+ new Chart(methodChartCtx, {
199
+ type: 'doughnut',
200
+ data: {
201
+ labels: Object.keys(methodCounts),
202
+ datasets: [{
203
+ data: Object.values(methodCounts),
204
+ backgroundColor: [
205
+ '#22c55e', // GET
206
+ '#3b82f6', // POST
207
+ '#f59e0b', // PUT
208
+ '#ef4444' // DELETE
209
+ ]
210
+ }]
211
+ },
212
+ options: {
213
+ responsive: true,
214
+ maintainAspectRatio: false,
215
+ plugins: {
216
+ legend: {
217
+ position: 'right'
218
+ }
219
+ }
220
+ }
221
+ });
222
+
223
+ <%% if @analytics_json[:auto_refresh] %>
224
+ setTimeout(function() {
225
+ window.location.reload();
226
+ }, 5000);
211
227
  <%% end %>
228
+ </script>
229
+
212
230
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsServerAnalytics
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_server_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chong Wei Jie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-11 00:00:00.000000000 Z
11
+ date: 2024-11-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  A rails gem that shows your rails application metrics and analytics in a dashboard view.