From 9ce9421bcf8ff6fd96fc293a8b65dc57fcc5c76d Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 9 Feb 2016 23:36:13 -0600 Subject: [PATCH] Tweak math; use ndash. --- templates/error.mako | 2 +- templates/index.mako | 2 +- tif/calc.py | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/templates/error.mako b/templates/error.mako index a2df007..0c44dc1 100644 --- a/templates/error.mako +++ b/templates/error.mako @@ -1,4 +1,4 @@ -<%include file="/support/header.mako" args="title='Error - TIF Calculator'"/> +<%include file="/support/header.mako" args="title='Error – TIF Calculator'"/>

Error!

An error occurred. If it hasn't been reported (try to check), please file an issue or email me. Include the following information:

diff --git a/templates/index.mako b/templates/index.mako index 1ac294c..a518376 100644 --- a/templates/index.mako +++ b/templates/index.mako @@ -24,7 +24,7 @@ - + diff --git a/tif/calc.py b/tif/calc.py index 38ce625..a0bf058 100644 --- a/tif/calc.py +++ b/tif/calc.py @@ -64,13 +64,14 @@ def _get_avg_views(site, article): if "items" not in res: return None - return sum(item["views"] for item in res["items"]) / float(days) + total_views = sum(item["views"] for item in res["items"]) + return total_views / (float(days) * 24 * 60) def _update_views(cursor, site, title, ns): cache_life = "7 DAY" query1 = """SELECT tl_from, page_title FROM {0}.templatelinks - LEFT JOIN page ON tl_from = page_id + LEFT JOIN {0}.page ON tl_from = page_id LEFT JOIN cache ON tl_from = cache_id WHERE tl_title = ? AND tl_namespace = ? AND tl_from_namespace = 0 AND (cache_id IS NULL OR cache_time < DATE_SUB(NOW(), INTERVAL {1}))"""
TIF${"{0:.2f}".format(result["tif"])}${"{0:.2f}".format(result["tif"])} views/min
Transclusions