power-bi 2.6.0 → 2.6.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: a22ca0a37fc03e4fd19214f0ecb71c8fedf820fabbbc9e7a7e5add198e0ab25a
4
- data.tar.gz: 61fc121ec95aa7cc815b7ee4e84a9fe28facbb2c5177dbe91e519e17ebcfae19
3
+ metadata.gz: ad399c89996fb5bc9d8503233c2827c7f57366cd849e16c3e780048a8f1973ae
4
+ data.tar.gz: a2ffbbac846e08cc9e9fefd52b86e9a996802ec51e5a4f748f0ab8c8799f4b87
5
5
  SHA512:
6
- metadata.gz: 1c69b92f3b68c19b67a417ba7deb402b4bcc8130ebf074260e97b36c62f773ac27e3720d4fa3946060ad1d8d062bbcf95768c436f7be207e773f849a818a633f
7
- data.tar.gz: 9454fcb89c9de930616e8ea944fb9aba73f5cfa558e2bef1e755c4f16ec66164dff386154532242ebd55242bc6ccd6ecbcc59fce3f64bf5e8fca554ed309ee59
6
+ metadata.gz: 88c0f92c90ae4392b20ea6a85f7be737302857735135b73cba780c2afd31349b672772ac2d95e38fa40a4cd01d8ae226edf49acab7caf4219c118c99021559c8
7
+ data.tar.gz: 78f8483bfc046ef783b852ec66b6ce7c5645c123e793dd475416de440ac83fb2ae65f3968553e02e8474e983ba06f9b27f32bf0e6ff57f3c406586b8e693427c
@@ -30,28 +30,11 @@ module PowerBI
30
30
  end
31
31
 
32
32
  def get_workspaces(filter: nil, expand: nil)
33
- params = {}
34
- params[:$filter] = filter if filter
35
- params[:$expand] = expand if expand
33
+ base_params = {}
34
+ base_params[:$filter] = filter if filter
35
+ base_params[:$expand] = expand if expand
36
36
 
37
- url = '/admin/groups'
38
-
39
- nr_records = 5000
40
- count = 0
41
-
42
- data = []
43
-
44
- loop do
45
- params[:$top] = nr_records
46
- params[:$skip] = count
47
- resp = @tenant.get(url, params)
48
- data += resp[:value]
49
- batch_count = resp[:value].size
50
- count += batch_count
51
- break if batch_count < nr_records
52
- end
53
-
54
- data
37
+ @tenant.get_paginated('/admin/groups', base_params: base_params)
55
38
  end
56
39
 
57
40
  def force_delete_workspace_by_workspace_name(user_email, workspace_name)
@@ -87,7 +87,7 @@ module PowerBI
87
87
  end
88
88
 
89
89
  def get_data
90
- @tenant.get("/groups/#{@workspace.id}/datasets")[:value]
90
+ @tenant.get_paginated("/groups/#{@workspace.id}/datasets")
91
91
  end
92
92
  end
93
93
  end
@@ -38,7 +38,7 @@ module PowerBI
38
38
  end
39
39
 
40
40
  def get_data
41
- @tenant.get("/profiles", use_profile: false)[:value]
41
+ @tenant.get_paginated("/profiles", use_profile: false)
42
42
  end
43
43
  end
44
44
  end
@@ -106,7 +106,7 @@ module PowerBI
106
106
  end
107
107
 
108
108
  def get_data
109
- @tenant.get("/groups/#{@workspace.id}/reports")[:value]
109
+ @tenant.get_paginated("/groups/#{@workspace.id}/reports")
110
110
  end
111
111
  end
112
112
  end
@@ -198,6 +198,69 @@ module PowerBI
198
198
  JSON.parse(response.body, symbolize_names: true)
199
199
  end
200
200
 
201
+ # Fetches paginated data from the Power BI API using OData-style pagination.
202
+ #
203
+ # Power BI API has a documented limit of 5000 records per request.
204
+ # This method handles pagination automatically by:
205
+ # 1. Requesting 5000 records at a time using $top and $skip
206
+ # 2. If exactly 5000 records are returned, fetching the next page
207
+ # 3. Accumulating all results across pages
208
+ # 4. Deduplicating records by ID (to handle insertions between requests)
209
+ #
210
+ # Note: $skip-based pagination is not fully protected against deletions
211
+ # between requests (a deleted record may cause a subsequent record to go
212
+ # unseen). This risk is acceptable given the short pagination window.
213
+ MAX_PAGE_SIZE = 5000
214
+ MAX_ITERATIONS = 100
215
+ def get_paginated(url, page_size: MAX_PAGE_SIZE, base_params: {}, use_profile: true, max_iterations: MAX_ITERATIONS)
216
+ page_size = [page_size, MAX_PAGE_SIZE].min
217
+
218
+ skip = 0
219
+ all_data = []
220
+ iteration = 0
221
+
222
+ loop do
223
+ iteration += 1
224
+ if iteration > max_iterations
225
+ log "WARNING: Reached maximum iteration limit (#{max_iterations}). " \
226
+ "Fetched #{all_data.size} records so far. This may indicate an API issue or " \
227
+ "an extremely large dataset. Consider using API filters to reduce the result set.",
228
+ level: :warn
229
+ break
230
+ end
231
+
232
+ params = base_params.merge({
233
+ '$top' => page_size,
234
+ '$skip' => skip
235
+ })
236
+
237
+ log "Fetching paginated data from #{url} (skip: #{skip}, top: #{page_size}, iteration: #{iteration})"
238
+
239
+ resp = get(url, params, use_profile: use_profile)
240
+ batch = resp[:value] || []
241
+ all_data += batch
242
+ batch_count = batch.size
243
+
244
+ log "Received #{batch_count} records (total so far: #{all_data.size})"
245
+
246
+ # If we got fewer records than requested, we've reached the last page
247
+ break if batch_count < page_size
248
+
249
+ skip += batch_count
250
+ end
251
+
252
+ # Deduplicate by ID to handle any records that were inserted between requests.
253
+ # Insertions before the current $skip position shift items right, which can
254
+ # cause duplicates across pages.
255
+ deduplicated_data = all_data.uniq{|r| r[:id]}
256
+
257
+ if deduplicated_data.size < all_data.size
258
+ log "Removed #{all_data.size - deduplicated_data.size} duplicate records during deduplication"
259
+ end
260
+
261
+ deduplicated_data
262
+ end
263
+
201
264
  private
202
265
 
203
266
  def add_spp_header(req)
@@ -113,7 +113,7 @@ module PowerBI
113
113
  end
114
114
 
115
115
  def get_data
116
- @tenant.get("/groups")[:value]
116
+ @tenant.get_paginated("/groups")
117
117
  end
118
118
  end
119
119
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power-bi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lode Cools
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-10 00:00:00.000000000 Z
11
+ date: 2026-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday