killbill-aviate 2.5.0 → 2.6.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 +9 -3
- data/lib/aviate/client.rb +11 -3
- 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: a62b8480ef36de4d4b7b940fe459b21f8558d709ca383d166f7646db74fbcc0f
|
|
4
|
+
data.tar.gz: 687a487132071980ab83a7fa071eedd743b03278426f91741a5f0b779c362bd7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e35b059d90bd65d1b894d219694a79ea2b6c16ae232c781eb4e7e76306da5911739e4879758d51c6a504920a57ce0dc062a5a50666a8d8a8688737135c7a026
|
|
7
|
+
data.tar.gz: dd2ff55665575f2f1fb4e1e60f92866d555d72250015cfdb22da0c77b9a25958091c3f91d5bd2b5bda7b004c42beb98a6ab8dc54d3e2dc18c3ea4bfa331f85ef
|
|
@@ -57,7 +57,13 @@ module Aviate
|
|
|
57
57
|
|
|
58
58
|
def billing_period(subscription)
|
|
59
59
|
today = Time.zone.today
|
|
60
|
-
|
|
60
|
+
# A usage subscription has no charged_through_date until its first invoice: anchor the
|
|
61
|
+
# period on its (billing) start date, not on today, so usage recorded between the start
|
|
62
|
+
# date and today still falls inside the displayed period (technical-support#302).
|
|
63
|
+
ctd = parse_kb_date(subscription.charged_through_date) ||
|
|
64
|
+
parse_kb_date(subscription.billing_start_date) ||
|
|
65
|
+
parse_kb_date(subscription.start_date) ||
|
|
66
|
+
today
|
|
61
67
|
bcd = subscription.bill_cycle_day_local
|
|
62
68
|
|
|
63
69
|
if ctd > today
|
|
@@ -70,11 +76,11 @@ module Aviate
|
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
def parse_kb_date(date_str)
|
|
73
|
-
return
|
|
79
|
+
return nil if date_str.blank?
|
|
74
80
|
|
|
75
81
|
Date.parse(date_str.to_s)
|
|
76
82
|
rescue ArgumentError
|
|
77
|
-
|
|
83
|
+
nil
|
|
78
84
|
end
|
|
79
85
|
|
|
80
86
|
def compute_next_bcd(start_date, bill_cycle_day_local)
|
data/lib/aviate/client.rb
CHANGED
|
@@ -136,7 +136,7 @@ module Killbill
|
|
|
136
136
|
|
|
137
137
|
request_options = build_request_options(options)
|
|
138
138
|
response = KillBillClient::API.get path, query_params, request_options
|
|
139
|
-
parse_csv_response(response.body)
|
|
139
|
+
parse_csv_response(response.body, subscription_id, sample_kind)
|
|
140
140
|
rescue KillBillClient::API::ResponseError
|
|
141
141
|
[]
|
|
142
142
|
end
|
|
@@ -168,7 +168,7 @@ module Killbill
|
|
|
168
168
|
account_id.present? ? { accountId: account_id } : {}
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
def parse_csv_response(body)
|
|
171
|
+
def parse_csv_response(body, expected_category = nil, expected_sample_kind = nil)
|
|
172
172
|
return [] if body.nil? || body.strip.empty?
|
|
173
173
|
|
|
174
174
|
# The host_samples endpoint returns a JSON array. Each element has a
|
|
@@ -180,6 +180,12 @@ module Killbill
|
|
|
180
180
|
|
|
181
181
|
result = []
|
|
182
182
|
parsed.each do |entry|
|
|
183
|
+
# Ignore entries for other categories/sample kinds: some plugin versions return
|
|
184
|
+
# unfiltered data when the requested subscription has no samples yet
|
|
185
|
+
# (technical-support#301).
|
|
186
|
+
next if expected_category.present? && entry['eventCategory'] != expected_category
|
|
187
|
+
next if expected_sample_kind.present? && entry['sampleKind'] != expected_sample_kind
|
|
188
|
+
|
|
183
189
|
samples_str = entry['samples']
|
|
184
190
|
next if samples_str.nil? || samples_str.strip.empty?
|
|
185
191
|
|
|
@@ -195,7 +201,9 @@ module Killbill
|
|
|
195
201
|
end
|
|
196
202
|
end
|
|
197
203
|
|
|
198
|
-
|
|
204
|
+
# Samples may span multiple entries (e.g. one per node): keep them chronological
|
|
205
|
+
# for the cumulative chart computation.
|
|
206
|
+
result.sort_by { |s| s[:date] }
|
|
199
207
|
rescue StandardError
|
|
200
208
|
[]
|
|
201
209
|
end
|
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.6.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-09-
|
|
11
|
+
date: 2026-09-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:
|