From 380aee7e75778248802c26e0b8ec9021265d871b Mon Sep 17 00:00:00 2001 From: Akshita-2307 Date: Thu, 4 Jun 2026 13:06:20 +0530 Subject: [PATCH] refactor: replace magic number with named constant in intensity calculation Replaces the hardcoded value 10 in the demand zone intensity calculation with a named constant MAX_ORDERS_FOR_FULL_INTENSITY for improved readability and maintainability. Closes #535 --- src/intelligence.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/intelligence.js b/src/intelligence.js index a34c2ee..85f69ea 100644 --- a/src/intelligence.js +++ b/src/intelligence.js @@ -20,6 +20,8 @@ * @property {string} reason - Why this zone is predicted to be high demand. */ +const MAX_ORDERS_FOR_FULL_INTENSITY = 10; + export const Intelligence = { /** * Predicts future waste volume based on historical data. @@ -66,7 +68,7 @@ export const Intelligence = { getHighDemandZones: (providers, allOrders) => { return providers.map(p => { const providerOrders = allOrders.filter(o => o.providerId === p.id); - const intensity = Math.min(providerOrders.length / 10, 1); + const intensity = Math.min(providerOrders.length / MAX_ORDERS_FOR_FULL_INTENSITY, 1); return { lat: p.lat + (Math.random() - 0.5) * 0.01, // Slight offset for visual "area" lng: p.lng + (Math.random() - 0.5) * 0.01,