Skip to content

feat(analytics-api): collab Messaging peer-counter query + catalog seed (#1527) - #1568

Closed
mozhaev-dev wants to merge 1 commit into
mainfrom
feat/collab-messaging-query-catalog
Closed

feat(analytics-api): collab Messaging peer-counter query + catalog seed (#1527)#1568
mozhaev-dev wants to merge 1 commit into
mainfrom
feat/collab-messaging-query-catalog

Conversation

@mozhaev-dev

Copy link
Copy Markdown
Contributor

PR B of the #1527 split — the backend layer over PR A's gold view (#1567). Clones the #1514 AI-personal counter pattern for the collaboration Messaging modality.

Split plan: A gold view (#1567) → B (this) → C e2e YAML → D FE (insight-front).

Changes

  • Query_ref migration m20260702_000001_collab_messaging_queriescollab_messaging_counters_qr:
    • reads insight.collab_person_counter_daily (PR A), re-aggregates per person with the honest-NULL if(countIf(x IS NOT NULL) > 0, sumIf(x, …), NULL) wrapper,
    • ARRAY JOIN unpivot dropping NULLs (person with no source → absent, not fake 0),
    • LEFT JOIN per-org_unit_id quantileExact bands (median/p25/p75 + min/max/count).
    • Stored on metrics.id …0053 (next free after AI counters …0052).
  • Catalog seed m20260702_000002_seed_collab_messaging_catalog — product-default metric_catalog rows for messages_sent + channel_posts, each with an initial product-default metric_threshold (catalog-probe requirement) and a metric_query_catalog junction link. source_tags carry the vendors (["m365","slack","zulip"] / ["m365","slack"]).
  • Register both migrations in mod.rs.

Tests

  • Rust unit (feeds test(analytics-api): unit suites for infra/identity, admin_threshold, api + auth #1433, runs in CI — no DB): asserts the generated SQL emits both keys with the honest-NULL wrapper + per-org_unit band join on (metric_key, org_unit_id).
  • Live test: extend domain/catalog/live_tests.rs::product_default_wins_when_no_tenant_overlay to assert both Messaging keys resolve at product-default (#[ignore], needs MariaDB — not in CI coverage).
  • fmt + clippy::pedantic clean.

Scope / notes

Refs #1527 · #1516

🤖 Generated with Claude Code

…ed (#1527)

PR B of the #1527 split — the backend layer over PR A's gold view. Clones the
#1514 AI-personal counter pattern for the collaboration Messaging modality.

- Query_ref migration (m20260702_000001): `collab_messaging_counters_qr` reads
  insight.collab_person_counter_daily, re-aggregates per person with the
  honest-NULL `if(countIf(x IS NOT NULL) > 0, sumIf …, NULL)` wrapper, ARRAY
  JOIN unpivot (drops NULLs), and LEFT JOINs per-org_unit_id `quantileExact`
  bands. Stored on metrics id …0053 (next free after AI counters …0052).
- Catalog seed (m20260702_000002): product-default metric_catalog rows for
  `messages_sent` + `channel_posts`, each with an initial product-default
  metric_threshold (catalog-probe requirement) and a metric_query_catalog
  junction link to the query. source_tags carry the vendors (m365/slack/zulip).
  Thresholds are initial defaults, NOT calibrated (per-org_unit calibration is
  a post-release follow-up).
- Register both migrations in mod.rs.

Tests:
- Rust unit (feeds #1433): asserts the generated peer-counter SQL emits both
  keys with the honest-NULL wrapper + per-org_unit band join — no DB, runs in
  CI coverage.
- Extend catalog live_tests (`product_default_wins_when_no_tenant_overlay`) to
  assert both Messaging keys resolve at product-default.

Designed for extension: later modalities add keys to the ARRAY JOIN list + seed
rows. Depends on the gold view from PR A (#1567) at deploy time. Honest-NULL
rendering is #1517.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergei Mozhaev <mozhaev.dev@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mozhaev-dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d98e3be6-de9c-4588-a831-ce899051e75c

📥 Commits

Reviewing files that changed from the base of the PR and between fc63c91 and 4dd5eb7.

📒 Files selected for processing (4)
  • src/backend/services/analytics-api/src/domain/catalog/live_tests.rs
  • src/backend/services/analytics-api/src/migration/m20260702_000001_collab_messaging_queries.rs
  • src/backend/services/analytics-api/src/migration/m20260702_000002_seed_collab_messaging_catalog.rs
  • src/backend/services/analytics-api/src/migration/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/collab-messaging-query-catalog

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.

@mozhaev-dev

Copy link
Copy Markdown
Contributor Author

Superseded by #1580 — consolidated with the e2e YAML (and the gold view #1567 as base) so the Metric coverage gate + E2E suite go green on one branch. See #1580.

@mozhaev-dev mozhaev-dev closed this Jul 3, 2026
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.

1 participant