| Index: sitescripts/stats/bin/pagegenerator.py |
| =================================================================== |
| --- a/sitescripts/stats/bin/pagegenerator.py |
| +++ b/sitescripts/stats/bin/pagegenerator.py |
| @@ -23,20 +23,21 @@ from sitescripts.stats.countrycodes impo |
| @cached(float("inf")) |
| def get_template_environment(): |
| return get_custom_template_environment({ |
| "monthname": lambda value: date(int(value[0:4]), int(value[4:]), 1).strftime("%b %Y"), |
| "weekday": lambda value: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"][int(value)], |
| "countryname": lambda value: countrycodes.get(value, "Unknown"), |
| "sortfield": lambda value, field: (field["sort"] if "sort" in field else default_sort)(value), |
| - "maxhits": lambda items: max(itertools.chain((value["hits"] for key, value in items), [1])), |
| - "maxbandwidth": lambda items: max(itertools.chain((value["bandwidth"] for key, value in items), [1])), |
| - "sumhits": lambda items: max(sum(value["hits"] for key, value in items), 1), |
| - "sumbandwidth": lambda items: max(sum(value["bandwidth"] for key, value in items), 1), |
| + "maxhits": lambda items: max(value["hits"] for key, value in items), |
| + "maxbandwidth": lambda items: max(value["bandwidth"] for key, value in items), |
| + "sumhits": lambda items: sum(value["hits"] for key, value in items), |
| + "sumbandwidth": lambda items: sum(value["bandwidth"] for key, value in items), |
| + "percentage": lambda value, total: float(value) / total * 100 if total != 0 else 0, |
| "isspecial": lambda name, field: field["isspecial"](name) if "isspecial" in field else False, |
| "defaultcount": get_default_count, |
| }) |
| @cached(float("inf")) |
| def get_main_page_template(): |
| return get_template_environment().get_template(get_config().get("stats", "mainPageTemplate")) |