Skip to content

Add 30-day comparison columns to integrations table - #1078

Open
RaHehl wants to merge 3 commits into
home-assistant:devfrom
RaHehl:feature/integrations-month-ago-comparison
Open

RaHehl wants to merge 3 commits into
home-assistant:devfrom
RaHehl:feature/integrations-month-ago-comparison

Conversation

@RaHehl

@RaHehl RaHehl commented Apr 16, 2026

Copy link
Copy Markdown

Add 30-day comparison columns to integrations table

What

Two new columns on the integrations page: ± Installations and ± Position, showing how each integration changed compared to ~30 days ago.

Why

Makes it easy to measure the impact of changes across releases — e.g. after adding new discovery for UniFi Protect, UniFi Access and UniFi Network, you can immediately see how their install numbers and ranking evolve over the following month.

How it works

  • Once per day (when the processing queue completes), the worker looks up the KV history entry closest to 30 days ago and stores it as month_ago inside the existing AnalyticsData object
  • No new KV keys, no extra scheduled tasks — ~2 additional KV operations per day (list + read), negligible cost
  • The site embeds month_ago.integrations into the page at build time; all comparison logic runs client-side
  • If no month_ago data exists yet (first deployment) the columns are simply hidden until history is available
  • New integrations not present in the snapshot are labelled NEW
  • Unchanged values show

Copilot AI review requested due to automatic review settings April 16, 2026 21:29
@RaHehl

RaHehl commented Apr 16, 2026

Copy link
Copy Markdown
Author
image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a “30 days ago” snapshot (month_ago) to the analytics payload and updates the integrations table UI to show ±Installations and ±Position deltas based on that snapshot.

Changes:

  • Worker: looks up the history KV entry closest to 30 days ago and stores it as AnalyticsData.month_ago.
  • Worker: preserves month_ago through analytics schema migrations and updates schedule handler tests accordingly.
  • Site: conditionally renders two new comparison columns on the integrations table (and supports custom table headers in the shared table layout).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
worker/src/handlers/schedule.ts Populates storedAnalytics.month_ago by listing history keys and reading the closest snapshot.
worker/src/utils/migrate.ts Preserves month_ago field across analytics data migrations.
worker/src/data.ts Adds MonthAgoData type and optional month_ago field on AnalyticsData.
worker/tests/handlers/schedule.spec.ts Extends PROCESS_QUEUE test to mock history list/get and assert month_ago is written.
site/src/integrations.html Adds conditional UI to show ±Installations / ±Position vs month-ago snapshot.
site/src/_layouts/table.html Allows pages to override the table header via customTableHeader.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread worker/tests/handlers/schedule.spec.ts Outdated
Comment thread site/src/integrations.html Outdated
Comment thread worker/src/handlers/schedule.ts
Comment thread worker/src/handlers/schedule.ts Outdated
Comment thread worker/src/utils/migrate.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants