improve archive list

This commit is contained in:
codl 2017-08-07 15:53:34 +02:00
parent deda43fd8a
commit 40a5acbdf3
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
2 changed files with 12 additions and 1 deletions

View File

@ -144,3 +144,10 @@ class TwitterArchive(db.Model, TimestampMixin):
chunks = db.Column(db.Integer) chunks = db.Column(db.Integer)
chunks_successful = db.Column(db.Integer, server_default='0', nullable=False) chunks_successful = db.Column(db.Integer, server_default='0', nullable=False)
chunks_failed = db.Column(db.Integer, server_default='0', nullable=False) chunks_failed = db.Column(db.Integer, server_default='0', nullable=False)
def status():
if self.chunks == None or self.chunks_failed > 0:
return 'failed'
if self.chunks_successful == self.chunks:
return 'successful'
return 'pending'

View File

@ -81,8 +81,12 @@
<h3 id="recent_archives">Recent archives</h3> <h3 id="recent_archives">Recent archives</h3>
<ul> <ul>
{% for archive in g.viewer.account.twitter_archives %} {% for archive in g.viewer.account.twitter_archives %}
<li>{{archive.created_at.strftime('%Y-%m-%d %H:%M')}}<br> <li class="tweet_archive" data-status="{{archive.status()}}">{{archive.created_at.strftime('%Y-%m-%d %H:%M')}}<br>
{% if archive.chunks == None %}
{{archive.chunks_successful}}/{{archive.chunks}} months imported, {{archive.chunks_failed}} failed</li> {{archive.chunks_successful}}/{{archive.chunks}} months imported, {{archive.chunks_failed}} failed</li>
{% else %}
Archive could not be opened
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}