plan_my_stuff 0.15.0 → 0.16.0

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: 8a3c6c6445f04d677b6d6b4f0219f57326346b3f42aee6839ab98a0bbf680e63
4
- data.tar.gz: f5f5adb4f7a11e2d35b907ae7ab1e15d9dc47f31313355be7da186bf9c5086d6
3
+ metadata.gz: 782add7d506a645b1f2c19c413de0ef21c91d31a91e07280c003523767a48368
4
+ data.tar.gz: c20c6aa1e5f98d297cfbcbae5c57c7c5d13dd24b746d26374294196e50b983a5
5
5
  SHA512:
6
- metadata.gz: a31f3331be41dcd8c4a1369f729888e06ec64474a58c0b56d2c7d57d69b647b1f33b7acc0ae4eed26f03491ce5736a3ab60656900fc31e731bbadd2ae68c492c
7
- data.tar.gz: 429281e1a5b431ab29fc5c2d91f15176c7556533df7a94d9990dc3e98a198d5b2d603205bd29f5d4efd210c131bc67b7d440de296857f2eeddd5c085fbc799a2
6
+ metadata.gz: bfcd02d86fa108d59ba15c75b3a7741c0d5c6c2cac701ac785d5d73aeee57025926910785383f5eac0f0c9fdb63ef32a9f72e2174e55ce0cf0c69dcac0c96f00
7
+ data.tar.gz: 8439a857e4d4a170b3802cbe34e040e940915c2b07dca61ea0cf9cd2e9a2995f7b02d447318ecda24ad8891ec080b6b2317a9b9e4b471dd11862002064b3ea19
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Added
6
+
7
+ - `PlanMyStuff::Issue.count(repo:, state:, labels:)` returns the total count of matching issues via the
8
+ GitHub Search API in a single request, without paginating full issue payloads. Mirrors `Issue.list`
9
+ kwargs (minus `page`/`per_page`); returns an `Integer`. Excludes PRs server-side via the `is:issue`
10
+ qualifier.
11
+
3
12
  ## 0.15.0
4
13
 
5
14
  ### Breaking
@@ -312,6 +312,37 @@ module PlanMyStuff
312
312
  filtered.map { |gi| build(gi, repo: resolved_repo) }
313
313
  end
314
314
 
315
+ # Counts GitHub issues matching the given filters without paginating full payloads.
316
+ #
317
+ # Uses GitHub's Search API (+search/issues+), which returns +total_count+ in a single
318
+ # request. The +is:issue+ qualifier excludes PRs server-side.
319
+ #
320
+ # Caveats:
321
+ # - The search index lags writes by up to ~1 minute, so freshly created/closed issues
322
+ # may not be reflected immediately.
323
+ # - The Search API has its own rate limit (30 req/min authenticated) separate from
324
+ # the core REST API.
325
+ #
326
+ # @param repo [Symbol, String, nil] defaults to config.default_repo
327
+ # @param state [Symbol] :open, :closed, or :all
328
+ # @param labels [Array<String>]
329
+ #
330
+ # @return [Integer]
331
+ #
332
+ def count(repo: nil, state: :open, labels: [])
333
+ client = PlanMyStuff.client
334
+ resolved_repo = client.resolve_repo!(repo)
335
+
336
+ normalized_state = state.to_s
337
+ qualifiers = ["repo:#{resolved_repo}", 'is:issue']
338
+ qualifiers << "is:#{normalized_state}" unless normalized_state == 'all'
339
+ labels_to_use = Array.wrap(labels).sort
340
+ qualifiers += labels_to_use.map do |label|
341
+ "label:\"#{label}\""
342
+ end
343
+ client.rest(:search_issues, qualifiers.join(' '), per_page: 1).total_count
344
+ end
345
+
315
346
  # Submits one or more pre-built payloads to GitHub's "Import Issues" preview endpoint
316
347
  # (+POST /repos/:repo/import/issues+). One request per payload: the endpoint only accepts a single
317
348
  # +{issue:, comments:}+ payload at a time.
@@ -3,7 +3,7 @@
3
3
  module PlanMyStuff
4
4
  module VERSION
5
5
  MAJOR = 0
6
- MINOR = 15
6
+ MINOR = 16
7
7
  TINY = 0
8
8
 
9
9
  # Set PRE to nil unless it's a pre-release (beta, rc, etc.)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plan_my_stuff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance