BUZZ-231: add command for count - #528
Merged
sarahweeks-prolific merged 6 commits intoSep 30, 2026
Merged
sarahweeks-prolific merged 6 commits into
sarahweeks-prolific merged 6 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Reconcile the privacy threshold before approval; help and README updates are also outstanding.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds prolific audience count for counting eligible participants from filter templates or saved filter sets.
Changes:
- Adds audience/count commands with human-readable and JSON output.
- Adds privacy-threshold metadata, tests, and an example template.
- Registers the new command.
Open items include reconciling the privacy threshold and updating command help and README listings.
| File | Description |
|---|---|
docs/examples/audience-count.json |
Example filter template |
cmd/root.go |
Registers the audience command |
cmd/audience/count.go |
Implements counting, validation, API calls, and rendering |
cmd/audience/count_test.go |
Tests command behavior and output |
cmd/audience/audience.go |
Defines the audience command group |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+12
to
+15
| cmd := &cobra.Command{ | ||
| Use: "audience", | ||
| Short: "Understand your audience of eligible participants", | ||
| } |
sarahweeks-prolific
marked this pull request as ready for review
September 29, 2026 08:22
Co-authored-by: Cursor <[email protected]>
sarahweeks-prolific
force-pushed
the
feat/buzz-231-audience-count
branch
from
September 29, 2026 08:38
5f8d446 to
40e9f23
Compare
…e-count # Conflicts: # CHANGELOG.md # README.md # contract_test/contract_test.go
sarahweeks-prolific
force-pushed
the
feat/buzz-231-audience-count
branch
from
September 30, 2026 10:45
33b7b23 to
5c90d47
Compare
sarahweeks-prolific
changed the base branch from
main
to
feat/buzz-231-audience-breakdown-command
September 30, 2026 12:50
sarahweeks-prolific
merged commit Sep 30, 2026
cc88f11
into
feat/buzz-231-audience-breakdown-command
6 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds prolific audience count, a wrapper over POST /api/v1/eligibility-count/ that counts how many participants match a set of filters, without creating a study or saving a filter set (BUZZ-231). Counts an unsaved set of filters via -t/--template-path or --filters, or a saved filter set via --filter-set — the latter reads eligible_participant_count straight off the existing filter-set response, so it stays one request rather than a count call per filter.
$ prolific audience count -t docs/examples/audience-count.json -w
Eligible participants: 1234
$ prolific audience count --filter-set --json
{"count":42,"below_privacy_threshold":false}
The API floors counts below 5 to 0, so --json carries below_privacy_threshold next to count — a bare {"count": 0} would read as "nobody is eligible" to an agent when the truth may be "four people are".
Breaking change: this PR removes the old eligibility-count command. audience count is a strict superset — same -t/-w flags, same template format — so prolific eligibility-count -t filters.json -w becomes prolific audience count -t filters.json -w . Noted under ## next in CHANGELOG.md. The old command's help text said the privacy floor was 25; the published spec says 5 in two independent places (the count endpoint description and the filter-set response field), so audience count uses 5 — removing the old command also removes that contradiction from the codebase rather than leaving two commands disagreeing on the same number.
Implementation
New cmd/audience package: an audience parent command (pure router) with count as a subcommand, following the documented Two-Level Command Structure
Filters can be provided three ways: -t/--template-path (file), --filters (raw JSON array, for scripting without a temp file — mirrors the pattern used by audience breakdown in #527), or --filter-set (by ID). Mutually exclusive; exactly one is required
Removes cmd/eligibilitycount/; reuses the existing GetEligibilityCount, EligibilityCountPayload and GetFilterSet client methods as-is — no client/payload/response/model changes
-j is bound by hand rather than through shared.AddOutputFlags, which claims -t for --table and would collide with --template-path; noted in a comment at the flag
Composite and/or groups still can't be expressed via -t or --filters, since model.Filter has no selected_filters — pre-existing and shared with the old eligibility-count, stated explicitly in the command's --help
docs/examples/audience-count.json example template
contract_test/contract_test.go and the README coverage table also gained skip entries for five operations that appeared in the live spec independently of this feature (four aiTaskBuilder_* export-job operations, plus messages_CreateConversation) — unrelated schema drift that was blocking make test, not part of this feature
Known overlap with #527: both PRs create cmd/audience/audience.go and touch the same lines in cmd/root.go (registering count vs breakdown respectively). Whichever merges second needs to reconcile both AddCommand calls into one file.
Testing
cmd/audience/count_test.go covers all three input paths, the payload actually sent over the wire, JSON and human-readable rendering at and above the privacy floor, empty-filters-not-nil, input validation (no input, any two inputs together, missing workspace), config/JSON parse failures, and API errors from both endpoints. make build, go vet ./..., gofmt, and the full test suite (including contract_test) pass locally.
🤖 Generated with Claude Code