Skip to content

Commit

Permalink
[#3588] Adding fix to logs timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan committed Jun 27, 2017
1 parent 83b7c2d commit 8f21097
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ckanext/datapusher/logic/action.py
Expand Up @@ -4,6 +4,7 @@
import json
import urlparse
import datetime
import time

from dateutil.parser import parse as parse_date

Expand Down Expand Up @@ -287,6 +288,11 @@ def datapusher_status(context, data_dict):
'Authorization': job_key})
r.raise_for_status()
job_detail = r.json()
for log in job_detail['logs']:
if 'timestamp' in log:
date = datetime.datetime.strptime(log['timestamp'], "%Y-%m-%dT%H:%M:%S.%f")
date = datetime.datetime.utcfromtimestamp(time.mktime(date.timetuple()))
log['timestamp'] = date
except (requests.exceptions.ConnectionError,
requests.exceptions.HTTPError):
job_detail = {'error': 'cannot connect to datapusher'}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datapusher/templates/datapusher/resource_data.html
Expand Up @@ -72,7 +72,7 @@ <h3>{{ _('Upload Log') }}</h3>
{{ line | urlize }}<br>
{% endfor %}
<span class="date" title="{{ h.render_datetime(item.timestamp, with_hours=True) }}">
{{ h.time_ago_from_timestamp(status.last_updated) }}
{{ h.time_ago_from_timestamp(item.timestamp) }}
<a href="#" data-target="popover" data-content="<dl>{% for key, value in item.iteritems() %}<dt>{{ key }}</dt><dd>{{ value }}</dd>{% endfor %}</dl>" data-html="true">{{ _('Details') }}</a>
</span>
</p>
Expand Down

0 comments on commit 8f21097

Please sign in to comment.