Skip to content

Share analytics queries and package downloads - #24350

Merged
MikeMcQuaid merged 1 commit into
mainfrom
analytics-query-refactor
Oct 24, 2026
Merged

MikeMcQuaid merged 1 commit into
mainfrom
analytics-query-refactor

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member
  • Extract InfluxDB queries so API generators can call Ruby directly.
  • Share cached package totals between brew info and API generation.
  • Keep query formatting and reader tests with their implementations.

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Codex with GPT 6 Astra at Extra High effort, with local review and testing.


@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 49197619-65bd-41c2-97ca-7eb7ad10bf01
Commits

Reviewing files that changed from the base of the PR and between 999b063 and d8fcbd4.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Summary

Summary by CodeRabbit

  • New Features
    • GitHub Packages download reporting now shows all-time and last-30-day totals, the date range covered and when the data was fetched. Where install-event data is available, it also shows the ratio of downloads to install events.
    • Download snapshots are reused for the remainder of the day and refreshed the following day.
  • Bug Fixes
    • When download data is unavailable, the report now warns that it could not retrieve data for the formula.
  • Documentation
    • Updated analytics guidance to describe the GitHub Packages download report.

The pull request moves Influx analytics setup, queries, and result formatting into a dedicated client. It also adds cached GitHub Packages download snapshots and updates analytics output to display those counts and their ratio to install events.

Changes: Influx analytics

Layer / File(s) Summary
Influx client setup and query bridge
Library/Homebrew/utils/analytics/influx.rb, Library/Homebrew/test/utils/analytics/influx_spec.rb
The new client sets up its Python environment, sends query requests, yields JSON-line records, and reports query failures.
Query construction and result formatting
Library/Homebrew/utils/analytics/influx.rb, Library/Homebrew/test/utils/analytics/influx_spec.rb
The client validates settings, builds category queries, filters and aggregates records, and formats ranked results and OS-version dimensions. Specs cover query output, ranking, and version formatting.
Command delegation
Library/Homebrew/dev-cmd/formula-analytics.rb, Library/Homebrew/test/dev-cmd/formula-analytics_spec.rb
The command delegates setup and queries to the client, handles the setup-check option, and prints results as pretty JSON. The spec retains the parseable-arguments example.

GitHub Packages download reporting

Layer / File(s) Summary
Download snapshot and cache
Library/Homebrew/github_packages.rb, Library/Homebrew/test/github_packages_spec.rb
GitHubPackages.downloads returns a same-day cached snapshot or fetches and validates fresh totals and daily counts. Specs cover counts, cache refresh, and missing chart data.
Analytics output and documentation
Library/Homebrew/utils/analytics.rb, Library/Homebrew/test/utils/analytics_spec.rb, docs/Analytics.md
Analytics output displays all-time and 30-day counts, the date range, fetch time, and the ratio to install events. Specs and documentation reflect the updated output.

Priority: Normal

Merge Risk: Low · up to 999b0

The new GitHub Packages download reporting works as intended. One new test does not exercise the case it is named for, so a future regression in missing-chart handling could go unnoticed. Fixing the fixture is a one-line change and is not a blocker for merging.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title "Share analytics queries and package downloads" matches the main changes. The PR extracts InfluxDB queries into a Ruby utility (utils/analytics/influx.rb) and adds a shared GitHubPackages.do…
Description check Passed The description lists the three goals of the PR: extracting InfluxDB queries for API generators, sharing cached package totals between brew info and API generation, and keeping query formatting and re…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Share analytics queries and package downloads" matches the main changes. The PR extracts InfluxDB queries into a Ruby utility (utils/analytics/influx.rb) and adds a shared GitHubPackages.downloads method used by brew info and analytics output. The title is specific and concise, and it names both main parts of the change.

Full details: Description check

Explanation

The description lists the three goals of the PR: extracting InfluxDB queries for API generators, sharing cached package totals between brew info and API generation, and keeping query formatting and reader tests with their implementations. These match the changeset, which moves query logic into Utils::Analytics::Influx, adds GitHubPackages.downloads with a per-formula cache, and moves related specs. The description is specific enough to relate to the change.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
Library/Homebrew/test/github_packages_spec.rb: 1

46-46: Trivial · Maintainability & Code Quality · Quick win

Give the missing-chart example a valid total.

This fixture omits both the chart and the Total downloads label. GitHubPackages.downloads returns at total.nil?, so the example cannot detect a regression in the missing-chart check. Add matching total markup and leave the chart absent.

🔇 Additional comments: 4
Library/Homebrew/utils/analytics/influx.rb: 1

1-386: LGTM!

Library/Homebrew/test/utils/analytics/influx_spec.rb: 1

1-158: LGTM!

Library/Homebrew/dev-cmd/formula-analytics.rb: 1

4-4: LGTM!

Also applies to: 67-70, 89-91

Library/Homebrew/github_packages.rb-67-67: 1

67-67: Minor · Data Integrity & Integration · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Reject incomplete chart date coverage.

If the chart omits a day with downloads, this check still accepts the remaining bars. The method then caches a partial sum as last_30_days, and brew info reports it as a 30-day count. Check date coverage before caching the snapshot. Allow a shorter range when the package has not existed for 30 days.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0834bbdc-20d4-45f7-a253-9fa06a4ef2ba
Commits

Reviewing files that changed from the base of the PR and between 39b07ff and 999b063.

Files selected for processing: 9
  • Library/Homebrew/dev-cmd/formula-analytics.rb
  • Library/Homebrew/github_packages.rb
  • Library/Homebrew/test/dev-cmd/formula-analytics_spec.rb
  • Library/Homebrew/test/github_packages_spec.rb
  • Library/Homebrew/test/utils/analytics/influx_spec.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/utils/analytics.rb
  • Library/Homebrew/utils/analytics/influx.rb
  • docs/Analytics.md
Files with no reviewable changes: 1
  • Library/Homebrew/test/dev-cmd/formula-analytics_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

- Extract InfluxDB queries so API generators can call Ruby directly.
- Share cached package totals between `brew info` and API generation.
- Keep query formatting and reader tests with their implementations.
@MikeMcQuaid
MikeMcQuaid force-pushed the analytics-query-refactor branch from 999b063 to d8fcbd4 Compare October 24, 2026 16:30
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit b51000c Oct 24, 2026
54 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the analytics-query-refactor branch October 24, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants