rails_server_analytics 0.1.0 → 0.1.2

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: ceecf3d520444f52ee03e83e013c11c051060c8f7aa68a6f51daade9f4ac7d32
4
- data.tar.gz: aba1fbf7819d6b292a9900ee29cd1d162b96057aa4d88ccf3bbfe4c9aed13252
3
+ metadata.gz: f2ad5b69aac05847b33c764c3e15b0e80a0d385d854270d27b741ef3cc28a719
4
+ data.tar.gz: 4a8057197fb0d6827987e4ce8125a1f6f6f3fd09e58e1b9ace6d24bbe6e9d731
5
5
  SHA512:
6
- metadata.gz: 0663736f3c8feb23bdae41ec480b2342a521e183deae4da9e4de7d6d8bcea711485cafb5c55e8f48e3d81e04c21f8ebe310fc46625b9341149832dfa05365958
7
- data.tar.gz: '092920b9405f6d39516a267c6001d33aed1c93b598e3c7908a7d9a41baaa34db0ebc2e2356fbcd1a5365285e0be546c190b4f20f6cdca128f2c679cd83903749'
6
+ metadata.gz: 40dc5596ed1dc6b3fdf9db9e65f34e3e356ab3cf001c54c67f3f9e4d0295f0d924f0d0f3983de578a4eb7d5872237a462e7f5aac6df920080b583d84a6a5cb30
7
+ data.tar.gz: '084f68a4b4da79339afbaf05ab7df7ac0a4ab3791e33f286432821de83e301e0dd0e54179f197f6a9633a3d403286886190b4c56c9840d2ab2c808597e14ae53'
@@ -16,7 +16,7 @@ class AnalyticsController < ApplicationController
16
16
  end
17
17
 
18
18
  def process_raw_analytics
19
- request_count = @analytics.count
19
+ @request_count = @analytics.count
20
20
  total_request_per_day = @analytics.where(updated_at: (Time.now - 1.day)..Time.now).pluck(:updated_at).count
21
21
 
22
22
  average_response_time = get_average("time_spent")
@@ -31,7 +31,7 @@ class AnalyticsController < ApplicationController
31
31
 
32
32
  @analytics_json = {
33
33
  analytics: @analytics,
34
- request_count: request_count,
34
+ request_count: @request_count,
35
35
  total_request_per_day: total_request_per_day,
36
36
  average_response_time: average_response_time,
37
37
  most_frequent_request: most_frequent_request,
@@ -45,6 +45,8 @@ class AnalyticsController < ApplicationController
45
45
  end
46
46
 
47
47
  def get_most_frequent(data)
48
+ return "None" if no_request
49
+
48
50
  all_request = @analytics.map(&:analytics_data).pluck(data)
49
51
  all_request.detect { |r| all_request.count(r) > 1 }
50
52
 
@@ -53,7 +55,13 @@ class AnalyticsController < ApplicationController
53
55
  end
54
56
 
55
57
  def get_average(data)
58
+ return 0.00 if no_request
59
+
56
60
  all_data = @analytics.map(&:analytics_data).pluck(data)
57
61
  (all_data.sum / @analytics.count).truncate(3)
58
62
  end
63
+
64
+ def no_request
65
+ @request_count == 0
66
+ end
59
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsServerAnalytics
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
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.0
4
+ version: 0.1.2
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-11 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: []