diff contrib/wochenbericht @ 32:4de86feae6ac

Added a parameter 'year' to the 'wochenbericht' script that filters out the week of a specific year only.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 31 Aug 2010 19:27:36 +0200
parents e7245c2127e5
children
line wrap: on
line diff
--- a/contrib/wochenbericht	Tue Aug 31 19:25:23 2010 +0200
+++ b/contrib/wochenbericht	Tue Aug 31 19:27:36 2010 +0200
@@ -14,8 +14,9 @@
 #
 usage() {
     cat <<EOF
-usage: ./wochenbericht [<week of year>] [<getan database file>] 
+usage: ./wochenbericht [<week of year>] [<year>] [<getan database file>] 
     <week of year>        defaults to current week
+    <year>                defaults to current year
     <getan database file> defaults to time.db
 EOF
     exit 1
@@ -34,7 +35,13 @@
     WEEK=$1
 fi
 
-TIME_DB=${2:-time.db}
+if [[ "$2" -eq "" ]]; then
+    YEAR=`date +'%Y'`
+else
+    YEAR=$2
+fi
+
+TIME_DB=${3:-time.db}
 
 if [ ! -f ${TIME_DB} ]; then
     echo "error: Database file ${TIME_DB} does not exist."
@@ -48,8 +55,10 @@
         project_id,
         sum(strftime('%s', stop_time) - strftime('%s', start_time)) AS total
     FROM entries
-    WHERE strftime('%W', start_time) = '${WEEK}' OR 
-          strftime('%W', stop_time)  = '${WEEK}' 
+    WHERE (strftime('%W', start_time) = '${WEEK}' AND
+        strftime('%Y', start_time) = '${YEAR}') OR 
+        (strftime('%W', stop_time)  = '${WEEK}' AND
+        strftime('%Y', stop_time) = '${YEAR}')
     GROUP BY project_id
 ) ON id = project_id
 WHERE active;
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)