changeset 13:e347f0de5e22

Applied Stephan Holl's week-option.patch
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 12 Aug 2008 10:14:59 +0200
parents 2ccae1e872e9
children 83f99008a3f9
files ChangeLog contrib/zeiterfassung
diffstat 2 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Aug 11 01:12:47 2008 +0200
+++ b/ChangeLog	Tue Aug 12 10:14:59 2008 +0200
@@ -1,3 +1,8 @@
+2008-08-12	Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* contrib/zeiterfassung: Applied Stephan Holl's week-option.patch which
+	  adds the possibility to give an optional week of year.
+
 2008-08-11	Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* getan: !!! Work in progress !!! Project Trees
--- a/contrib/zeiterfassung	Mon Aug 11 01:12:47 2008 +0200
+++ b/contrib/zeiterfassung	Tue Aug 12 10:14:59 2008 +0200
@@ -33,6 +33,7 @@
     [--database=|-d <database>]: getan database,        default: time.db
     [--project=|-p <key>]      : Key of output project, default: all
     [--encoding=|-e encoding]  : encoding of output,    default: none
+    [--week=]|-w <week>]       : week of year
     [--list|-l]                : list all projects
     [--help|-h]                : This text'''
 
@@ -48,6 +49,27 @@
 SELECT id, key, description FROM projects
 '''
 
+WEEK_ENTRIES = '''
+SELECT 
+    date(start_time) AS t, 
+    sum(strftime('%s', stop_time) - strftime('%s', start_time)), 
+    'no description' AS description
+FROM entries 
+WHERE 
+    project_id = :project_id AND 
+    (description IS NULL or length(description) = 0) -- trim() function is missing
+    AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week)
+GROUP BY round(julianday(start_time))
+UNION
+SELECT date(start_time) AS s, strftime('%s', stop_time) - strftime('%s', start_time), description
+FROM entries 
+WHERE 
+    project_id = :project_id AND 
+    description IS NOT NULL AND length(description) > 0
+    AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week)
+ORDER BY t
+'''
+
 ENTRIES = '''
 SELECT 
     date(start_time), 
@@ -101,11 +123,12 @@
     list_projects = False
     project       = None
     encoding      = None
+    week          = None
 
     opts, args = getopt.getopt(
         sys.argv[1:],
-        'd:u:p:e:hl',
-        ['database=', 'user=', 'project=', 'encoding=', 'help', 'list'])
+        'd:u:p:e:hl:w:',
+        ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week='])
 
     for opt, val in opts:
         if opt in ("--database", "-d"):
@@ -120,6 +143,8 @@
             usage()
         elif opt in ("--list", "-l"):
             list_projects = True
+        elif opt in ("--week", "-w"):
+            week = val
 
     if not user:
         user = os.getenv("USER")
@@ -159,7 +184,10 @@
 
                 for project_id, project, proj_desc in project_ids:
                     print "# project: %s (%s)" % (project, proj_desc)
-                    cur.execute(ENTRIES, {'project_id': project_id})
+                    if not week is None:
+                        cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week})
+                    else:
+                        cur.execute(ENTRIES, {'project_id': project_id})
                     total = 0
                     while True:
                         row = cur.fetchone()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)