front page updates as it runs
This commit is contained in:
parent
51480fafcc
commit
5247350524
@ -5,13 +5,44 @@ oyster
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var REFRESH = 5000;
|
||||||
|
var MAX_ROWS = 100;
|
||||||
|
setInterval(function() {
|
||||||
|
jQuery.getJSON('/?json', function(data) {
|
||||||
|
jQuery('#tracking_val').text(data.tracking);
|
||||||
|
jQuery('#need_update_val').text(data.need_update);
|
||||||
|
var latest_link = jQuery('tr td a')[0]['href'].split('/tracked/')[1];
|
||||||
|
var new_rows = ''
|
||||||
|
for(var i=0; i < data.logs.length; ++i) {
|
||||||
|
if(latest_link == data.logs[i].url) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(data.logs[i].error) {
|
||||||
|
new_rows += '<tr class="error">'
|
||||||
|
} else {
|
||||||
|
new_rows += '<tr>';
|
||||||
|
}
|
||||||
|
new_rows += '<td>' + data.logs[i].action + '</td>\n';
|
||||||
|
new_rows += '<td><a href="{{request.script_root}}/tracked/' + data.logs[i].url + '">' + data.logs[i].url + '</td>';
|
||||||
|
new_rows += '<td>' + data.logs[i].timestamp + '</td>';
|
||||||
|
if(data.logs[i].error) {
|
||||||
|
new_rows += '<td>' + data.logs[i].error + '</td></tr>';
|
||||||
|
} else {
|
||||||
|
new_rows += '<td></td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jQuery('tr:first').after(new_rows);
|
||||||
|
jQuery('tr:gt(' + MAX_ROWS + ')').empty()
|
||||||
|
});
|
||||||
|
}, REFRESH);
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="span-4">
|
<div class="span-4">
|
||||||
<h2>Stats</h2>
|
<h2>Stats</h2>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Queue Size</dt><dd>{{queue_size}}</dd>
|
<dt>Tracking</dt><dd id="tracking_val">{{tracking}}</dd>
|
||||||
<dt>Tracking</dt><dd>{{tracking}}</dd>
|
<dt>Need Update</dt><dd id="need_update_val">{{need_update}}</dd>
|
||||||
<dt>Need Update</dt><dd>{{need_update}}</dd>
|
|
||||||
<dt>Mongo Host</dt><dd>{{mongo_host}}</dd>
|
<dt>Mongo Host</dt><dd>{{mongo_host}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<tr{% if log.error %} class="error" {% endif %}>
|
<tr{% if log.error %} class="error" {% endif %}>
|
||||||
<td>{{log.action}}</td>
|
<td>{{log.action}}</td>
|
||||||
<td><a href="{{request.script_root}}/tracked/{{log.url}}">{{log.url}}</td>
|
<td><a href="{{request.script_root}}/tracked/{{log.url}}">{{log.url}}</td>
|
||||||
|
@ -19,6 +19,7 @@ class JSONEncoder(json.JSONEncoder):
|
|||||||
else:
|
else:
|
||||||
return super(JSONEncoder, self).default(obj)
|
return super(JSONEncoder, self).default(obj)
|
||||||
|
|
||||||
|
|
||||||
def _path_fixer(url):
|
def _path_fixer(url):
|
||||||
""" this exists because werkzeug seems to collapse // into / sometimes
|
""" this exists because werkzeug seems to collapse // into / sometimes
|
||||||
certainly a hack, but given that werkzeug seems to only do the mangling
|
certainly a hack, but given that werkzeug seems to only do the mangling
|
||||||
@ -26,6 +27,7 @@ def _path_fixer(url):
|
|||||||
"""
|
"""
|
||||||
return re.sub(r'(http|https|ftp):/([^/])', r'\1://\2', url)
|
return re.sub(r'(http|https|ftp):/([^/])', r'\1://\2', url)
|
||||||
|
|
||||||
|
|
||||||
def api_wrapper(template=None):
|
def api_wrapper(template=None):
|
||||||
def wrapper(func):
|
def wrapper(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
@ -50,7 +52,7 @@ def index():
|
|||||||
status = {
|
status = {
|
||||||
'tracking': client.db.tracked.count(),
|
'tracking': client.db.tracked.count(),
|
||||||
'need_update': client.get_update_queue_size(),
|
'need_update': client.get_update_queue_size(),
|
||||||
'logs': client.db.logs.find().sort('$natural', -1).limit(20),
|
'logs': list(client.db.logs.find().sort('$natural', -1).limit(20)),
|
||||||
'mongo_host': settings.MONGO_HOST,
|
'mongo_host': settings.MONGO_HOST,
|
||||||
}
|
}
|
||||||
return status
|
return status
|
||||||
|
Loading…
Reference in New Issue
Block a user