rails_server_analytics 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4cf58448dd0c85fe840e2261ceaf35d3ddd1a99141a70f16891ba6e0dcc46fe
4
- data.tar.gz: 18f97b3624a472f957466d4313f875d3ab2e3e9a6d8098ab420a7dac270f2c6a
3
+ metadata.gz: 013b7e598bba87a4ca28a1d98ed7170b474afa7fd09d77e817479f7650b26870
4
+ data.tar.gz: 065ff1d2e022cc1c495c8b16453b5797c31a962915ccb3cb9da1a356c9ed321d
5
5
  SHA512:
6
- metadata.gz: f28602990dc8c0d9b2f5bf43bb56ffcf468e6dafd67b56cbfd00fbb57aa775d22fd4f762f2858f095bb1ac72eed821d6ae60964f52bdc63ddc17800c285985db
7
- data.tar.gz: 22fc488ca4e4cf21e5e1e64b890a274419f9cbd02b3b9bd0728f56b3f5ba88810a24fb4495d7c1567244d8f4db97109ca175c9a62a16a78417eb675f71410502
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.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,17 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_server_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
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-10 00:00:00.000000000 Z
11
+ date: 2024-11-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: a gem that applies a custom middleware in a rails application for tracing
14
- requests and generates an analytics page for monitoring.
13
+ description: |
14
+ A rails gem that shows your rails application metrics and analytics in a dashboard view.
15
+ The gem applies a middleware to your rails application to trace requests and responses from your server, then pushes it to the database.
16
+ Raw data stored will then be processed and show in an analytical view on your localhost.
15
17
  email:
16
18
  - jackchong398@gmail.com
17
19
  executables: []
@@ -33,6 +35,7 @@ licenses:
33
35
  metadata:
34
36
  homepage_uri: https://github.com/Cwjiee/rails-server-analytics
35
37
  source_code_uri: https://github.com/Cwjiee/rails-server-analytics
38
+ changelog_uri: https://github.com/Cwjiee/rails-server-analytics/blob/main/CHANGELOG.md
36
39
  post_install_message:
37
40
  rdoc_options: []
38
41
  require_paths:
@@ -51,5 +54,6 @@ requirements: []
51
54
  rubygems_version: 3.5.11
52
55
  signing_key:
53
56
  specification_version: 4
54
- summary: A middleware to trace and montior requests and responses in rails
57
+ summary: A rails gem that shows your rails application metrics and analytics in a
58
+ dashboard view
55
59
  test_files: []