killbill-aviate 2.4.1 → 2.5.0.pre.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/controllers/aviate/usage_controller.rb +27 -5
- data/app/views/aviate/usage/show.html.erb +6 -8
- data/lib/aviate/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bee60163cbf0ca265183dedb23b84706b33b861fb9930388011d26624a31b203
|
|
4
|
+
data.tar.gz: d2e489be4421c15c412cf41f4e38936f56b4c13f0cbbd7f40423d159e4c4f701
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 99e627e23ceada4b4f3869da12191f00df3679438216387f99e84e15f5d0bd91f8ce1ae559f62fc981bce01cacd650fe3ebe275a21717f5fa5222652cc6a4d2b
|
|
7
|
+
data.tar.gz: 9528968cc7255029e32303f73133cb2d896d39bf516f179293b9262b857b1ddf4e6d941d52c97d66e70dff66bc87e991892d6f817bc548669d171f4ccb601d64
|
|
@@ -35,6 +35,7 @@ module Aviate
|
|
|
35
35
|
|
|
36
36
|
# Step 3: Retrieve unit types from catalog
|
|
37
37
|
unit_types = fetch_unit_types(@subscription, start_date, cached_options)
|
|
38
|
+
@unit_types = unit_types
|
|
38
39
|
|
|
39
40
|
# Step 4: Fetch daily usage time-series in parallel
|
|
40
41
|
samples_by_unit = fetch_all_samples(subscription_id, unit_types, start_date, end_date, cached_options)
|
|
@@ -55,9 +56,17 @@ module Aviate
|
|
|
55
56
|
private
|
|
56
57
|
|
|
57
58
|
def billing_period(subscription)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
today = Time.zone.today
|
|
60
|
+
ctd = parse_kb_date(subscription.charged_through_date)
|
|
61
|
+
bcd = subscription.bill_cycle_day_local
|
|
62
|
+
|
|
63
|
+
if ctd > today
|
|
64
|
+
# CTD is the end of the current open billing period; find its start.
|
|
65
|
+
[compute_prev_bcd(ctd, bcd), ctd]
|
|
66
|
+
else
|
|
67
|
+
# CTD marks the start of the next open period.
|
|
68
|
+
[ctd, compute_next_bcd(ctd, bcd)]
|
|
69
|
+
end
|
|
61
70
|
end
|
|
62
71
|
|
|
63
72
|
def parse_kb_date(date_str)
|
|
@@ -88,6 +97,20 @@ module Aviate
|
|
|
88
97
|
start_date + 30
|
|
89
98
|
end
|
|
90
99
|
|
|
100
|
+
def compute_prev_bcd(date, bill_cycle_day_local)
|
|
101
|
+
return date - 30 if bill_cycle_day_local.blank?
|
|
102
|
+
|
|
103
|
+
bcd = bill_cycle_day_local.to_i
|
|
104
|
+
bcd = 28 if bcd > 28
|
|
105
|
+
bcd = 1 if bcd < 1
|
|
106
|
+
|
|
107
|
+
prev_month = date.prev_month
|
|
108
|
+
last_day = [bcd, Date.new(prev_month.year, prev_month.month, -1).day].min
|
|
109
|
+
Date.new(prev_month.year, prev_month.month, last_day)
|
|
110
|
+
rescue ArgumentError
|
|
111
|
+
date - 30
|
|
112
|
+
end
|
|
113
|
+
|
|
91
114
|
def fetch_unit_types(subscription, start_date, cached_options)
|
|
92
115
|
if Killbill::Aviate::AviateClient.aviate_catalog?(subscription.account_id, cached_options)
|
|
93
116
|
fetch_billing_meter_codes(subscription, cached_options)
|
|
@@ -148,7 +171,7 @@ module Aviate
|
|
|
148
171
|
|
|
149
172
|
return samples_by_unit if unit_types.empty?
|
|
150
173
|
|
|
151
|
-
# rubocop:disable ThreadSafety/NewThread -- fetching samples for each unit type in parallel is intentional
|
|
174
|
+
# rubocop:disable-next ThreadSafety/NewThread -- fetching samples for each unit type in parallel is intentional
|
|
152
175
|
threads = unit_types.map do |unit_type|
|
|
153
176
|
Thread.new do
|
|
154
177
|
samples = Killbill::Aviate::AviateClient.host_samples(
|
|
@@ -160,7 +183,6 @@ module Aviate
|
|
|
160
183
|
[unit_type, []]
|
|
161
184
|
end
|
|
162
185
|
end
|
|
163
|
-
# rubocop:enable ThreadSafety/NewThread
|
|
164
186
|
|
|
165
187
|
threads.each do |t|
|
|
166
188
|
unit_type, samples = t.value
|
|
@@ -16,15 +16,13 @@
|
|
|
16
16
|
</p>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
|
-
<% if @
|
|
19
|
+
<% if @unit_types.present? || @accrued_cost.present? || @wallet_balance.present? %>
|
|
20
20
|
<div class="usage-stats d-flex gap-4 mb-4">
|
|
21
|
-
<%
|
|
22
|
-
|
|
23
|
-
<div class="stat-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
</div>
|
|
27
|
-
<% end %>
|
|
21
|
+
<% @unit_types.each do |unit_type| %>
|
|
22
|
+
<div class="stat-card card p-3">
|
|
23
|
+
<div class="stat-label text-muted small">Units Consumed (<%= unit_type %>)</div>
|
|
24
|
+
<div class="stat-value h4"><%= @chart_data[unit_type]&.last&.dig('y') || 0 %></div>
|
|
25
|
+
</div>
|
|
28
26
|
<% end %>
|
|
29
27
|
|
|
30
28
|
<% if @accrued_cost.present? %>
|
data/lib/aviate/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: killbill-aviate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0.pre.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kill Bill core team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: killbill-assets-ui
|
|
@@ -125,9 +125,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
125
|
version: '0'
|
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
requirements:
|
|
128
|
-
- - "
|
|
128
|
+
- - ">"
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version:
|
|
130
|
+
version: 1.3.1
|
|
131
131
|
requirements: []
|
|
132
132
|
rubygems_version: 3.4.10
|
|
133
133
|
signing_key:
|