atomic_admin 2.0.1 → 2.1.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c10368cb99860ffc390005c069b5f8ecb9d8a32565825ede48170f2cebf1c45f
|
|
4
|
+
data.tar.gz: '09d0e51b31e4d6ddaf2690b42df590b170e901f5f5266b343d9212d21708ff65'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da2a6e0c2ddcde2b28feb058e8072ba183c152f7db7107bb59f386b387706db4876aa318b88e1d9096a9dd02169369a790cf80e6b759ee7b7e5b288a80daa38d
|
|
7
|
+
data.tar.gz: 15889bbcbc41b5adb3c2acf88015e64ceb31ebc1d0435c9006b13f42f83dda515c51e7f9b1af8bb34f530ef18d822f0953cc0ddb6ff7e7b5199e478493c8cc7e
|
|
@@ -15,6 +15,7 @@ module AtomicAdmin::V1
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
@application_instances, meta = filter(@application_instances)
|
|
18
|
+
@stats = get_stats_for_instances(@application_instances)
|
|
18
19
|
|
|
19
20
|
render json: {
|
|
20
21
|
application_instances: json_for_collection(@application_instances),
|
|
@@ -24,12 +25,14 @@ module AtomicAdmin::V1
|
|
|
24
25
|
|
|
25
26
|
def show
|
|
26
27
|
@application_instance = ApplicationInstance.find(params[:id])
|
|
28
|
+
@stats = get_stats_for_instances([@application_instance])
|
|
27
29
|
render json: { application_instance: json_for(@application_instance) }
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
def create
|
|
31
33
|
application = Application.find(params[:application_id])
|
|
32
34
|
instance = application.application_instances.new(create_params)
|
|
35
|
+
@stats = get_stats_for_instances([instance])
|
|
33
36
|
|
|
34
37
|
if instance.save
|
|
35
38
|
render json: { application_instance: json_for(instance) }
|
|
@@ -41,6 +44,7 @@ module AtomicAdmin::V1
|
|
|
41
44
|
def update
|
|
42
45
|
instance = ApplicationInstance.find(params[:id])
|
|
43
46
|
instance.update(update_params)
|
|
47
|
+
@stats = get_stats_for_instances([instance])
|
|
44
48
|
|
|
45
49
|
if params[:application_instance][:is_paid] && instance.paid_at.nil?
|
|
46
50
|
instance.paid_at = DateTime.now
|
|
@@ -67,6 +71,27 @@ module AtomicAdmin::V1
|
|
|
67
71
|
render json: { interactions: interactions }
|
|
68
72
|
end
|
|
69
73
|
|
|
74
|
+
def get_stats_for_instances(instances)
|
|
75
|
+
tenants = instances.pluck(:tenant)
|
|
76
|
+
stats = {}
|
|
77
|
+
stats[:errors] = RequestStatistic.total_errors_grouped(tenants) if defined?(RequestStatistic)
|
|
78
|
+
stats[:unique_users] = CachedUniqueUsersByContractDate.unique_users_by_contract_date(instances) if defined?(CachedUniqueUsersByContractDate)
|
|
79
|
+
stats[:max_users_month] = CachedUniqueUsersByMonth.max_monthly_unique_users(instances) if defined?(CachedUniqueUsersByMonth)
|
|
80
|
+
|
|
81
|
+
stats
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def request_stats(instance)
|
|
85
|
+
tenant = instance.tenant
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
unique_users_in_contract: @stats.dig(:unique_users, tenant) || 0,
|
|
89
|
+
day_1_errors: @stats.dig(:errors, 0, tenant) || 0,
|
|
90
|
+
day_7_errors: @stats.dig(:errors, 7, tenant) || 0,
|
|
91
|
+
max_users_month: @stats.dig(:max_users_month, tenant) || 0,
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
70
95
|
def json_for(instance)
|
|
71
96
|
json = instance.as_json(include: [:application, :site])
|
|
72
97
|
|
|
@@ -74,8 +99,10 @@ module AtomicAdmin::V1
|
|
|
74
99
|
json["trial_end_date"] = instance.trial_end_date&.strftime("%Y-%m-%d") if instance.respond_to?(:trial_end_date)
|
|
75
100
|
json["license_start_date"] = instance.license_start_date&.strftime("%Y-%m-%d") if instance.respond_to?(:license_start_date)
|
|
76
101
|
json["license_end_date"] = instance.license_end_date&.strftime("%Y-%m-%d") if instance.respond_to?(:license_end_date)
|
|
102
|
+
json["paid_at"] = instance.paid_at&.strftime("%Y-%m-%d") if instance.respond_to?(:paid_at)
|
|
77
103
|
json["is_paid"] = instance.paid_at.present? if instance.respond_to?(:paid_at)
|
|
78
104
|
json["lti_config_xml"] = instance.lti_config_xml if instance.respond_to?(:lti_config_xml)
|
|
105
|
+
json["request_stats"] = request_stats(instance)
|
|
79
106
|
|
|
80
107
|
json
|
|
81
108
|
end
|
|
@@ -113,7 +140,7 @@ module AtomicAdmin::V1
|
|
|
113
140
|
end
|
|
114
141
|
|
|
115
142
|
def create_params
|
|
116
|
-
params.require(:application_instance).except(:is_paid, :lti_config_xml, :site, :application).permit!
|
|
143
|
+
params.require(:application_instance).except(:is_paid, :lti_config_xml, :site, :application, :request_stats).permit!
|
|
117
144
|
end
|
|
118
145
|
|
|
119
146
|
def update_params
|
|
@@ -10,7 +10,7 @@ module AtomicAdmin::Schema
|
|
|
10
10
|
type: "boolean",
|
|
11
11
|
title: "Paid Account"
|
|
12
12
|
},
|
|
13
|
-
|
|
13
|
+
paid_at: {
|
|
14
14
|
type: ["string", "null"],
|
|
15
15
|
format: "date",
|
|
16
16
|
},
|
|
@@ -57,10 +57,12 @@ module AtomicAdmin::Schema
|
|
|
57
57
|
{
|
|
58
58
|
type: "Control",
|
|
59
59
|
scope: "#/properties/is_paid",
|
|
60
|
+
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
63
|
type: "Control",
|
|
63
|
-
scope: "#/properties/
|
|
64
|
+
scope: "#/properties/paid_at",
|
|
65
|
+
label: "License Start Date",
|
|
64
66
|
options: {
|
|
65
67
|
format: "date",
|
|
66
68
|
},
|
data/lib/atomic_admin/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: atomic_admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Benoit
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-06-
|
|
12
|
+
date: 2026-06-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -40,7 +40,7 @@ dependencies:
|
|
|
40
40
|
version: 1.5.0
|
|
41
41
|
- - "<"
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version:
|
|
43
|
+
version: 5.0.0
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -50,7 +50,7 @@ dependencies:
|
|
|
50
50
|
version: 1.5.0
|
|
51
51
|
- - "<"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 5.0.0
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: atomic_tenant
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|