# HG changeset patch # User Sascha L. Teichmann # Date 1218528899 -7200 # Node ID e347f0de5e224a95ff5b8ca53de4209e7c9c261a # Parent 2ccae1e872e91d7c4e19c90ef1e223df8a2067c9 Applied Stephan Holl's week-option.patch diff -r 2ccae1e872e9 -r e347f0de5e22 ChangeLog --- 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 + + * 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 * getan: !!! Work in progress !!! Project Trees diff -r 2ccae1e872e9 -r e347f0de5e22 contrib/zeiterfassung --- 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 ]: getan database, default: time.db [--project=|-p ] : Key of output project, default: all [--encoding=|-e encoding] : encoding of output, default: none + [--week=]|-w ] : 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()