@@ -1,4 +1,4 @@ | |||||
<%include file="/support/header.mako" args="title='Error - TIF Calculator'"/> | |||||
<%include file="/support/header.mako" args="title='Error – TIF Calculator'"/> | |||||
<h2>Error!</h2> | <h2>Error!</h2> | ||||
<p>An error occurred. If it hasn't been reported (<a href="https://github.com/earwig/template-influence-factor/issues">try to check</a>), please <a href="https://github.com/earwig/template-influence-factor/issues/new">file an issue</a> or <a href="mailto:wikipedia.earwig@gmail.com">email me</a>. Include the following information:</p> | <p>An error occurred. If it hasn't been reported (<a href="https://github.com/earwig/template-influence-factor/issues">try to check</a>), please <a href="https://github.com/earwig/template-influence-factor/issues/new">file an issue</a> or <a href="mailto:wikipedia.earwig@gmail.com">email me</a>. Include the following information:</p> | ||||
<div id="error"> | <div id="error"> | ||||
@@ -24,7 +24,7 @@ | |||||
<table> | <table> | ||||
<tr> | <tr> | ||||
<td>TIF</td> | <td>TIF</td> | ||||
<td>${"{0:.2f}".format(result["tif"])}</td> | |||||
<td>${"{0:.2f}".format(result["tif"])} views/min</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td>Transclusions</td> | <td>Transclusions</td> | ||||
@@ -64,13 +64,14 @@ def _get_avg_views(site, article): | |||||
if "items" not in res: | if "items" not in res: | ||||
return None | 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): | def _update_views(cursor, site, title, ns): | ||||
cache_life = "7 DAY" | cache_life = "7 DAY" | ||||
query1 = """SELECT tl_from, page_title | query1 = """SELECT tl_from, page_title | ||||
FROM {0}.templatelinks | 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 | LEFT JOIN cache ON tl_from = cache_id | ||||
WHERE tl_title = ? AND tl_namespace = ? AND tl_from_namespace = 0 AND | WHERE tl_title = ? AND tl_namespace = ? AND tl_from_namespace = 0 AND | ||||
(cache_id IS NULL OR cache_time < DATE_SUB(NOW(), INTERVAL {1}))""" | (cache_id IS NULL OR cache_time < DATE_SUB(NOW(), INTERVAL {1}))""" | ||||