Commits

Ferran Pegueroles  committed 186df6e

Add last executed info on index page

  • Participants
  • Parent commits b273941

Comments (0)

Files changed (2)

File templates/index.html

         <div class="alert-message block-message">
             <h5>{{ name }}</h5>
             <p>{{ task.__doc__|default('',true)|safe() }}</p>
+            <p><small>
+            {% if task.last_run %}
+                Last executed on {{ task.last_run }}
+            {% else %}
+                Task never executed
+            {% endif %}
+            </small></p>
             <div class="alert-actions">
                 <a class="btn task" href="{{ url_for('run') }}" rel="{{ name }}">Run deployment »</a>
             </div>

File webfabric.py

     g.db.close()
 
 
+def get_task_last_run(task):
+    select = """SELECT start FROM logs WHERE taskname=?
+    ORDER BY start DESC LIMIT 1"""
+    cur = g.db.execute(select, (task,))
+    row = cur.fetchone()
+    if row:
+        return row[0]
+    else:
+        return None
+
+
 @app.route("/")
 def index():
 
     docstring, tasks, default = main.load_fabfile(app.config['FABFILE'])
+
+    # get last execution time for tasks
+    for name, task in tasks.iteritems():
+        tasks[name].last_run = get_task_last_run(name)
+
+
     data = {
        'docstring': docstring,
        'tasks': tasks,