[Mpuls-commits] r114 - in waska/trunk: . waskaweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Sep 2 13:11:41 CEST 2008
Author: torsten
Date: 2008-09-02 13:11:41 +0200 (Tue, 02 Sep 2008)
New Revision: 114
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/waskaweb/lib/evaluation.py
Log:
Adjusted evaluation to work with new phases model. TODO: Consolidate phase ids if modell changes again
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2008-09-02 10:21:11 UTC (rev 113)
+++ waska/trunk/ChangeLog.txt 2008-09-02 11:11:41 UTC (rev 114)
@@ -1,3 +1,12 @@
+2008-09-02 Torsten Irlaender <torsten.irlaender at intevation.de>
+
+ Adjusted evaluation to work with new phases model. TODO: Consolidate
+ phase ids if modell changes again
+
+ * waskaweb/lib/evaluation.py: Adjusted evaluations. adjusted new
+ grouping of age evaluations. adjusted evalaution on migration
+ background.
+
2008-09-02 Sascha L. Teichmann <sascha.teichmann at intevation.de>
* waskaweb/lib/exportselection.py: New. out-factorized selection of case parts.
Modified: waska/trunk/waskaweb/lib/evaluation.py
===================================================================
--- waska/trunk/waskaweb/lib/evaluation.py 2008-09-02 10:21:11 UTC (rev 113)
+++ waska/trunk/waskaweb/lib/evaluation.py 2008-09-02 11:11:41 UTC (rev 114)
@@ -52,19 +52,29 @@
try:
conn = db.getConnection()
c1 = conn.cursor()
+
+ # All cases (including invalid)
+ c1.execute("""SELECT count(id) from master_tbl_eval_total_view m""")
+ self.allcases = c1.fetchone()[0]
+
+ # All cases (valid)
+ c1.execute("""SELECT count(id) from master_tbl_eval_total_view m WHERE %s""" % self.where_clause(self.compressed_ids))
+ self.total_valid = c1.fetchone()[0]
+
+ # All "beratungsfälle" (valid)
+ c1.execute("""SELECT count(id) from master_tbl_eval_total_view m WHERE phase IN (1,2) AND %s""" % self.where_clause(self.compressed_ids))
+ self.total_valid_beratung = c1.fetchone()[0]
+
+ # All "cm-fälle" (valid)
c1.execute("""SELECT count(id) from master_tbl_eval_incm_view m WHERE %s""" % self.where_clause(self.compressed_ids))
self.total_valid_cm = c1.fetchone()[0]
- # Num of cases which are finished (aborted or regular ending)
- c1.execute("""SELECT count(id) from master_tbl_eval_incm_view m where art_beendigung <> -1 AND %s""" % self.where_clause(self.compressed_ids))
+
+ # All finished "cm-fälle" (valid)
+ c1.execute("""SELECT count(id) from master_tbl_eval_incm_view m where phase IN (3,4,5) AND %s""" % self.where_clause(self.compressed_ids))
self.total_valid_cmfinished = c1.fetchone()[0]
+
c1.close(); c1 = None
- c1 = conn.cursor()
- c1.execute("""SELECT count(id) from master_tbl_eval_total_view m WHERE %s""" % self.where_clause(self.compressed_ids))
- self.total_valid = c1.fetchone()[0]
- c1.close(); c1 = None
- c1 = conn.cursor()
- c1.execute("""SELECT count(id) from master_tbl_eval_total_view m""")
- self.allcases = c1.fetchone()[0]
+
finally:
db.recycleConnection(conn, c1)
except:
@@ -83,6 +93,7 @@
return "(%s)" % where_ids(ids, field)
def _build_eval_where_clause(self, fkz):
+ '''Only for evaluation server. Builds where-clause based on fkz'''
fkz = "fkz IN (%s)" % (", ".join("'%s'" % a.fkz for a in session.get('agencybundle', AgencyBundle()).getAgencys()))
dummy_search = AgencySearch()
form_defaults = session.get('CASE_OVERVIEW_SEARCHOPTIONS') or {}
@@ -95,11 +106,11 @@
cm = 'TRUE' #default
cm_state = options.get('cm', "all")
if cm_state == 'before':
- cm = 'm.id not in (SELECT id from master_tbl_eval_incm_view)'
+ cm = 'm.id not in (SELECT id from master_tbl_eval_total_view where phase in (0,1))'
if cm_state == 'active':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE art_beendigung = -1)'
+ cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase = 2)'
if cm_state == 'finished':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE art_beendigung <> -1)'
+ cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase in (3,4,5))'
time_interval = "TRUE"
interval_start_field = options.get('interval_start_field', "erstgespraech")
@@ -160,18 +171,18 @@
self.cm_percent = "%s" % h.formatNumber(
float(self.total_valid_cm)/float(divisor)*100)
self.ber_percent = "%s" % h.formatNumber(
- float(self.total_valid-self.total_valid_cm)/float(divisor)*100)
+ float(self.total_valid_beratung)/float(divisor)*100)
except:
print >> sys.stderr, "No results for eval 1"
self.percent = 0;
- return (self.total_valid, (self.total_valid-self.total_valid_cm), self.ber_percent, self.total_valid_cm, self.cm_percent)
+ return (self.total_valid, self.total_valid_beratung, self.ber_percent, self.total_valid_cm, self.cm_percent)
def doExport(self, f):
self.perform()
f.write(u"#%s (Auswertung: alle Jugendliche)\r\n" % _('cm_eval_summary_header_1'))
f.write(u"Jugendliche;Anzahl;Prozent\r\n")
f.write(u"Gesamt Jugendliche;%s;100%%\r\n" % (self.total_valid))
- f.write(u"Davon Beratungskunden;%s;%s%%\r\n" % (self.total_valid-self.total_valid_cm, self.ber_percent))
+ f.write(u"Davon Beratungskunden;%s;%s%%\r\n" % (self.total_valid_beratung, self.ber_percent))
f.write(u"Davon in das CM übernommen;%s;%s%%\r\n" %(self.total_valid_cm, self.cm_percent))
class Evaluation_2(Evaluation):
@@ -243,14 +254,21 @@
conn = db.getConnection()
c1 = conn.cursor()
r = [[0,0],[0,0],[0,0]]
- sql = """select coalesce(muttersprache, -1) from master_tbl_eval_incm_view m WHERE %s""" % self.where_clause(self.compressed_ids)
+ sql = """select coalesce(muttersprache, -1), coalesce(geburtsland, -1), coalesce(vater, -1), coalesce(mutter, -1) from master_tbl_eval_incm_view m WHERE %s""" % self.where_clause(self.compressed_ids)
c1.execute(sql)
for case in c1.fetchall():
muttersprache = case[0]
- if muttersprache == 18:
+ geburtsland = case[1]
+ vater = case[2]
+ mutter = case[3]
+
+ # Kein Migrationshintergrund
+ if (muttersprache == 18) and (geburtsland == 29) and (vater == 1) and (mutter == 1):
r[1][0] += 1
- elif muttersprache not in (18, -1):
+ # Migrationshintergrund
+ elif (muttersprache not in (18, -1)) or (geburtsland not in (29, -1)) or (vater not in (0, -1)) or (mutter not in (0, -1)):
r[0][0] += 1
+ # Keine Angabe möglich
else:
r[2][0] += 1
@@ -378,7 +396,7 @@
sql = """select v.id, count(m.vermittlung), v.value from master_tbl_eval_incm_view m
join vermittlung_tbl v
on v.id = m.vermittlung
- where art_beendigung <> -1
+ where m.phase in (3,4,5)
AND %s
group by v.id, v.value
order by v.id asc""" % self.where_clause(self.compressed_ids, 'm.id')
@@ -429,7 +447,7 @@
sql ="""select r.id, count(m.veraenderungen_rechtskreis), r.value from master_tbl_eval_incm_view m
right join veraenderungen_rechtskreis_tbl r
on m.veraenderungen_rechtskreis = r.id
- where art_beendigung <> -1
+ where m.phase IN (3,4,5)
AND %s
group by r.id, r.value having r.id is not null
order by r.id asc""" % self.where_clause(self.compressed_ids, 'm.id')
@@ -472,11 +490,11 @@
def perform(self):
result = [["<14",0,0],
- ["14-15",0,0],
- ["16-17",0,0],
+ ["14",0,0],
+ ["15-17",0,0],
["18-20",0,0],
- ["21-23",0,0],
- ["24-26",0,0],
+ ["21-24",0,0],
+ ["25-26",0,0],
[">26",0,0],
["Keine Angabe",0,0]]
try:
@@ -498,11 +516,11 @@
result[0][1] += 1
result[0][2] = "%s" % h.formatNumber(
float(result[0][1])/float(divisor)*100)
- elif 14 <= r[0] <= 15:
+ elif 14 == r[0]:
result[1][1] += 1
result[1][2] = "%s" % h.formatNumber(
float(result[1][1])/float(divisor)*100)
- elif 16 <= r[0] <= 17:
+ elif 15 <= r[0] <= 17:
result[2][1] += 1
result[2][2] = "%s" % h.formatNumber(
float(result[2][1])/float(divisor)*100)
@@ -510,11 +528,11 @@
result[3][1] += 1
result[3][2] = "%s" % h.formatNumber(
float(result[3][1])/float(divisor)*100)
- elif 21 <= r[0] <= 23:
+ elif 21 <= r[0] <= 24:
result[4][1] += 1
result[4][2] = "%s" % h.formatNumber(
float(result[4][1])/float(divisor)*100)
- elif 24 <= r[0] <= 26:
+ elif 25 <= r[0] <= 26:
result[5][1] += 1
result[5][2] = "%s" % h.formatNumber(
float(result[5][1])/float(divisor)*100)
@@ -621,7 +639,7 @@
LEFT JOIN art_beendigung_tbl a on a.id = m.art_beendigung AND a.id = 1
LEFT JOIN art_beendigung_tbl r on r.id = m.art_beendigung AND r.id IN (0,2)
LEFT JOIN art_beendigung_tbl k on k.id = m.art_beendigung AND k.id = -1
- WHERE %s
+ WHERE m.phase IN (3,4,5) AND %s
GROUP BY zeitraum_fallmanagement
ORDER BY zeitraum_fallmanagement
""" % self.where_clause(self.compressed_ids, 'm.id')
@@ -820,7 +838,7 @@
FROM ka_logbuch_tbl_view l
JOIN master_tbl_eval_total_view m
ON m.id = l.master_id
- WHERE m.id NOT IN (SELECT id from master_tbl_eval_incm_view)
+ WHERE m.phase == 1
AND m.kompetenzfeststellung = 0
AND %s
AND l.dauer IS NOT NULL
@@ -927,7 +945,7 @@
FROM ka_logbuch_tbl_view l
JOIN master_tbl_eval_incm_view m
ON m.id = l.master_id
- WHERE m.art_beendigung <> -1
+ WHERE m.phase IN (3,4,5)
AND %s
AND l.dauer IS NOT NULL
GROUP BY l.art
More information about the Mpuls-commits
mailing list