Skip to content

Add Rank Tracking metric filters and fix null-last sort ordering#75

Merged
bensenescu merged 2 commits into
every-app:mainfrom
A-S-Manoj:fix/rank-tracking-filters-null-sort
Jul 13, 2026
Merged

Add Rank Tracking metric filters and fix null-last sort ordering#75
bensenescu merged 2 commits into
every-app:mainfrom
A-S-Manoj:fix/rank-tracking-filters-null-sort

Conversation

@A-S-Manoj

@A-S-Manoj A-S-Manoj commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Closes #69

Changes

  • Added min/max range filters for Volume, Keyword Difficulty, and CPC in the Rank Tracking filter panel, alongside the existing position filters.
  • Fixed null-last sorting: the previous custom comparator returned a fixed +1/-1 to push nulls last, but TanStack Table negates the entire comparator result when sorting descending — so nulls ended up first instead of last in that direction. Switched to TanStack's built-in sortUndefined: "last" column option, which handles this independently of sort direction.
  • Split RankTrackingFilters.tsx into a UI component file and a RankTrackingFilters.logic.ts file to stay under the project's file-length lint limit. The public import path (./RankTrackingFilters) is unchanged via a re-export, so no other files needed updates.

Testing

  • pnpm ci:check passes locally
  • pnpm test passes locally
  • Added unit tests covering:
    • Metric range filtering (Volume, KD, CPC)
    • Null metric handling when filters are active
    • Zero-value edge cases (e.g. KD 0)

Greptile Summary

This PR adds metric filters and updates null-last sorting for rank tracking. The main changes are:

  • Adds min/max filters for volume, keyword difficulty, and CPC.
  • Moves rank-tracking filter logic into RankTrackingFilters.logic.ts while preserving the existing import path.
  • Updates numeric columns to use sortUndefined: "last" so missing values stay last in both sort directions.
  • Adds unit tests for metric range filtering, null metric handling, and zero-value cases.

Confidence Score: 5/5

Safe to merge with low risk.

Changes are contained to client-side rank tracking filters, sorting accessors, and focused tests. No correctness, security, or behavioral coverage issues were identified in the changed paths.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The local rank-tracking seed initialization completed with exit code 0, as shown in the seed log.
  • Dev-server start attempts and blockers are documented across the start-retry, server-ci, and server-final logs.
  • The focused filter logic test suite passed, as verified in the filters vitest log.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/client/features/rank-tracking/RankTrackingColumns.tsx Replaces custom null-last numeric comparators with undefined accessors and TanStack sortUndefined: "last" for metric and position columns.
src/client/features/rank-tracking/RankTrackingFilters.logic.ts Extracts filter helper logic and adds metric range matching for volume, keyword difficulty, and CPC.
src/client/features/rank-tracking/RankTrackingFilters.tsx Keeps the public filter module export while adding UI controls for metric min/max filters.
src/client/features/rank-tracking/RankTrackingFilters.test.ts Adds focused unit coverage for metric filters, null metric exclusion when bounded, and zero-value edge cases.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant FilterPanel
participant Logic as RankTrackingFilters.logic
participant Table as RankTrackingTable
participant Columns as RankTrackingColumns

User->>FilterPanel: Enter min/max metric filters
FilterPanel->>Logic: Update Filters state
Logic->>Logic: applyFilters(rows, filters)
Logic-->>Table: Filtered rows
User->>Columns: Toggle numeric column sort
Columns-->>Table: Accessor value or undefined
Table-->>User: Render sorted rows with undefined values last
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant FilterPanel
participant Logic as RankTrackingFilters.logic
participant Table as RankTrackingTable
participant Columns as RankTrackingColumns

User->>FilterPanel: Enter min/max metric filters
FilterPanel->>Logic: Update Filters state
Logic->>Logic: applyFilters(rows, filters)
Logic-->>Table: Filtered rows
User->>Columns: Toggle numeric column sort
Columns-->>Table: Accessor value or undefined
Table-->>User: Render sorted rows with undefined values last
Loading

Reviews (1): Last reviewed commit: "Merge branch 'every-app:main' into fix/r..." | Re-trigger Greptile

@bensenescu bensenescu merged commit 65f7baf into every-app:main Jul 13, 2026
3 checks passed
@bensenescu

Copy link
Copy Markdown
Contributor

Thanks for this, hope you join the discord! https://discord.com/invite/c9uGs3cFXr

@A-S-Manoj

Copy link
Copy Markdown
Contributor Author

Thanks! Glad to contribute, and I'll definitely check out the Discord.

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.

Add Rank Tracking metric filters and keep nulls last

2 participants