rails_server_analytics 0.1.0 → 0.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4cf58448dd0c85fe840e2261ceaf35d3ddd1a99141a70f16891ba6e0dcc46fe
|
4
|
+
data.tar.gz: 18f97b3624a472f957466d4313f875d3ab2e3e9a6d8098ab420a7dac270f2c6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f28602990dc8c0d9b2f5bf43bb56ffcf468e6dafd67b56cbfd00fbb57aa775d22fd4f762f2858f095bb1ac72eed821d6ae60964f52bdc63ddc17800c285985db
|
7
|
+
data.tar.gz: 22fc488ca4e4cf21e5e1e64b890a274419f9cbd02b3b9bd0728f56b3f5ba88810a24fb4495d7c1567244d8f4db97109ca175c9a62a16a78417eb675f71410502
|
@@ -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
|