Skip to content

Commit 27b18ea

Browse files
authored
Merge pull request #282 from RivianTrackr/sort-rolling-resistance
Add "Rolling Resistance: Low → High" sort option (v1.50.1)
2 parents ead23ea + f541d20 commit 27b18ea

9 files changed

Lines changed: 26 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to the Rivian Tire Guide plugin will be documented in this f
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [1.50.1] - 2026-06-17
8+
9+
### Added
10+
- **"Rolling Resistance: Low → High" sort option.** The tire-guide sort dropdown can now order tires by their estimated rolling-resistance coefficient (`roamer_crr`), lowest first. Tires without a Crr estimate sort to the bottom in both client-side and server-side pagination (`(roamer_crr = 0) ASC, roamer_crr ASC`). Added to the allowed-sort lists (client URL state, AJAX, and the shortcode `sort=""` attribute); mirrors the existing "Real-World Efficiency" sort and, like it, is not exposed in the REST API sort enum.
11+
712
## [1.50.0] - 2026-06-17
813

914
### Added

frontend/js/modules/filters.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,16 @@ function applySorting(sortOption) {
491491
return bVal - aVal;
492492
});
493493
break;
494+
case "rolling-resistance":
495+
state.filteredRows.sort((a, b) => {
496+
const aVal = parseFloat(a[28]) || 0;
497+
const bVal = parseFloat(b[28]) || 0;
498+
// Tires without a Crr estimate go to bottom; lower Crr is better.
499+
if (aVal > 0 && bVal === 0) return -1;
500+
if (aVal === 0 && bVal > 0) return 1;
501+
return aVal - bVal;
502+
});
503+
break;
494504
}
495505
}
496506

frontend/js/modules/validation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const NUMERIC_BOUNDS = {
2626

2727
export const ALLOWED_SORT_OPTIONS = [
2828
"efficiencyGrade", "roamer-efficiency",
29+
"rolling-resistance",
2930
"price-asc", "price-desc",
3031
"warranty-desc", "weight-asc",
3132
"reviewed", "rating-desc",

frontend/js/rivian-tires.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/templates/tire-guide.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<select id="sortBy" aria-label="Sort tires by">
106106
<option value="efficiencyGrade">Efficiency Grade</option>
107107
<option value="roamer-efficiency" selected>Real-World Efficiency</option>
108+
<option value="rolling-resistance">Rolling Resistance: Low → High</option>
108109
<option value="most-reviewed">Most Reviewed</option>
109110
<option value="newest">Newest Added</option>
110111
<option value="price-asc">Price: Low → High</option>

includes/class-rtg-ajax.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class RTG_Ajax {
3939
'weight-asc',
4040
'newest',
4141
'roamer-efficiency',
42+
'rolling-resistance',
4243
);
4344

4445
/**

includes/class-rtg-database.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ private static function build_filter_sort_clause( $sort ) {
659659
'weight-asc' => 'weight_lb ASC',
660660
'newest' => 'created_at DESC',
661661
'roamer-efficiency' => 'roamer_efficiency DESC',
662+
// Lower Crr is better; tires without an estimate (0) sort last.
663+
'rolling-resistance' => '(roamer_crr = 0) ASC, roamer_crr ASC',
662664
);
663665
return $sort_map[ $sort ] ?? 'efficiency_score DESC';
664666
}

includes/class-rtg-frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private function enqueue_assets( $shortcode_atts = array() ) {
153153
$prefilters['category'] = sanitize_text_field( $shortcode_atts['category'] );
154154
}
155155
if ( ! empty( $shortcode_atts['sort'] ) ) {
156-
$allowed_sorts = array( 'efficiencyGrade', 'price-asc', 'price-desc', 'warranty-desc', 'weight-asc', 'newest', 'rating-desc', 'most-reviewed' );
156+
$allowed_sorts = array( 'efficiencyGrade', 'rolling-resistance', 'price-asc', 'price-desc', 'warranty-desc', 'weight-asc', 'newest', 'rating-desc', 'most-reviewed' );
157157
$sort_val = sanitize_text_field( $shortcode_atts['sort'] );
158158
if ( in_array( $sort_val, $allowed_sorts, true ) ) {
159159
$prefilters['sort'] = $sort_val;

rivian-tire-guide.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Plugin Name: Rivian Tire Guide
44
* Description: Interactive tire guide for Rivian vehicles with filtering, comparison, and ratings.
5-
* Version: 1.50.0
5+
* Version: 1.50.1
66
* Author: RivianTrackr
77
* Text Domain: rivian-tire-guide
88
* Requires at least: 5.8
@@ -14,7 +14,7 @@
1414
exit;
1515
}
1616

17-
define( 'RTG_VERSION', '1.50.0' );
17+
define( 'RTG_VERSION', '1.50.1' );
1818
define( 'RTG_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
1919
define( 'RTG_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
2020
define( 'RTG_PLUGIN_FILE', __FILE__ );

0 commit comments

Comments
 (0)