# HG changeset patch # User Teemu Piippo # Date 1525459426 -10800 # Node ID 0726eb9bc9d186762717bc66ff157def2edb16ef # Parent c07a77c8a0707a63f772548cfc2d3ca327e755d8 night routes can be rarer diff -r c07a77c8a070 -r 0726eb9bc9d1 service.py --- a/service.py Fri May 04 21:32:16 2018 +0300 +++ b/service.py Fri May 04 21:43:46 2018 +0300 @@ -369,18 +369,20 @@ break return length or len(route) from math import inf + def route_limit(route): + return (route in night_routes) and 20 else 6 def route_key(route): from math import log return ( route in night_routes, - counts_per_variant.get(route, 0) < 20, + counts_per_variant.get(route, 0) < route_limit(route), route_len(route), str(route) ) def routes_key(routes): return min(route_key(route) for route in routes) result = [] - rare_variants = {variant['name'] for variant in all_variants if variant['count'] < 20} + rare_variants = {variant['name'] for variant in all_variants if variant['count'] < route_limit(route)} rare_variant_groups = set() for regions, routes in sorted( routes_per_destination.items(),