Overview
src/services/rulesFilter.ts implements the first layer of the hybrid filter pipeline. It is a pure function — no I/O, no side effects, and no external calls. All state required for deduplication is injected by the caller (dealsService.ts).
Exported function
applyHardFilters
Deal objects returned by CheapShark against a set of hard thresholds and a deduplication set.
Raw deals fetched from the CheapShark API.
Threshold values for each filter criterion. See the interface section below.
Set of
steamAppID strings already notified within the deduplication window. Built by dealsService using getNotifiedIds() and injected here to keep this module side-effect-free.RulesFilterOptions interface
Minimum required savings percentage. Deals with
savings < minDiscountPercent are rejected.Minimum Metacritic score for the quality gate. Used in the OR condition together with
minSteamRatingPercent.Minimum Steam user rating percentage for the quality gate. A deal passes if
steamRatingPercent >= minSteamRatingPercent even if it has no Metacritic score.Maximum sale price in USD. Deals with
salePrice > maxPriceUSD are rejected regardless of discount or quality.Filter logic
Each deal is evaluated against two categories of criteria: Rejection criteria — any one of these causes the deal to be dropped:savings < minDiscountPercentsalePrice > maxPriceUSDsteamAppIDis present innotifiedIds(deduplication)
metacriticScore >= minMetacriticScore(only evaluated when a non-zero score is present)steamRatingPercent >= minSteamRatingPercent