Commits

Andy Mikhailenko committed 5088121

added reporting.methodology: for now it is a set of simple hard-coded rules (or, well, a single rule).

Comments (0)

Files changed (3)

timetra/reporting/methodology.py

+# -*- coding: utf-8 -*-
+#
+#    Timetra is a time tracking application and library.
+#    Copyright © 2010-2012  Andrey Mikhaylenko
+#
+#    This file is part of Timetra.
+#
+#    Timetra is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Lesser General Public License as published
+#    by the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    Timetra is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Lesser General Public License for more details.
+#
+#    You should have received a copy of the GNU Lesser General Public License
+#    along with Timer.  If not, see <http://gnu.org/licenses/>.
+#
+"""
+Methodology
+===========
+
+:copyright: Andy Mikhaylenko, 2012
+:license: LGPL3
+
+"""
+from timetra import storage
+
+
+def check_planning_after_sleep(facts):
+    remainder = []
+    after_sleep = None
+    for f in reversed(facts):
+        if f.activity == 'sleeping':
+            after_sleep = reversed(remainder)
+            break
+        remainder.append(f)
+    message = u'Please plan the day'
+    if after_sleep:
+        if any(True for x in after_sleep if x.activity == 'sorting-tasks'):
+            message = u'You seem to have planned the day, OK'
+    return message
+
+
+def analyse_day():
+    """ Returns a generator or messages that give some hints re given day.
+    """
+    facts = storage.get_facts_for_day()
+    rules = [check_planning_after_sleep]
+    for rule in rules:
+        yield rule(facts)

timetra/web/__init__.py

 
 from timetra import storage
 from timetra.curses import CATEGORY_COLOURS
-from timetra.reporting import drift, prediction
+from timetra.reporting import drift, methodology, prediction
 from timetra.utils import format_delta
 
 
     return render_template('dashboard.html', facts=facts, stats=stats,
                            appraise_category=appraise_category,
                            sleep_drift=sleep_drift, next_sleep=next_sleep,
-                           format_delta=format_delta, approx_time=approx_time)
+                           format_delta=format_delta, approx_time=approx_time,
+                           methodology=methodology)
 
 
 @blueprint.route('reports/drift/')

timetra/web/templates/dashboard.html

                 {% endif %}
                 (См. <a href="{{ url_for('timetra.report_drift') }}">режим сна</a> и <a href="{{ url_for('timetra.report_predictions') }}">список предсказаний</a>)
             </p>
+
+            {% for message in methodology.analyse_day() %}
+                <p>{{ message }}</p>
+            {% endfor %}
         </div>
         <h2>Categories</h2>
         <dl class="dl-horizontal">