Files
vyndr/src/config/statFilters.js
T

36 lines
1.4 KiB
JavaScript

'use strict';
/**
* Stat-filter categories per sport (Session 23).
*
* The stat filter is VYNDR's navigation system — users browse by what
* they care about ("show me everyone on a 3-point streak"), not by sport
* alone. These categories drive:
* - the StatFilterPills UI
* - the `?stat=` param on /api/streaks and /api/hotlist
*
* Category strings here MUST match the `category` field the streaks &
* hot-list engines emit, or the filter silently returns nothing. Mirror
* any change in `web/src/config/statFilters.ts`.
*/
const STAT_FILTERS = Object.freeze({
nba: ['all', 'points', 'rebounds', 'assists', 'threes', 'blocks', 'steals', 'pra'],
wnba: ['all', 'points', 'rebounds', 'assists', 'threes', 'blocks', 'steals'],
mlb: ['all', 'hits', 'home_runs', 'stolen_bases', 'rbis', 'strikeouts', 'total_bases', 'on_base'],
soccer: ['all', 'goals', 'assists', 'shots', 'tackles', 'saves'],
nfl: ['all', 'passing_yards', 'rushing_yards', 'receiving_yards', 'touchdowns', 'interceptions'],
});
function getStatFilters(sport) {
return STAT_FILTERS[String(sport || '').toLowerCase()] || ['all'];
}
/** Is `stat` a valid category for `sport`? 'all' is always valid. */
function isValidStat(sport, stat) {
if (!stat || stat === 'all') return true;
return getStatFilters(sport).includes(String(stat).toLowerCase());
}
module.exports = { STAT_FILTERS, getStatFilters, isValidStat };