[Mpuls-commits] r259 - in waska/trunk: . waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 12 16:52:09 CET 2009


Author: torsten
Date: 2009-02-12 16:52:08 +0100 (Thu, 12 Feb 2009)
New Revision: 259

Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/lib/adelexml.py
   waska/trunk/waskaweb/lib/evaluation_new.py
Log:
Modified adele evaluation


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2009-02-11 19:02:40 UTC (rev 258)
+++ waska/trunk/ChangeLog.txt	2009-02-12 15:52:08 UTC (rev 259)
@@ -1,3 +1,12 @@
+2009-02-12	Torsten Irlaender  <torsten.irlaender at intevation.de>
+
+	Modified adele evaluation. 
+
+	* waskaweb/lib/adelexml.py,
+	  waskaweb/lib/evaluation_new.py: The ammount of cm-cases should be
+	  larger no as another cirtieria was added. Further the checks if a
+	  case is relevant for the evaluation period was enhanced 
+
 2009-02-05	Torsten Irlaender  <torsten.irlaender at intevation.de>
 	
 	Removed some evalautions as they are not relevant yet.

Modified: waska/trunk/waskaweb/lib/adelexml.py
===================================================================
--- waska/trunk/waskaweb/lib/adelexml.py	2009-02-11 19:02:40 UTC (rev 258)
+++ waska/trunk/waskaweb/lib/adelexml.py	2009-02-12 15:52:08 UTC (rev 259)
@@ -18,15 +18,65 @@
 EXP_TYPE   = re.compile('^([0-9]{1,2},?)+$')
 EXP_DATE   = re.compile('^\d{4}-\d{2}-\d{2}$')
 
-SQL_TABLE      = "master_tbl_view"
+SQL_TABLE      = "master_tbl_eval_total_view"
 SQL_GENDER_FIELD   = 'geschlecht'
 SQL_FKZ = """(TRUE)"""
-SQL_CM = """(kompetenzfeststellung = '1' or (kompetenzfeststellung = '-1' and
-phase in (2,3,4,5)))"""
+SQL_CM = """
+-- Nur CM-Faelle
+(kompetenzfeststellung = '1' 
+    or (kompetenzfeststellung = '-1' and phase in (2,3,4,5))
+) 
+or (bereich_berufliche_qualifizierung = '1' or bereich_berufsvorbereitung = '1'
+   or bildender_bereich = '1' or bereich_lebensbewaeltigung = '1' or
+   sonstiger_foerderbedarf = '1')"""
 
+# begin,ende,begin,begin,begin,ende,begin,ende,ende,begin,begin,begin,ende,begin,ende
+SQL_TIME = """
+(
+    --
+    -- Ausfiltern der Faelle, die definitiv nicht in Frage kommen
+    --
+    -- Beendigung vor BZ
+    not (coalesce(beendigung_5, now()) < '%s'::date)
+    -- Begin nach BZ
+    and not (coalesce(datum_feststellung, '1970-01-01'::date) > '%s'::date)
+    -- Begin vor BZ aber auch letzte Aktualisierung vor BZ
+    and not (coalesce(datum_feststellung, '1970-01-01'::date) < '%s'::date
+             and s.zugriff < '%s'::date)
+    -- Kein Begin und Erstgespraech nicht im BZ
+    and not (datum_feststellung IS NULL and (coalesce(erstgespraech,
+    '1970-01-01'::date) < '%s'::date or coalesce(erstgespraech,
+    '1970-01-01'::date) > '%s'::date)
+    )
+)
+and (
+    --
+    -- Nur Faelle die den Kriterien entsprechen 
+    --
+    -- Beendigung im BZ
+    (coalesce(beendigung_5, now()) >= '%s'::date 
+    and coalesce(beendigung_5, now()) <= '%s'::date) 
+    or (
+      -- Beendigung nach BZ
+      coalesce(beendigung_5, now()) >= '%s'::date 
+      and (
+    -- Begin vor BZ und Aktualisierung nach Begin BZ
+    (datum_feststellung < '%s'::date and s.zugriff >=
+    '%s'::date) 
+    or 
+    -- Begin im BZ
+    (datum_feststellung >= '%s'::date 
+    and datum_feststellung <= '%s'::date)
+      )
+      -- Erstgespraech innerhalb des BZ
+      or ( erstgespraech >= '%s'::date and erstgespraech <=
+      '%s'::date)
+    )
+)
+"""
+# Alte Abfrage
+#SQL_TIME = """(datum_feststellung <= '%s'::date and coalesce(beendigung_5, now()) >= '%s'::date)"""
 
-SQL_TIME = """(datum_feststellung <= '%s'::date and coalesce(beendigung_5, now()) >= '%s'::date)"""
-
 SQL_EINTRITTE_GESAMT           = """('%s'::date <= datum_feststellung and '%s'::date >= datum_feststellung)"""
 SQL_AUSTRITTE_GESAMT           = """('%s'::date <= beendigung_5 and '%s'::date >= beendigung_5)"""
 SQL_AUSTRITTE_VORZEITIG        = """(art_beendigung = 2 and '%s'::date <= beendigung_5 and '%s'::date >= beendigung_5)"""
@@ -154,7 +204,11 @@
         try:
             #out.append(self.sql_fkz % self.agency)
             out.append(self.sql_cm)
-            out.append(self.sql_time_frame % (self.end_date, self.start_date))
+            # begin,ende,begin,begin,begin,ende
+            begin = self.start_date
+            ende  = self.end_date
+            out.append(self.sql_time_frame % (begin,ende,begin,begin,begin,ende,begin,ende,ende,begin,begin,begin,ende,begin,ende))
+
         except StandardError, err:
             print err
         try:
@@ -163,7 +217,6 @@
             out.append(where)
             pass # Maybe the where clause does not have any time restrictions
         where = " and ".join(out)
-        print where
         sql = Evaluation._build_sql(self, where)
         return sql
 

Modified: waska/trunk/waskaweb/lib/evaluation_new.py
===================================================================
--- waska/trunk/waskaweb/lib/evaluation_new.py	2009-02-11 19:02:40 UTC (rev 258)
+++ waska/trunk/waskaweb/lib/evaluation_new.py	2009-02-12 15:52:08 UTC (rev 259)
@@ -33,9 +33,9 @@
 XML_BODY   = """<TEILNEHMER><PJTN_TTYP_ID>%s</PJTN_TTYP_ID><PJTN_MANN>%s</PJTN_MANN><PJTN_FRAU>%s</PJTN_FRAU><PJTN_GESAMT>%s</PJTN_GESAMT></TEILNEHMER>"""
 XML_FOOTER = """</PROJEKT_TEILNEHMER>"""
 
-SQL_TABLE      = "master_tbl_view"
+SQL_TABLE      = "master_tbl_eval_total_view"
 SQL_GENDER_FIELD   = 'geschlecht'
-SQL_BASE_QUERY = """SELECT %s, count(id) FROM %s WHERE %s GROUP BY %s"""
+SQL_BASE_QUERY = """SELECT %s, count(m.id) FROM %s m JOIN ka_status_tbl_view s ON m.id = s.master_id WHERE %s GROUP BY %s"""
 
 SQL_TOTAL      = "TRUE"
 EVALUATION     = {'1': SQL_TOTAL}
@@ -172,7 +172,6 @@
         out.append('<%inherit file="/main.mako"/>')
         out.append('<%!  import waskaweb.lib.filters as F %>')
         out.append(self.transform(xml))
-        print 'generated mako: %s' % "\n".join(out)
         try:
             return render_with_mako(eval, out)
         except StandardError, err:
@@ -259,7 +258,6 @@
     def perform(self):
         self._set_header()
         for eval_id in self.evaluations:
-            print 'performing evaluation for %s' % eval_id
             try:
                 sql = self._build_sql(self.evaluation_mapping.get(eval_id))
                 evaluation = EvaluationQuery(eval_id, sql)
@@ -303,7 +301,7 @@
                     self.women = int(r[1])
         except StandardError, err:
             #log.error(err)
-            #log.error("Error with query %s" % self.sql)
+            print "Error with query %s" % self.sql
             pass
         except:
             #log.error("Error with query %s" % self.sql)



More information about the Mpuls-commits mailing list