killbill-aviate 2.5.0.pre.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bee60163cbf0ca265183dedb23b84706b33b861fb9930388011d26624a31b203
4
- data.tar.gz: d2e489be4421c15c412cf41f4e38936f56b4c13f0cbbd7f40423d159e4c4f701
3
+ metadata.gz: a62b8480ef36de4d4b7b940fe459b21f8558d709ca383d166f7646db74fbcc0f
4
+ data.tar.gz: 687a487132071980ab83a7fa071eedd743b03278426f91741a5f0b779c362bd7
5
5
  SHA512:
6
- metadata.gz: 99e627e23ceada4b4f3869da12191f00df3679438216387f99e84e15f5d0bd91f8ce1ae559f62fc981bce01cacd650fe3ebe275a21717f5fa5222652cc6a4d2b
7
- data.tar.gz: 9528968cc7255029e32303f73133cb2d896d39bf516f179293b9262b857b1ddf4e6d941d52c97d66e70dff66bc87e991892d6f817bc548669d171f4ccb601d64
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
- ctd = parse_kb_date(subscription.charged_through_date)
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 Time.zone.today if date_str.blank?
79
+ return nil if date_str.blank?
74
80
 
75
81
  Date.parse(date_str.to_s)
76
82
  rescue ArgumentError
77
- Time.zone.today
83
+ nil
78
84
  end
79
85
 
80
86
  def compute_next_bcd(start_date, bill_cycle_day_local)
@@ -171,8 +177,8 @@ module Aviate
171
177
 
172
178
  return samples_by_unit if unit_types.empty?
173
179
 
174
- # rubocop:disable-next ThreadSafety/NewThread -- fetching samples for each unit type in parallel is intentional
175
180
  threads = unit_types.map do |unit_type|
181
+ # rubocop:disable-next ThreadSafety/NewThread -- fetching samples for each unit type in parallel is intentional
176
182
  Thread.new do
177
183
  samples = Killbill::Aviate::AviateClient.host_samples(
178
184
  subscription_id, unit_type, from, to, cached_options
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
- result
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aviate
4
- VERSION = '2.5.0.pre.1'
4
+ VERSION = '2.6.0.pre.1'
5
5
  end
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.5.0.pre.1
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-08-25 00:00:00.000000000 Z
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
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '7.0'
61
+ version: '7.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '7.0'
68
+ version: '7.2'
69
69
  description: Rails UI plugin for the Aviate plugin.
70
70
  email: killbilling-users@googlegroups.com
71
71
  executables: []