Ahora los días empiezan a las 00:00
authorDaniel Garcia Moreno <dgarcia@emergya.es>
Wed, 24 Sep 2008 14:21:01 +0000 (16:21 +0200)
committerDaniel Garcia Moreno <dgarcia@emergya.es>
Wed, 24 Sep 2008 14:21:01 +0000 (16:21 +0200)
Ya se puede mostrar agrupado, última semana y todo

show.py
ttt.py

diff --git a/show.py b/show.py
index 3c620a2..c025da0 100755 (executable)
--- a/show.py
+++ b/show.py
@@ -9,6 +9,14 @@ import ttt
 if __name__ == '__main__':
     args = sys.argv[1:]
     if '-g' in args:
+        # show grouped by project
         ttt.show_today_grouped()
+    elif '-s' in args:
+        ttt.show_week()
+    elif '-gs' in args:
+        # show grouped by project
+        ttt.show_week_grouped()
+    elif '-a' in args:
+        ttt.show_all()
     else:
         ttt.show_today()
diff --git a/ttt.py b/ttt.py
index e437837..4a23316 100755 (executable)
--- a/ttt.py
+++ b/ttt.py
@@ -52,6 +52,7 @@ def track(task, project='', ticket=0):
 def show(trackers):
     grouped = {}
     total = 0
+    prev = ''
     for i in trackers:
         diff = i.end - i.start
         total += diff.seconds
@@ -64,21 +65,24 @@ def show(trackers):
         else:
             grouped[key] = diff.seconds
         
-        to_show = '%-20s | %-20s | #%-6d | %s | %s'
-        print to_show % (i.project, i.task, i.ticket, i.start.ctime(),
-                                                            time_passed)
+        to_show = '%s | %-20s | %-40s | #%-6d | %s'
+        to_show = to_show % (i.start.ctime(), i.project, i.task, i.ticket, time_passed)
+        if prev != to_show[0:3]:
+            prev = to_show[0:3]
+            print ''
+        print to_show
     
     print ''
     for k,v in grouped.items():
         task, project = k
         time_passed = parse_time(v)
-        print 'Tiempo para "%s": %s' % (task, time_passed)
+        print 'Tiempo para %-40s %s' % ('"'+task+'":', time_passed)
 
-    print '\nTotal para hoy: %s' % parse_time(total)
+    print '\nTotal: %s' % parse_time(total)
 
-def show_today(delta=1):
-    # TODO yesterday no es real, hay que mirar desde las 00 del mismo dia
-    yesterday = datetime.datetime.now() - datetime.timedelta(delta)
+def show_today(delta=0):
+    today = datetime.datetime.now() - datetime.timedelta(delta)
+    yesterday = datetime.datetime(today.year, today.month, today.day)
     today_trackers = Tracker.select(Tracker.q.start > yesterday)
     show(today_trackers)
 
@@ -90,11 +94,19 @@ def show_project(project):
 
     print 'Tiempo para "%s": %s' % (project, parse_time(sum))
 
-def show_sem():
-    show_today(7)
+def show_all():
+    all = Tracker.select()
+    show(all)
 
-def show_today_grouped(delta=1):
-    yesterday = datetime.datetime.now() - datetime.timedelta(delta)
+def show_week():
+    show_today(6)
+
+def show_week_grouped():
+    show_today_grouped(6)
+
+def show_today_grouped(delta=0):
+    today = datetime.datetime.now() - datetime.timedelta(delta)
+    yesterday = datetime.datetime(today.year, today.month, today.day)
     today_trackers = Tracker.select(Tracker.q.start > yesterday)
     show_grouped(today_trackers)
 
@@ -113,7 +125,7 @@ def show_grouped(trackers):
         p = '"' + k + '":'
         print 'Tiempo para %-20s %s' % (p, parse_time(v))
 
-    print '\nTotal para hoy: %s' % parse_time(total)
+    print '\nTotal: %s' % parse_time(total)
 
 if __name__ == '__main__':
     task, project, ticket = '','',0