Commits

Andy Mikhailenko committed f94bab7

web: quick fix for negative timedelta in next sleep prediction.

Comments (0)

Files changed (5)

 
 
 app = create_app(TestConfig)
-app.run()
+app.run(port=6060)

timetra/reporting/prediction.py

     now = datetime.now()
     if now < est_start:
         eta = est_start - now
+        eta_is_negative = False
     else:
-        eta = -(now - est_start)
+        eta = now - est_start
+        eta_is_negative = True
     return {'start': est_start, 'end': est_end, 'duration': est_duration,
-            'eta': eta}
+            'eta': eta, 'eta_is_negative': eta_is_negative}

timetra/web/templates/_helpers.html

 {% macro render_tags(tags) %}
     {% for tag in tags %}
         {% if not tag in ['auto-logged', 'auto-timed'] %}
-            <a href="{{ url_for('timetra.search', q=tag) }}" class="label">{{ tag }}</a>
+            <a href="{{ url_for('timetra.search', q=tag) }}" class="label"><i class="icon-tag icon-white"></i>&nbsp;{{ tag }}</a>
         {% endif %}
     {% endfor %}
 {% endmacro %}

timetra/web/templates/dashboard.html

             <h2>Next sleep</h2>
             <dl class="dl-horizontal">
                 <dt>ETA</dt>
-                <dd title="{{ next_sleep.start }}"><strong>{{ next_sleep.eta }}</strong></dd>
+                <dd title="{{ next_sleep.start }}"><strong>{% if next_sleep.eta_is_negative %}-{% endif %}{{ next_sleep.eta }}</strong></dd>
                 <dt>Duration</dt>
                 <dd>{{ next_sleep.duration }}</dd>
                 <dt>Wake Up</dt>

timetra/web/templates/predictions.html

                     <tr>
                         <td>{{ prediction.activity }}</td>
                         <td>{{ prediction.eta }}</td>
+                        <td>{% if prediction.eta_is_negative %}-{% endif %}{{ prediction.eta }}</td>
                         <td>
                             {% if prediction.start %}
                                 {{ prediction.start.strftime('%Y-%m-%d %H:%M') }}