Skip to content

feat(metrics): wiki on unified metric-results - #1812

Merged
aleksdotbar merged 5 commits into
mainfrom
feat/unified-metrics-wiki
Jul 17, 2026
Merged

feat(metrics): wiki on unified metric-results#1812
aleksdotbar merged 5 commits into
mainfrom
feat/unified-metrics-wiki

Conversation

@aleksdotbar

@aleksdotbar aleksdotbar commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Migrate the wiki family to /v1/metric-results, mirroring the git/collab/task cutovers. Wiki was the last IC family on the legacy bullet path (insight.wiki_bullet_rows + seeded query_refs).

What

  • New gold wiki_metric_observations over the wiki silver classes, plus registry seeds — four metrics served on the unified path:
    • wiki.pages_created — pages authored (from class_wiki_pages)
    • wiki.edits — logical edit sessions
    • wiki.pages_edited — distinct pages edited (new)
    • wiki.comments — comments received on the person's pages
  • edits binds to class_wiki_activity.total_edits (autosave-collapsed, per real editor, edit-dated) instead of the legacy page-snapshot version_count-1, which over-counted saves and credited every revision to the page's original author. Values will read lower than the legacy dashboard — intended.
  • comments keep page-author attribution (engagement received, per Figma: Bronze connector #285 design); the engagement->pages join adds source_id to prevent cross-instance fan-out.
  • active_authors dropped from the per-person set (team can derive it).
  • Attribution keys on lowercased author email; unresolved accounts are excluded (honest absence), consistent with git/task/collab.

Placeholder fix

Separate commit: the bronze bootstrap never created wiki_page_versions stand-ins for either connector, so class_wiki_activity failed to build on any instance without a real versions sync — the root of the historical "unstable on dev" note. Added both placeholders.

Safety

Purely additive: legacy wiki_bullet_rows + seeds + catalog untouched (old FE keeps working). Gold is materialized='table' (full CTAS) so no positional/incremental drift. Placeholder script is IF NOT EXISTS, idempotent on existing instances.

Verification

  • cargo fmt --check, clippy -D warnings, cargo test -p analytics (437 passed)
  • dbt build +wiki_metric_observations — 132/132
  • Booted the service; /v1/metric-results serves all four × period/peer/timeseries with exact ClickHouse parity; pages_created/comments match legacy, edits lower by design.

Deferred: e2e retarget to wiki.* (no unified-endpoint 200 fixture repo-wide yet), legacy wiki_bullet_rows retirement.

Closes #1700

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added wiki activity metrics for pages created, edits, pages edited, and comments.
    • Added standardized wiki observations for person-level analytics.
    • Added support for wiki page-version data on fresh installations.
  • Bug Fixes

    • Added data-quality checks for malformed identities, negative values, duplicate records, and unexpected dimensions.
  • Documentation

    • Updated wiki model documentation to reflect its analytics role.

aleksdotbar and others added 2 commits July 17, 2026 12:58
Reproduce the wiki bullet metrics on the unified path — a gold
observation view over the wiki silver classes plus registry seeds —
so pages-created, edits, pages-edited and comments-received serve
through /v1/metric-results like the other families.

edits binds to class_wiki_activity.total_edits (session-collapsed,
per actual editor, edit-dated) rather than the legacy page-snapshot
version_count-1, which over-counted autosaves and credited every
revision to the page's original author. pages-edited is new from the
same rollup. comments stay attributed to the page author (engagement
received); the engagement->pages join adds source_id to prevent
cross-instance fan-out. active-authors is dropped.

Attribution keys on the lowercased author email; accounts that do not
resolve to one are excluded rather than carried as unmatchable ids.

Closes #1700

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
class_wiki_activity reads confluence/outline wiki_page_versions, but
the bronze bootstrap never created stand-ins for them, so the model
failed to build on any instance without a real versions sync. Add both
placeholders (IF NOT EXISTS, columns per each connector's schema) so a
fresh bronze bootstraps a buildable wiki activity class.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar requested a review from a team as a code owner July 17, 2026 11:00
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 10 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: 6910496b-dd1c-4d9e-b976-672e3846b05a

📥 Commits

Reviewing files that changed from the base of the PR and between bd6d39c and 6e76fae.

📒 Files selected for processing (1)
  • src/ingestion/gold/wiki_metric_observations.sql
📝 Walkthrough

Walkthrough

Changes

Wiki unified metrics

Layer / File(s) Summary
Wiki ingestion prerequisites
src/ingestion/scripts/create-bronze-placeholders.sh
Adds guarded ClickHouse placeholders for Outline and Confluence wiki page versions.
Wiki observation model and validation
src/ingestion/gold/wiki_metric_observations.sql, src/ingestion/gold/schema.yml, src/ingestion/silver/wiki/schema.yml, src/ingestion/dbt/tests/gold/*wiki_observations*
Adds standardized person-level observations for page creation, edits, edited pages, and comments, with schema constraints and integrity checks.
Wiki analytics registration
src/backend/services/analytics/src/domain/metric_definitions/builtin.rs
Registers the wiki source and four built-in sum metrics with integer units and organization-unit peer cohorts.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WikiSources
  participant WikiMetricObservations
  participant AnalyticsRegistry
  WikiSources->>WikiMetricObservations: aggregate page, activity, and engagement data
  WikiMetricObservations->>AnalyticsRegistry: expose standardized wiki measures
  AnalyticsRegistry->>AnalyticsRegistry: resolve four built-in wiki metrics
Loading

Possibly related issues

  • constructorfabric/insight#1561 — Covers the unified wiki metric migration with normalized observations and typed metric definitions.
  • constructorfabric/insight#1696 — Describes a similar migration pattern involving dbt gold observations and backend metric registration.

Possibly related PRs

Suggested reviewers: ktursunov

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Most #1700 requirements are met, but the diff does not show the requested unit tests. Add unit tests for the wiki metric registry/model behavior to satisfy the authoring standard.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the wiki metrics migration to unified metric-results.
Out of Scope Changes check ✅ Passed The placeholder, schema, and test additions all support the wiki migration and do not appear unrelated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/unified-metrics-wiki

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/ingestion/gold/wiki_metric_observations.sql`:
- Around line 54-115: Update the pages, activity, and engagement CTE flow to
pre-aggregate records at (tenant_id, entity_id, metric_date) so each metric
emits one row per unique grain. Separate the pages base data used for engagement
joins from the daily pages aggregation, remove the created_at IS NOT NULL
exclusion from the join source, and retain engagement rows for pages lacking
timestamps. Apply the corresponding day-grain GROUP BY clauses before the
value_measures unions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e439fb2c-5a61-4e20-94b6-43ab87aa1ba2

📥 Commits

Reviewing files that changed from the base of the PR and between b51da6b and bd6d39c.

📒 Files selected for processing (9)
  • src/backend/services/analytics/src/domain/metric_definitions/builtin.rs
  • src/ingestion/dbt/tests/gold/assert_wiki_observations_entity_id_shape.sql
  • src/ingestion/dbt/tests/gold/assert_wiki_observations_nonnegative.sql
  • src/ingestion/dbt/tests/gold/assert_wiki_observations_subject_key_shape.sql
  • src/ingestion/dbt/tests/gold/assert_wiki_observations_unique_grain.sql
  • src/ingestion/gold/schema.yml
  • src/ingestion/gold/wiki_metric_observations.sql
  • src/ingestion/scripts/create-bronze-placeholders.sh
  • src/ingestion/silver/wiki/schema.yml

Comment thread src/ingestion/gold/wiki_metric_observations.sql
The comment join reused the pages_created branch, whose created_at
gate exists only to date the creation metric — so comments on a page
snapshot lacking the timestamp were dropped. Split the join source
(page -> author, email gate only) from the dated creation branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar enabled auto-merge July 17, 2026 11:41
@aleksdotbar
aleksdotbar merged commit 46f6742 into main Jul 17, 2026
34 checks passed
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.

feat: migrate wiki metrics to unified metric system (backend)

2 participants