lesli_audit 0.6.0 → 1.0.1
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 +4 -4
- data/app/assets/config/lesli_audit_manifest.js +0 -1
- data/app/assets/javascripts/lesli_audit/application.js +1 -4910
- data/app/assets/stylesheets/lesli_audit/application.css +3 -3
- data/app/controllers/lesli_audit/analytics_controller.rb +3 -13
- data/app/controllers/lesli_audit/dashboards_controller.rb +2 -0
- data/app/controllers/lesli_audit/requests_controller.rb +1 -6
- data/app/controllers/lesli_audit/users_controller.rb +4 -11
- data/app/interfaces/lesli_audit/logger_interface.rb +132 -0
- data/app/models/lesli_audit/account.rb +0 -1
- data/app/models/lesli_audit/dashboard.rb +0 -26
- data/app/services/lesli_audit/analytic_service.rb +12 -7
- data/app/services/lesli_audit/analytics/visitor_service.rb +155 -153
- data/app/services/lesli_audit/user_service.rb +17 -9
- data/app/views/lesli_audit/analytics/index.html.erb +42 -1
- data/app/views/lesli_audit/dashboards/edit.html.erb +12 -1
- data/app/views/lesli_audit/dashboards/index.html.erb +2 -0
- data/app/views/lesli_audit/dashboards/new.html.erb +2 -0
- data/app/views/lesli_audit/dashboards/show.html.erb +33 -1
- data/app/views/lesli_audit/requests/index.html.erb +23 -1
- data/app/views/lesli_audit/users/index.html.erb +14 -1
- data/config/locales/translations.en.yml +1 -20
- data/config/locales/translations.es.yml +1 -20
- data/config/locales/translations.fr.yml +1 -20
- data/config/locales/translations.it.yml +1 -20
- data/config/locales/translations.pt.yml +1 -20
- data/config/routes.rb +1 -19
- data/db/migrate/v1.0/0503000110_create_lesli_audit_accounts.rb +1 -6
- data/db/migrate/v1.0/0503050110_create_lesli_audit_dashboards.rb +1 -15
- data/db/seeds.rb +7 -10
- data/lib/lesli_audit/engine.rb +2 -0
- data/lib/lesli_audit/version.rb +2 -2
- data/lib/vue/apps/users/registrations.vue +7 -9
- data/lib/vue/stores/translations.json +10 -0
- metadata +10 -12
- data/db/migrate/v1.0/0503050210_create_lesli_audit_dashboard_components.rb +0 -53
- data/db/seed/production.rb +0 -0
- data/db/seed/test.rb +0 -0
- /data/app/views/lesli_audit/partials/{_engine-navigation.html.erb → _navigation.html.erb} +0 -0
- /data/db/seed/{development.rb → requests.rb} +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
!*** css ./node_modules/css-loader/dist/cjs.js??
|
3
|
-
|
1
|
+
/*!************************************************************************************************************************************************************!*\
|
2
|
+
!*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/sass-loader/dist/cjs.js!../LesliAudit/lib/scss/application.scss ***!
|
3
|
+
\************************************************************************************************************************************************************/
|
4
4
|
@charset "UTF-8";
|
5
5
|
/*
|
6
6
|
|
@@ -3,25 +3,15 @@ module LesliAudit
|
|
3
3
|
|
4
4
|
# GET /analytics
|
5
5
|
def index
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
respond_with_successful(AnalyticService.new(current_user, query).visitors)
|
10
|
-
end
|
11
|
-
|
12
|
-
def users
|
13
|
-
respond_with_successful(AnalyticService.new(current_user, query).users)
|
6
|
+
@visitors = respond_as_successful(AnalyticService.new(current_user, query).visitors)
|
7
|
+
@controllers = respond_as_successful(AnalyticService.new(current_user, query).controllers)
|
8
|
+
@users = respond_as_successful(AnalyticService.new(current_user, query).users)
|
14
9
|
end
|
15
10
|
|
16
11
|
def devices
|
17
12
|
respond_with_successful(AnalyticService.new(current_user, query).devices)
|
18
13
|
end
|
19
14
|
|
20
|
-
def controllers
|
21
|
-
respond_with_successful(AnalyticService.new(current_user, query).controllers)
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
15
|
private
|
26
16
|
|
27
17
|
# Use callbacks to share common setup or constraints between actions.
|
@@ -35,12 +35,7 @@ module LesliAudit
|
|
35
35
|
|
36
36
|
# GET /requests
|
37
37
|
def index
|
38
|
-
|
39
|
-
format.html
|
40
|
-
format.json {
|
41
|
-
respond_with_pagination(LesliAudit::RequestService.new(current_user, query).index)
|
42
|
-
}
|
43
|
-
end
|
38
|
+
@requests = respond_as_pagination(LesliAudit::RequestService.new(current_user, query).index)
|
44
39
|
end
|
45
40
|
end
|
46
41
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Lesli
|
4
4
|
|
5
|
-
Copyright (c)
|
5
|
+
Copyright (c) 2025, Lesli Technologies, S. A.
|
6
6
|
|
7
7
|
This program is free software: you can redistribute it and/or modify
|
8
8
|
it under the terms of the GNU General Public License as published by
|
@@ -17,9 +17,9 @@ GNU General Public License for more details.
|
|
17
17
|
You should have received a copy of the GNU General Public License
|
18
18
|
along with this program. If not, see http://www.gnu.org/licenses/.
|
19
19
|
|
20
|
-
Lesli · Ruby on Rails SaaS
|
20
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
21
21
|
|
22
|
-
Made with ♥ by
|
22
|
+
Made with ♥ by LesliTech
|
23
23
|
Building a better future, one line of code at a time.
|
24
24
|
|
25
25
|
@contact hello@lesli.tech
|
@@ -34,14 +34,7 @@ module LesliAudit
|
|
34
34
|
|
35
35
|
# GET /users
|
36
36
|
def index
|
37
|
+
@users = respond_as_successful(UserService.new(current_user, query).registrations)
|
37
38
|
end
|
38
|
-
|
39
|
-
def registrations
|
40
|
-
respond_with_successful(UserService.new(current_user, query).registrations)
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
39
|
end
|
47
40
|
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Lesli
|
4
|
+
|
5
|
+
Copyright (c) 2023, Lesli Technologies, S. A.
|
6
|
+
|
7
|
+
This program is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
This program is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
19
|
+
|
20
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
21
|
+
|
22
|
+
Made with ♥ by https://www.lesli.tech
|
23
|
+
Building a better future, one line of code at a time.
|
24
|
+
|
25
|
+
@contact hello@lesli.tech
|
26
|
+
@website https://www.lesli.tech
|
27
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
28
|
+
|
29
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
30
|
+
// ·
|
31
|
+
=end
|
32
|
+
|
33
|
+
module LesliAudit
|
34
|
+
module LoggerInterface
|
35
|
+
def get_user_agent(as_string=true)
|
36
|
+
|
37
|
+
http_user_agent = request.env["HTTP_USER_AGENT"]
|
38
|
+
|
39
|
+
# parse user agent
|
40
|
+
user_agent = UserAgent.parse(http_user_agent)
|
41
|
+
|
42
|
+
user_agent_version = user_agent.version.to_a.first(2).join(".")
|
43
|
+
|
44
|
+
# return user agent as object
|
45
|
+
if as_string == false
|
46
|
+
return {
|
47
|
+
platform: user_agent.platform,
|
48
|
+
os: user_agent.os,
|
49
|
+
browser: user_agent.browser,
|
50
|
+
version: user_agent_version
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# return user agent info as string
|
55
|
+
"#{user_agent.platform} #{user_agent.os} - #{user_agent.browser} #{user_agent_version}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def log_requests
|
59
|
+
log_account_requests
|
60
|
+
log_user_requests
|
61
|
+
end
|
62
|
+
|
63
|
+
def log_account_requests
|
64
|
+
return unless Lesli.config.security.dig(:enable_analytics)
|
65
|
+
return unless defined?(LesliAudit)
|
66
|
+
return unless current_user
|
67
|
+
|
68
|
+
# Try to save a unique record for this request configuration
|
69
|
+
current_user.account.audit.account_requests.upsert(
|
70
|
+
{
|
71
|
+
request_controller: controller_path,
|
72
|
+
request_action: action_name,
|
73
|
+
request_count: 1,
|
74
|
+
created_at: Date2.new.date.to_s
|
75
|
+
},
|
76
|
+
|
77
|
+
# group of columns to consider a request as unique
|
78
|
+
unique_by: %i[request_controller request_action created_at account_id],
|
79
|
+
|
80
|
+
# if request id is not unique, increase the counter for this configuration
|
81
|
+
on_duplicate: Arel.sql("request_count = lesli_audit_account_requests.request_count + 1")
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Track all user activity
|
86
|
+
# this is disabled by default in the settings file
|
87
|
+
def log_user_requests
|
88
|
+
return unless Lesli.config.security.dig(:enable_analytics)
|
89
|
+
return unless defined?(LesliAudit)
|
90
|
+
return unless current_user
|
91
|
+
return unless session[:user_session_id]
|
92
|
+
|
93
|
+
# Try to save a unique record for this request configuration
|
94
|
+
current_user.account.audit.user_requests.upsert(
|
95
|
+
{
|
96
|
+
request_controller: controller_path,
|
97
|
+
request_action: action_name,
|
98
|
+
session_id: session[:user_session_id],
|
99
|
+
user_id: current_user.id,
|
100
|
+
request_count: 1,
|
101
|
+
created_at: Date2.new.date.to_s
|
102
|
+
},
|
103
|
+
|
104
|
+
# group of columns to consider a request as unique
|
105
|
+
unique_by: %i[request_controller request_action created_at user_id session_id],
|
106
|
+
|
107
|
+
# if request id is not unique
|
108
|
+
# - increase the counter for this configuration
|
109
|
+
# - update the datetime of the last request
|
110
|
+
on_duplicate: Arel.sql(
|
111
|
+
'request_count = lesli_audit_user_requests.request_count + 1'
|
112
|
+
)
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Track specific account activity
|
117
|
+
# this is disabled by default in the settings file
|
118
|
+
def log_account_activity(system_module, system_process, title = nil, payload = nil, description = nil)
|
119
|
+
# return unless Rails.application.config.lesli.dig(:security, :enable_analytics)
|
120
|
+
|
121
|
+
# account = Account.first
|
122
|
+
|
123
|
+
# account.activities.create({
|
124
|
+
# system_module:,
|
125
|
+
# system_process:,
|
126
|
+
# description:,
|
127
|
+
# payload:,
|
128
|
+
# title:
|
129
|
+
# })
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -1,32 +1,6 @@
|
|
1
1
|
module LesliAudit
|
2
|
-
#class Dashboard < Lesli::ApplicationLesliRecord
|
3
2
|
class Dashboard < Lesli::Shared::Dashboard
|
4
3
|
self.table_name = "lesli_audit_dashboards"
|
5
4
|
belongs_to :account
|
6
|
-
|
7
|
-
has_many :components, inverse_of: :dashboard, autosave: true, dependent: :destroy
|
8
|
-
accepts_nested_attributes_for :components, allow_destroy: true
|
9
|
-
|
10
|
-
def self.initialize_account(account)
|
11
|
-
self.create!(
|
12
|
-
account: account,
|
13
|
-
name: "Audit Default Dashboard",
|
14
|
-
default: true,
|
15
|
-
main: false,
|
16
|
-
components_attributes: [{
|
17
|
-
name: "Total users",
|
18
|
-
component_id: "audit-users",
|
19
|
-
layout: 3,
|
20
|
-
query_configuration: {},
|
21
|
-
custom_configuration: {}
|
22
|
-
}, {
|
23
|
-
name: "Roles",
|
24
|
-
component_id: "audit-roles",
|
25
|
-
layout: 3,
|
26
|
-
query_configuration: {},
|
27
|
-
custom_configuration: {}
|
28
|
-
}]
|
29
|
-
)
|
30
|
-
end
|
31
5
|
end
|
32
6
|
end
|
@@ -48,19 +48,24 @@ module LesliAudit
|
|
48
48
|
# only the users of the account
|
49
49
|
usrs = current_user.account.users
|
50
50
|
|
51
|
+
group_by = "DATE_TRUNC('month', created_at)" if group == 'month'
|
52
|
+
group_by = "DATE_TRUNC('week', created_at)" if group == 'week'
|
53
|
+
group_by = "DATE_TRUNC('day', created_at)" if group == 'day'
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
# compatibility for SQLite
|
56
|
+
if ActiveRecord::Base.connection.adapter_name == "SQLite"
|
57
|
+
group_by = "strftime('%Y-%m-%d', created_at)"
|
58
|
+
end
|
59
|
+
|
60
|
+
requests = current_user.account.audit.account_requests.group(group_by)
|
56
61
|
|
57
62
|
requests = apply_filters(requests, query)
|
58
63
|
|
59
|
-
requests.limit(
|
64
|
+
requests.limit(10).order("date desc").select(
|
60
65
|
"count(id) resources",
|
61
66
|
"sum(request_count) requests",
|
62
|
-
"
|
63
|
-
)
|
67
|
+
"#{group_by} date"
|
68
|
+
).as_json
|
64
69
|
end
|
65
70
|
|
66
71
|
def users
|
@@ -1,170 +1,172 @@
|
|
1
|
-
=begin
|
1
|
+
# =begin
|
2
2
|
|
3
|
-
Lesli
|
3
|
+
# Lesli
|
4
4
|
|
5
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
5
|
+
# Copyright (c) 2023, Lesli Technologies, S. A.
|
6
6
|
|
7
|
-
This program is free software: you can redistribute it and/or modify
|
8
|
-
it under the terms of the GNU General Public License as published by
|
9
|
-
the Free Software Foundation, either version 3 of the License, or
|
10
|
-
(at your option) any later version.
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
11
|
|
12
|
-
This program is distributed in the hope that it will be useful,
|
13
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
GNU General Public License for more details.
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
16
|
|
17
|
-
You should have received a copy of the GNU General Public License
|
18
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see http://www.gnu.org/licenses/.
|
19
19
|
|
20
|
-
Lesli · Ruby on Rails SaaS development platform.
|
20
|
+
# Lesli · Ruby on Rails SaaS development platform.
|
21
21
|
|
22
|
-
Made with ♥ by https://www.lesli.tech
|
23
|
-
Building a better future, one line of code at a time.
|
22
|
+
# Made with ♥ by https://www.lesli.tech
|
23
|
+
# Building a better future, one line of code at a time.
|
24
24
|
|
25
|
-
@contact hello@lesli.tech
|
26
|
-
@website https://www.lesli.tech
|
27
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
25
|
+
# @contact hello@lesli.tech
|
26
|
+
# @website https://www.lesli.tech
|
27
|
+
# @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
28
28
|
|
29
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
30
|
-
// ·
|
31
|
-
=end
|
29
|
+
# // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
30
|
+
# // ·
|
31
|
+
# =end
|
32
32
|
|
33
33
|
module LesliAudit
|
34
34
|
class Analytics::VisitorService < Lesli::ApplicationLesliService
|
35
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
|
-
|
36
|
+
# LIMIT=5
|
37
|
+
|
38
|
+
# # @overwrite
|
39
|
+
# # @return {Hash} Paginated list of the records
|
40
|
+
# # @param {query} Has of the formated queries/filters that will be applied to filter data
|
41
|
+
# # @description
|
42
|
+
# # @example
|
43
|
+
# def visits
|
44
|
+
|
45
|
+
# return "hola"
|
46
|
+
|
47
|
+
# return Lesli::User::Request
|
48
|
+
# .group("DATE_TRUNC('day', created_at)").limit(30)
|
49
|
+
# .order("date DESC")
|
50
|
+
# .limit(30)
|
51
|
+
# .select(
|
52
|
+
# "count(id) resources",
|
53
|
+
# "sum(request_count) requests",
|
54
|
+
# "DATE_TRUNC('day', created_at) date"
|
55
|
+
# ).map do |request|
|
56
|
+
# {
|
57
|
+
# :requests => request[:requests],
|
58
|
+
# :resources => request[:resources],
|
59
|
+
# :date => Date2.new(request[:date]).date.to_s
|
60
|
+
# }
|
61
|
+
# end
|
62
|
+
|
63
|
+
# group = 'day'
|
64
|
+
# #group = params[:bygroup] if ['month','week','day'].include?(params[:bygroup])
|
65
|
+
|
66
|
+
# # only the users of the account
|
67
|
+
# usrs = current_user.account.users
|
68
|
+
|
69
|
+
# requests = ::User::Request.where(user: usrs).group("DATE_TRUNC('month', created_at)") if group == 'month'
|
70
|
+
# requests = ::User::Request.where(user: usrs).group("DATE_TRUNC('week', created_at)") if group == 'week'
|
71
|
+
# requests = ::User::Request.where(user: usrs).group("DATE_TRUNC('day', created_at)") if group == 'day'
|
72
|
+
|
73
|
+
# requests = apply_filters(requests, query)
|
72
74
|
|
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
|
-
|
75
|
+
# requests.limit(30).order("date DESC").select(
|
76
|
+
# "count(id) resources",
|
77
|
+
# "sum(request_count) requests",
|
78
|
+
# "DATE_TRUNC('day', created_at) date"
|
79
|
+
# ).map do |request|
|
80
|
+
# {
|
81
|
+
# :requests => request[:requests],
|
82
|
+
# :resources => request[:resources],
|
83
|
+
# :date => Date2.new(request[:date]).date.to_s
|
84
|
+
# }
|
85
|
+
# end
|
86
|
+
# end
|
87
|
+
|
88
|
+
# def users
|
89
|
+
# requests = ::User::Request
|
90
|
+
# .joins(:user)
|
91
|
+
# .where(user: current_user.account.users)
|
92
|
+
# .group(:email)
|
93
|
+
|
94
|
+
# requests = apply_filters(requests, query)
|
95
|
+
|
96
|
+
# requests = requests.limit(LIMIT).order("requests DESC").select(
|
97
|
+
# :email,
|
98
|
+
# "count(user_requests.id) resources",
|
99
|
+
# "sum(user_requests.request_count) requests"
|
100
|
+
# ).map do |request|
|
101
|
+
# {
|
102
|
+
# :requests => request[:requests],
|
103
|
+
# :resources => request[:resources],
|
104
|
+
# :email => request[:email]
|
105
|
+
# }
|
106
|
+
# end
|
107
|
+
|
108
|
+
# return requests
|
109
|
+
# end
|
110
|
+
|
111
|
+
# def devices
|
112
|
+
# agents = ::User::Agent.where(user: current_user.account.users)
|
113
|
+
# agents = agents.group("platform", "browser")
|
114
|
+
# agents = agents.limit(LIMIT).order(sum_count: :desc).sum(:count).map do |req|
|
115
|
+
# {
|
116
|
+
# :device => req[0].join("/"),
|
117
|
+
# :visits => req[1]
|
118
|
+
# }
|
119
|
+
# end
|
120
|
+
|
121
|
+
# return agents
|
122
|
+
# end
|
123
|
+
|
124
|
+
# def controllers
|
125
|
+
# requests = Lesli::User::Request.where(lesli_user: current_user.account.users).group("request_controller")
|
126
|
+
|
127
|
+
# requests = apply_filters(requests, query)
|
128
|
+
|
129
|
+
# requests = requests.limit(LIMIT).order("requests DESC").select(
|
130
|
+
# :request_controller,
|
131
|
+
# "sum(request_count) requests"
|
132
|
+
# )
|
131
133
|
|
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
|
-
|
134
|
+
# return requests
|
135
|
+
# end
|
136
|
+
|
137
|
+
# private
|
138
|
+
|
139
|
+
# def apply_filters requests, params
|
140
|
+
|
141
|
+
# return requests
|
142
|
+
|
143
|
+
# # filter by search string
|
144
|
+
# unless params[:search].blank?
|
145
|
+
# requests = requests.where(
|
146
|
+
# "lower(request_agent) like :search_string or lower(request_controller) like :search_string or lower(request_action) like :search_string",
|
147
|
+
# {
|
148
|
+
# search_string: "%#{params[:search].downcase.gsub(" ","%")}%"
|
149
|
+
# }
|
150
|
+
# )
|
151
|
+
# end
|
152
|
+
|
153
|
+
# # filter by time
|
154
|
+
# unless params[:bytime].blank? && params[:bytime] != 'all'
|
155
|
+
# requests = requests.where(created_at: (Time.now.beginning_of_day)..) if params[:bytime] == 'day'
|
156
|
+
# requests = requests.where(created_at: (Time.now.beginning_of_day - 7.day)..) if params[:bytime] == 'week'
|
157
|
+
# requests = requests.where(created_at: (Time.now.beginning_of_day - 30.day)..) if params[:bytime] == 'month'
|
158
|
+
# requests = requests.where(created_at: (Time.now.beginning_of_day - 6.month)..) if params[:bytime] == 'sixmonth'
|
159
|
+
# requests = requests.where(created_at: (Time.now.beginning_of_day - 1.year)..) if params[:bytime] == 'year'
|
160
|
+
# end
|
161
|
+
|
162
|
+
# # filter by request format
|
163
|
+
# if (!params[:byformat].blank? && ['html', 'json'].include?(params[:byformat]))
|
164
|
+
# requests = requests.where(:request_action => 'show') if params[:byformat] == 'html'
|
165
|
+
# requests = requests.where(:request_format => params[:byformat])
|
166
|
+
# end
|
167
|
+
|
168
|
+
# requests
|
169
|
+
|
170
|
+
# end
|
169
171
|
end
|
170
172
|
end
|