[Mpuls-commits] r826 - in wasko/branches/2.0: . waskaweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jan 22 12:05:59 CET 2010
Author: torsten
Date: 2010-01-22 12:05:58 +0100 (Fri, 22 Jan 2010)
New Revision: 826
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/waskaweb/lib/evaluation.py
Log:
* waskaweb/lib/evaluation.py (Evaluation_X): Deleted unused evaluation
classes which where not used anymore. Left over classes which are referenced
from logbook for logbook evaluation.
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-01-22 10:53:37 UTC (rev 825)
+++ wasko/branches/2.0/ChangeLog 2010-01-22 11:05:58 UTC (rev 826)
@@ -1,9 +1,12 @@
-2010-01-22 Torsten Irländer <torsten.irlaender at intevation.com
+2010-01-22 Torsten Irländer <torsten.irlaender at intevation.de>
* waskaweb/lib/evaluation.py (Evaluation._build_eval_where_clause):
Deleted is not called from anywhere.
+ * waskaweb/lib/evaluation.py (Evaluation_X): Deleted unused evaluation
+ classes which where not used anymore. Left over classes which are
+ referenced from logbook for logbook evaluation.
-2010-01-22 Torsten Irländer <torsten.irlaender at intevation.com
+2010-01-22 Torsten Irländer <torsten.irlaender at intevation.de>
* waskaweb/controllers/case_overview.py: Removed import. Was not used
* waskaweb/lib/search.py (build_inconsistency_type_querys): Removed.
Modified: wasko/branches/2.0/waskaweb/lib/evaluation.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/evaluation.py 2010-01-22 10:53:37 UTC (rev 825)
+++ wasko/branches/2.0/waskaweb/lib/evaluation.py 2010-01-22 11:05:58 UTC (rev 826)
@@ -114,688 +114,6 @@
pass
-class Evaluation_1(Evaluation):
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
- self.percent = 0
-
- def perform(self):
- try:
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid
- self.cm_percent = "%s" % h.formatNumber(
- float(self.total_valid_cm)/float(divisor)*100)
- self.ber_percent = "%s" % h.formatNumber(
- float(self.total_valid_beratung)/float(divisor)*100)
- except:
- traceback.print_exc(file=sys.stderr)
- print >> sys.stderr, "No results for eval 1"
- self.percent = 0;
- 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_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):
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- self.m = [0,0]
- self.w = [0,0]
- self.i = [0,0]
- self.u = [0,0]
-
- conn, cur = None, None
- try:
- try:
- conn = db.getConnection()
- cur = conn.cursor()
- sql = """SELECT count(geschlecht), coalesce(geschlecht, -1)
- FROM master_tbl_eval_incm_view m
- WHERE %s
- GROUP BY geschlecht""" % self.where_clause(self.compressed_ids)
- cur.execute(sql)
- result = cur.fetchall()
- for g in result:
- if g[1] == 1:
- self.m[0] += g[0]
- elif g[1] == 0:
- self.w[0] += g[0]
- elif g[1] == 2:
- self.i[0] += g[0]
- else:
- self.u[0] += g[0]
- self.total_valid = self.m[0]+self.w[0]+self.i[0]+self.u[0]
- if self.total_valid > 0:
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid_cm
- self.m[1] = "%s" % h.formatNumber(
- float(self.m[0])/float(divisor)*100)
- self.w[1] = "%s" % h.formatNumber(
- float(self.w[0])/float(divisor)*100)
- self.i[1] = "%s" % h.formatNumber(
- float(self.i[0])/float(divisor)*100)
- self.u[1] = "%s" % h.formatNumber(
- float(self.u[0])/float(divisor)*100)
- finally:
- db.recycleConnection(conn, cur)
- except:
- print >> sys.stderr, "No result for eval 2"
- return (self.total_valid,self.m,self.w,self.i,self.u)
-
- def doExport(self, f):
- self.perform()
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_summary_header_4'))
- f.write(u"Geschlecht;Anzahl;Prozent\r\n")
- f.write(u"Männlich;%s;%s%%\r\n" % (self.m[0], self.m[1]))
- f.write(u"Weiblich;%s;%s%%\r\n" %(self.w[0], self.w[1]))
- f.write(u"Intersexuell;%s;%s%%\r\n" %(self.i[0], self.i[1]))
- f.write(u"Keine Angabe;%s;%s%%\r\n" %(self.u[0], self.u[1]))
-
-class Evaluation_3(Evaluation):
- """Migrationshintergrund"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- r = [[0,0],[0,0],[0,0]]
- sql = """select coalesce(muttersprache, -1), coalesce(staatsangehoerigkeit, -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]
- staatsangehoerigkeit = case[1]
- vater = case[2]
- mutter = case[3]
-
- # Kein Migrationshintergrund
- if (muttersprache == 18) and (staatsangehoerigkeit == 29) and (vater == 1) and (mutter == 1):
- r[1][0] += 1
- # Migrationshintergrund
- elif (muttersprache not in (18, -1)) or (staatsangehoerigkeit not in (29, -1)) or (vater not in (1, -1)) or (mutter not in (1, -1)):
- r[0][0] += 1
- # Keine Angabe möglich
- else:
- r[2][0] += 1
-
- if self.total_valid_cm == 0: divisor = 1
- else: divisor = self.total_valid_cm
- r[0][1] = "%s" % h.formatNumber(float(r[0][0])/float(divisor)*100)
- r[1][1] = "%s" % h.formatNumber(float(r[1][0])/float(divisor)*100)
- r[2][1] = "%s" % h.formatNumber(float(r[2][0])/float(divisor)*100)
- finally:
- db.recycleConnection(conn, c1)
- except StandardError, err:
- print >> sys.stderr, "no result eval 3: %s" % str(err)
- return [[0,0],[0,0],[0,0]]
- return r
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_summary_header_5'))
- f.write(u"Kategorie;Anzahl;Prozent\r\n")
- f.write(u"Migrationshintergrund;%s;%s%%\r\n" % (p[0][0], p[0][1]))
- f.write(u"Kein Migrationshintergrund;%s;%s%%\r\n" % (p[1][0], p[1][1]))
- f.write(u"Keine Angabe;%s;%s%%\r\n" % (p[2][0], p[2][1]))
-
-class Evaluation_4(Evaluation):
- """ Zugang der der Jugendichen zu KA"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- result = {}
- sql = """select t.id, count(m.zugang_kompetenzagentur), t.value
- from master_tbl_eval_total_view m
- right join zugang_kompetenzagentur_tbl t
- on m.zugang_kompetenzagentur = t.id
- WHERE %s
- group by t.id, t.value having t.id is not null
- order by t.id asc""" % self.where_clause(self.compressed_ids, "m.id")
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(sql)
-
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid
-
- for r in c1.fetchall():
- result[r[0]] = []
- try:
- result[r[0]].append(
- u'%s' % unicode(r[2], 'utf-8')) # name
- result[r[0]].append(
- r[1]) # how many?
- result[r[0]].append(
- "%s" % h.formatNumber(
- float(r[1])/float(divisor)*100))
- except StandardError, err:
- print >> sys.stderr, str(err)
- finally:
- db.recycleConnection(conn, c1)
- except:
- print >> sys.stderr, "No results for eval 4"
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: alle Jugendliche)\r\n" % _('cm_eval_header_access_youngster_to_agency'))
- f.write(u"Zugang;Anzahl;Prozent\r\n")
- for v in p.itervalues():
- f.write("%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
-class Evaluation_5(Evaluation):
- """Rechtskreis der Jugendlichen beim Zugang zur KA"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- result = {}
- sql = """select r.id, count(m.rechtlicher_kontext), r.value from master_tbl_eval_total_view m
- right join rechtlicher_kontext_tbl r
- on m.rechtlicher_kontext = r.id
- WHERE %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')
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(sql)
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid
- for r in c1.fetchall():
- result[r[0]] = []
- try:
- result[r[0]].append(
- u'%s' % unicode(r[2], 'utf-8')) # name
- result[r[0]].append(r[1]) # how many?
- result[r[0]].append(
- "%s" % h.formatNumber(
- float(r[1])/float(divisor)*100))
- except StandardError, err:
- print >> sys.stderr, str(err)
- finally:
- db.recycleConnection(conn, c1)
- except StandardError, err:
- print >> sys.stderr, str('no results for eval 5: %s' % err)
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: alle Jugendliche)\r\n" % _('cm_eval_head_law_access_agency'))
- f.write(u"Rechtskreis;Anzahl;Prozent\r\n")
- for v in p.itervalues():
- f.write(u"%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
-class Evaluation_6(Evaluation):
- """Vermittlung"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- result = {}
- 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 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')
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(sql)
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid_cmfinished
- for r in c1.fetchall():
- result[r[0]] = []
- try:
- result[r[0]].append(
- u'%s' % unicode(r[2], "utf-8")) # name
- result[r[0]].append(
- r[1]) # how many?
- try:
- result[r[0]].append(
- "%s" % h.formatNumber(
- float(r[1])/float(divisor)*100))
- except:
- result[r[0]].append("%s" % h.formatNumber(0.0))
- except StandardError, err:
- print >> sys.stderr, str(
- 'Error on assigning values: %s' % err)
- finally:
- db.recycleConnection(conn, c1)
- except StandardError, err:
- print >> sys.stderr, str('No result eval 6: %s' % err)
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: abgeschlossene CM-Fälle)\r\n" % _('cm_eval_head_where_to_place_youngster'))
- f.write("Vermittlung;Anzahl;Prozent\r\n")
- for v in p.itervalues():
- f.write(u"%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
-class Evaluation_7(Evaluation):
- """Rechtskreis nach Vermittlung"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- result = {}
- 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 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')
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(sql)
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid_cmfinished
- for r in c1.fetchall():
- result[r[0]] = []
- try:
- result[r[0]].append(
- u'%s' % unicode(r[2], 'utf-8')) # name
- result[r[0]].append(r[1]) # how many?
- result[r[0]].append(
- "%s" % h.formatNumber(
- float(r[1])/float(divisor)*100))
- except StandardError, err:
- print >> sys.stderr, str(err)
- finally:
- db.recycleConnection(conn, c1)
- except StandardError, err:
- print >> sys.stderr, str('no results for eval 7: %s' % err)
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: abgeschlossene CM-Fälle)\r\n" % _('cm_eval_header_law_changed_after_place'))
- f.write(u"Rechtskreis;Anzahl;Prozent\r\n")
- for v in p.itervalues():
- f.write(u"%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
-class Evaluation_8(Evaluation):
- """Altersvreteilung"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- result = [["<14",0,0],
- ["14",0,0],
- ["15-17",0,0],
- ["18-20",0,0],
- ["21-24",0,0],
- ["25-26",0,0],
- [">26",0,0],
- ["Keine Angabe",0,0]]
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(
- """select date_part('year',
- (age(geburtsdatum::timestamp)-age(coalesce(erstgespraech,
- st.zugriff)::timestamp))) from master_tbl_eval_incm_view m
- JOIN ka_status_tbl_view st ON m.id = st.master_id WHERE
- %s""" %
- self.where_clause(self.compressed_ids, 'm.id'))
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid_cm
- for r in c1.fetchall():
- if 0 < r[0] < 14:
- result[0][1] += 1
- result[0][2] = "%s" % h.formatNumber(
- float(result[0][1])/float(divisor)*100)
- elif 14 == r[0]:
- result[1][1] += 1
- result[1][2] = "%s" % h.formatNumber(
- float(result[1][1])/float(divisor)*100)
- elif 15 <= r[0] <= 17:
- result[2][1] += 1
- result[2][2] = "%s" % h.formatNumber(
- float(result[2][1])/float(divisor)*100)
- elif 18 <= r[0] <= 20:
- result[3][1] += 1
- result[3][2] = "%s" % h.formatNumber(
- float(result[3][1])/float(divisor)*100)
- elif 21 <= r[0] <= 24:
- result[4][1] += 1
- result[4][2] = "%s" % h.formatNumber(
- float(result[4][1])/float(divisor)*100)
- elif 25 <= r[0] <= 26:
- result[5][1] += 1
- result[5][2] = "%s" % h.formatNumber(
- float(result[5][1])/float(divisor)*100)
- elif 26 < r[0]:
- result[6][1] += 1
- result[6][2] = "%s" % h.formatNumber(
- float(result[6][1])/float(divisor)*100)
- else:
- # Age == 0 -> no birthdate was entered.
- result[7][1] += 1
- result[7][2] = "%s" % h.formatNumber(
- float(result[7][1])/float(divisor)*100)
- finally:
- db.recycleConnection(conn, c1)
- except StandardError, err:
- print >> sys.stderr, str('No results for eval 8: %s' % err)
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_header_on_age'))
- f.write("Altersgruppe;Anzahl;Prozent\r\n")
- for v in p:
- f.write("%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
-class Evaluation_9(Evaluation):
- """Verteilung Foerderangebote"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- result = [[u"berufliche Qualifizierung",0,0],
- [u"Berufsvorbereitung", 0,0],
- [u"allgemein bildenden Bereich", 0,0],
- [u"%s" % unicode("Lebensbewältigung", "utf-8"), 0,0],
- [u"%s" % unicode("Sonstige", "utf-8"), 0,0]
- ]
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute("""select count(id) from master_tbl_eval_incm_view m WHERE bereich_berufliche_qualifizierung = 1 AND %s""" % self.where_clause(self.compressed_ids))
- result[0][1] = c1.fetchone()[0]
- c1.close(); c1 = None
- c1 = conn.cursor()
- c1.execute("""select count(id) from master_tbl_eval_incm_view m WHERE bereich_berufsvorbereitung = 1 AND %s""" % self.where_clause(self.compressed_ids))
- result[1][1] = c1.fetchone()[0]
- c1.close(); c1 = None
- c1 = conn.cursor()
- c1.execute("""select count(id) from master_tbl_eval_incm_view m WHERE bildender_bereich = 1 AND %s""" % self.where_clause(self.compressed_ids))
- result[2][1] = c1.fetchone()[0]
- c1.close(); c1 = None
- c1 = conn.cursor()
- c1.execute("""select count(id) from master_tbl_eval_incm_view m WHERE bereich_lebensbewaeltigung = 1 AND %s""" % self.where_clause(self.compressed_ids))
- result[3][1] = c1.fetchone()[0]
- c1.close(); c1 = None
- c1 = conn.cursor()
- c1.execute("""select count(id) from master_tbl_eval_incm_view m WHERE sonstiger_foerderbedarf = 1 AND %s""" % self.where_clause(self.compressed_ids))
- result[4][1] = c1.fetchone()[0]
- c1.close(); c1 = None
- total = 0
- # Gesamtanzahl der Maßnahmen berechnen
- if self.total_valid_cm == 0: divisor = 1
- else: divisor = self.total_valid_cm
- total = divisor
- #for r in result: total += r[1]
- result[0][2] = "%s" % h.formatNumber(
- float(result[0][1])/float(total)*100)
- result[1][2] = "%s" % h.formatNumber(
- float(result[1][1])/float(total)*100)
- result[2][2] = "%s" % h.formatNumber(
- float(result[2][1])/float(total)*100)
- result[3][2] = "%s" % h.formatNumber(
- float(result[3][1])/float(total)*100)
- result[4][2] = "%s" % h.formatNumber(
- float(result[4][1])/float(total)*100)
- finally:
- db.recycleConnection(conn, c1)
- except StandardError, err:
- print >> sys.stderr, str('No results for eval 9: %s' % err)
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_summary_header_6'))
- f.write(u"Angebot;Anzahl;Prozent\r\n")
- for v in p:
- f.write(u"%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
-class Evaluation_10(Evaluation):
- """Verweildauer im CM"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- sql = """
- SELECT
- zeitraum_fallmanagement,
- count(a.id) as abbruch,
- count(r.id) as regulaer,
- count(v.id) as vorzeitig,
- count(k.id) as keine
- FROM master_tbl_eval_incm_view m
- 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 = 0
- LEFT JOIN art_beendigung_tbl v on v.id = m.art_beendigung AND v.id = 2
- LEFT JOIN art_beendigung_tbl k on k.id = m.art_beendigung AND k.id = -1
- 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')
- if self.total_valid_cm == 0: divisor = 1
- else: divisor = self.total_valid_cm
- try:
- conn, c1, query_result = None, None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(sql)
- query_result = c1.fetchall()
- finally:
- db.recycleConnection(conn, c1)
- except:
- traceback.print_exc(file=sys.stderr)
-
- # query_result: [monat, anz_abr, anz_reg, anz_vor, anz_ka]
- result = []
- # row: [monat, abgeschl_num, abschloss_proz, abbruch_num, abbruch_proz, vorz_num, vorz_proz, ka_num, ka_proz]
- for r in query_result:
- row = ['Keine Angabe',0,0,0,0,0,0,0,0]
- # Monat
- if r[0]:
- row[0] = r[0]
- # Regulaer
- row[1] = r[2]
- row[2] = "%s" % h.formatNumber(float(r[2])/float(divisor)*100)
- # Abbruch
- row[3] = r[1]
- row[4] = "%s" % h.formatNumber(float(r[1])/float(divisor)*100)
- #Vorzeitig
- row[5] = r[3]
- row[6] = "%s" % h.formatNumber(float(r[3])/float(divisor)*100)
- # KA
- row[7] = r[4]
- row[8] = "%s" % h.formatNumber(float(r[4])/float(divisor)*100)
- if r[2] > 0 or r[1] > 0 or r[3] > 0:
- result.append(row)
- return result
-
-
- def doExport(self, f):
- p = self.perform()
-
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_length_cm'))
- f.write("Monat;Anzahl Abgeschlossen;Prozent Abgeschlossen, Anzahl Abgebrochen, Prozent Abgebrochen\r\n")
- for v in p:
- f.write(u"%s;%s;%s%%;%s;%s%%\r\n" % (v[0], v[1], v[2], v[3], v[4]))
-
-class Evaluation_13(Evaluation):
- """Durchschnitt Verweildauer im CM"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
-
- def perform(self):
- eval_10 = Evaluation_10(self.compressed_ids).perform()
- # row: [monat, abgeschl_num, abschloss_proz, abbruch_num, abbruch_proz, vorz_num, vorz_proz, ka_num, ka_proz]
-
- months_abr = 0
- anz_abr = 0
- months_abg = 0
- anz_abg = 0
- months_vz = 0
- anz_vz = 0
- avg_month_abr = "-/-"
- avg_month_abg = "-/-"
- avg_month_vz = "-/-"
-
- for r in eval_10:
- try:
- months_abr += int(r[0]) * int(r[3])
- anz_abr += int(r[3])
- months_abg += int(r[0]) * int(r[1])
- anz_abg += int(r[1])
- months_vz += int(r[0]) * int(r[5])
- anz_vz += int(r[5])
- except:
- pass
- if anz_abr > 0:
- avg_month_abr = "%s" % h.formatNumber(float(months_abr) / float(anz_abr))
- if anz_abg > 0:
- avg_month_abg = "%s" % h.formatNumber(float(months_abg) / float(anz_abg))
- if anz_vz > 0:
- avg_month_vz = "%s" % h.formatNumber(float(months_vz) / float(anz_vz))
-
- result = [avg_month_abg, anz_abg, avg_month_vz, anz_vz, avg_month_abr, anz_abr]
- return result
-
- def doExport(self, f):
- p = self.perform()
-
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_avg_length_cm'))
- f.write("Durchschnitt Monat Abgeschlossen;Durchschnitt Monat vorzeitig Abgeschlossen;Durchschnitt Monat Abgebrochen\r\n")
- for v in [p]:
- f.write(u"%s;%s;%s\r\n" % (v[0], v[2], v[4]))
-
-class Evaluation_11(Evaluation):
- """Schulabschluss beim Zugang (alle)"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
- self.view = 'master_tbl_eval_total_view'
- def perform(self):
- result = {}
- sql = """select t.id, count(m.schulabschluss_1), t.value
- from %s m
- right join schulabschluss_1_tbl t
- on m.schulabschluss_1 = t.id
- WHERE %s
- group by t.id, t.value having t.id is not null
- order by t.id asc""" % (self.view, self.where_clause(self.compressed_ids, "m.id"))
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(sql)
-
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid
-
- for r in c1.fetchall():
- result[r[0]] = []
- try:
- result[r[0]].append(
- u'%s' % unicode(r[2], 'utf-8')) # name
- result[r[0]].append(
- r[1]) # how many?
- result[r[0]].append(
- "%s" % h.formatNumber(
- float(r[1])/float(divisor)*100))
- except StandardError, err:
- print >> sys.stderr, str(err)
- finally:
- db.recycleConnection(conn, c1)
- except:
- print c1.query
- print >> sys.stderr, "No results for eval 11"
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: alle Jugendliche)\r\n" % _('cm_eval_header_graduation'))
- f.write(u"Schulabschluss;Anzahl;Prozent\r\n")
- for v in p.itervalues():
- f.write("%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
-class Evaluation_12(Evaluation):
- """Arbeitsituation beim Zugang"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- def perform(self):
- result = {}
- sql = """select t.id, count(m.schulabschluss_1), t.value
- from master_tbl_eval_total_view m
- right join bei_eintritt_ist_der_jugendliche_tbl t
- on m.bei_eintritt_ist_der_jugendliche = t.id
- WHERE %s
- group by t.id, t.value having t.id is not null
- order by t.id asc""" % self.where_clause(self.compressed_ids, "m.id")
- try:
- conn, c1 = None, None
- try:
- conn = db.getConnection()
- c1 = conn.cursor()
- c1.execute(sql)
-
- if self.total_valid == 0: divisor = 1
- else: divisor = self.total_valid
-
- for r in c1.fetchall():
- result[r[0]] = []
- try:
- result[r[0]].append(
- u'%s' % unicode(r[2], 'utf-8')) # name
- result[r[0]].append(
- r[1]) # how many?
- result[r[0]].append(
- "%s" % h.formatNumber(
- float(r[1])/float(divisor)*100))
- except StandardError, err:
- print >> sys.stderr, str(err)
- finally:
- db.recycleConnection(conn, c1)
- except:
- print c1.query
- print >> sys.stderr, "No results for eval 11"
- return result
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s (Auswertung: alle Jugendliche)\r\n" % _('cm_eval_header_work'))
- f.write(u"Status;Anzahl;Prozent\r\n")
- for v in p.itervalues():
- f.write("%s;%s;%s%%\r\n" % (v[0], v[1], v[2]))
-
class Evaluation_14(Evaluation):
"""Zeitaufwände aus dem Logbuch abgeschlossene Beratungsfälle"""
def __init__(self, compressed_ids):
@@ -922,46 +240,6 @@
v = p.get(key)
f.write("%s;%s;%s\r\n" % (KIND2TEXT.get(key, SUMKIND2TEXT.get(key)), v[0], v[1]))
-class Evaluation_15(Evaluation_14):
- """Zeitaufwände aus dem Logbuch (abgeschlossene CM-Fälle)"""
- def __init__(self, compressed_ids):
- Evaluation_14.__init__(self, compressed_ids)
- self.export_label = _('cm_eval_header_effort2')
- self.export_eval_what = u"abgeschlossene CM-Fälle"
- self.sql = """SELECT sum(l.dauer) AS dauer, count(l.dauer) AS anzahl, l.art, m.id
- FROM ka_logbuch_tbl_view l
- JOIN master_tbl_eval_incm_view m
- ON m.id = l.master_id
- WHERE m.phase IN (3,4,5)
- AND %s
- AND l.dauer IS NOT NULL
- GROUP BY l.art, m.id
- ORDER BY l.art
- """ % self.where_clause(self.compressed_ids, "l.master_id")
-
-class Evaluation_16(Evaluation_14):
- """Durchschnitt Zeitaufwand abgeschlossene Beratung"""
- def __init__(self, compressed_ids):
- Evaluation_14.__init__(self, compressed_ids)
- self.export_label = _('cm_eval_header_avg_effort')
- self.export_eval_what = u"abgeschlossene Beratungsfälle"
-
- def doExport(self, f):
- p = self.perform()
- f.write(u"#%s - %s Fälle (Auswertung: %s)\r\n" % (self.export_label, p['avg_all'][0], self.export_eval_what))
- f.write(u"Aktivität;Durchschnitt Aufwand\r\n")
- items = ['avg_cat1','avg_cat2','avg_cat3','avg_cat4','avg_all']
- for key in items:
- v = p.get(key)
- f.write("%s;%s\r\n" % (AVGKIND2TEXT.get(key), v[1]))
-
-class Evaluation_17(Evaluation_15):
- """Durchschnitt Zeitaufwand abgeschlossene CM-Fälle"""
- def __init__(self, compressed_ids):
- Evaluation_15.__init__(self, compressed_ids)
- self.export_label = _('cm_eval_header_avg_effort2')
- self.export_eval_what = u"abgeschlossene CM-Fälle"
-
class Evaluation_18(Evaluation_14):
"""Zeitaufwände aus dem Logbuch aller Fälle"""
def __init__(self, compressed_ids):
@@ -978,255 +256,4 @@
ORDER BY l.art
""" % self.where_clause(self.compressed_ids, "l.master_id")
-class Evaluation_19(Evaluation):
- """Anzahl gemeldeter Arbeitsloser"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
-
- # Anzahl aller gemeldeten Arbeitlosen
- self.sql_gesamt = """select count(arbeitslosigkeit_1) from master_tbl_eval_incm_view where arbeitslosigkeit_1= 1 AND (%s)""" % self.where_clause(self.compressed_ids, "id")
- # Anzahl davon ALG1 Empfänger
- self.sql_alg1 = """select count(bezug_alg1) from (select bezug_alg1, id, fkz from master_tbl_eval_incm_view where arbeitslosigkeit_1 = 1) arbeitslos where bezug_alg1 = 1 AND (%s)""" % self.where_clause(self.compressed_ids, "id")
- # Anzahl davon ALG2 Empfänger
- self.sql_alg2 = """select count(bezug_alg2) from (select bezug_alg2, id, fkz from master_tbl_eval_incm_view where arbeitslosigkeit_1 = 1) arbeitslos where bezug_alg2 = 1 AND (%s)""" % self.where_clause(self.compressed_ids, "id")
- # Anzahl davon Langezeitarbeitslose
- self.sql_lza = """select count(dauer_nach_letzter_beschaeftigung) from (select dauer_nach_letzter_beschaeftigung, id, fkz from master_tbl_eval_incm_view where arbeitslosigkeit_1 = 1) arbeitslos where dauer_nach_letzter_beschaeftigung >= 12 AND (%s)""" % self.where_clause(self.compressed_ids, "id")
-
-
- def perform(self):
- result = {'gesamt': [0,0], 'alg1': [0,0], 'alg2': [0,0], 'lza': [0,0]}
- try:
- try:
- conn = db.getConnection()
- cur = conn.cursor()
-
- if self.total_valid_cm == 0: divisor = 1
- else: divisor = self.total_valid_cm
-
- # gesamt
- cur.execute(self.sql_gesamt)
- row = cur.fetchone()
- result['gesamt'][0] = row[0]
- result['gesamt'][1] = h.formatNumber(float(row[0] / divisor*100))
-
- # alg1
- cur.execute(self.sql_alg1)
- row = cur.fetchone()
- result['alg1'][0] = row[0]
- result['alg1'][1] = h.formatNumber(float(row[0] / divisor*100))
-
- # alg2
- cur.execute(self.sql_alg2)
- row = cur.fetchone()
- result['alg2'][0] = row[0]
- result['alg2'][1] = h.formatNumber(float(row[0] / divisor*100))
-
- # lza
- cur.execute(self.sql_lza)
- row = cur.fetchone()
- result['lza'][0] = row[0]
- result['lza'][1] = h.formatNumber(float(row[0] / divisor*100))
-
- return result
- except StandardError, e:
- traceback.print_exc(file=sys.stderr)
- print >> sys.stderr, "No results for eval 19"
- finally:
- db.recycleConnection(conn, cur)
-
-
- def doExport(self, f):
- p = self.perform()
-
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_summary_header_19'))
- f.write("Kategorie;Anzahl;Prozent\r\n")
- for l in [p]:
- for k, v in l.iteritems():
- f.write(u"%s;%s;%s;\r\n" % (k, v[0], v[1]))
-
-
-class Evaluation_20(Evaluation):
- """Anzahl Nicht-Erwerbspersonen"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
- # Anzahl aller Nicht-Erwerbspersonen
- self.sql_gesamt = """select count(id) from master_tbl_eval_incm_view where arbeitslosigkeit_1 = 0 and erwerbstaetigkeit_job = 0 AND (%s)""" % self.where_clause(self.compressed_ids, "id")
- # Davon befinden sich in einer schulischen Ausbildung
- self.sql_inschule = """select count(bei_eintritt_ist_der_jugendliche) from (select bei_eintritt_ist_der_jugendliche, id, fkz from master_tbl_eval_incm_view where arbeitslosigkeit_1 = 0 and erwerbstaetigkeit_job = 0) erwerbslos where bei_eintritt_ist_der_jugendliche = 0 AND (%s)""" % self.where_clause(self.compressed_ids, "id")
-
- def perform(self):
- # result [gesamt_anz, gesamt_proz, schule_anz, schule_proz]
- result = {'gesamt':[0,0],'schule':[0,0]}
- try:
- try:
- conn = db.getConnection()
- cur = conn.cursor()
-
- if self.total_valid_cm == 0: divisor = 1
- else: divisor = self.total_valid_cm
-
- cur.execute(self.sql_gesamt)
- row = cur.fetchone()
- result['gesamt'][0] = row[0]
- result['gesamt'][1] = h.formatNumber(float(row[0]) / divisor*100)
-
- cur.execute(self.sql_inschule)
- row = cur.fetchone()
- result['schule'][0] = row[0]
- result['schule'][1] = h.formatNumber(float(row[0]) / divisor*100)
- return result
- except StandardError, e:
- traceback.print_exc(file=sys.stderr)
- print >> sys.stderr, "No results for eval 20"
- finally:
- db.recycleConnection(conn, cur)
-
- def doExport(self, f):
- p = self.perform()
-
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_summary_header_20'))
- f.write("Kategorie;Anzahl;Prozent\r\n")
- for l in [p]:
- for k, v in l.iteritems():
- f.write(u"%s;%s;%s;\r\n" % (k, v[0], v[1]))
-
-class Evaluation_21(Evaluation):
- """Auswertung des ESF Stammblatt"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
- self.eval_alter = Evaluation_8(compressed_ids)
- self.austritte = Evaluation_13(compressed_ids)
- self.arbeitslos = Evaluation_19(compressed_ids)
- self.nichterwerb = Evaluation_20(compressed_ids)
- self.migration = Evaluation_3(compressed_ids)
- self.abschluss = Evaluation_22(compressed_ids)
- self.ohneabschluss = Evaluation_23(compressed_ids)
-
- # Anzahl aller Nicht-Erwerbspersonen
-
- def perform(self):
- # result [gesamt_anz, gesamt_proz, schule_anz, schule_proz]
- result = {'eintritte':[0,0],'eintritte_alter':[], 'migrationshintergrund': [0,0], 'arbeitslos':{}, 'nichterwerb': {}, 'austritte': [0,0,0,0,0,0,0,0], 'abschluss': {} }
-
- if self.total_valid_cm == 0: divisor = 1
- else: divisor = self.total_valid_cm
-
- try:
- # eintritte gesammt
- result_eval_alter = self.eval_alter.perform()
- for cat in result_eval_alter:
- result['eintritte'][0] += cat[1]
- result['eintritte'][1] = h.formatNumber(float(result['eintritte'][0] / divisor*100))
- # eintritte nach alter aufgeschluesselt
- result['eintritte_alter'] = result_eval_alter
- # migrationshintergrund
- migration = self.migration.perform()
- result['migrationshintergrund'][0] = migration[0][0]
- result['migrationshintergrund'][1] = h.formatNumber(float(result['migrationshintergrund'][0])/ divisor*100)
- # arbeitslos
- result['arbeitslos'] = self.arbeitslos.perform()
- # nichterwerb
- result['nichterwerb'] = self.nichterwerb.perform()
-
- # schulabschluss
- result['abschluss']['kein'] = [0,0]
- result['abschluss']['hauptreal'] = [0,0]
-
- schule = self.abschluss.perform()
- for id, v in schule.iteritems():
- if id in [3,4,5,9,10]:
- result['abschluss']['hauptreal'][0] += v[1]
- result['abschluss']['hauptreal'][1] = h.formatNumber(float(result['abschluss']['hauptreal'][0])/ divisor*100)
-
- ohneabschluss = self.ohneabschluss.perform()
- result['abschluss']['kein'][0] = ohneabschluss[0]
- result['abschluss']['kein'][1] = h.formatNumber(float(result['abschluss']['kein'][0])/ divisor*100)
-
- # Austritte
- austritte = self.austritte.perform()
- #austritte= [avg_month_abg, anz_abg, avg_month_vz, anz_vz, avg_month_abr, anz_abr]
- # Vorzeitig
- result['austritte'][2] = austritte[3]
- result['austritte'][3] = h.formatNumber(float(result['austritte'][2])/ divisor*100)
- # Abgesch.
- result['austritte'][4] = austritte[1]
- result['austritte'][5] = h.formatNumber(float(result['austritte'][4])/ divisor*100)
- # Abbruch
- result['austritte'][6] = austritte[5]
- result['austritte'][7] = h.formatNumber(float(result['austritte'][6])/ divisor*100)
- result['austritte'][0] = austritte[1]+austritte[3]+austritte[5]
- result['austritte'][1] = h.formatNumber(float(result['austritte'][0])/ divisor*100)
-
- return result
- except StandardError, e:
- traceback.print_exc(file=sys.stderr)
- print >> sys.stderr, "No results for eval 21"
-
-
- def doExport(self, f):
- p = self.perform()
-
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_summary_header_21'))
- f.write("Kategorie;Anzahl;Prozent\r\n")
- f.write(u"%s;%s;%s;\r\n" % ('Eintritte gesamt', p['eintritte'][0], p['eintritte'][1]))
- f.write(u"%s;;;\r\n" % ('Eintritte nach Alter'))
- for a in p['eintritte_alter']:
- f.write(u" %s;%s;%s;\r\n" % (a[0], a[1], a[2]))
- f.write(u"%s;%s;%s;\r\n" % ('Migrationshintergrund', p['migrationshintergrund'][0], p['migrationshintergrund'][1]))
- f.write(u"%s;%s;%s;\r\n" % ('Arbeitslos gemeldet', p['arbeitslos']['gesamt'][0], p['arbeitslos']['gesamt'][1]))
-
- f.write(u" %s;%s;%s;\r\n" % ('davon langzeitarbeitslos', p['arbeitslos']['lza'][0], p['arbeitslos']['lza'][1]))
- f.write(u" %s;%s;%s;\r\n" % ('davon aus Regelkreis SGBII', p['arbeitslos']['gesamt'][0], p['arbeitslos']['alg1'][1]))
- f.write(u" %s;%s;%s;\r\n" % ('davon aus Regelkreis SGBIII', p['arbeitslos']['gesamt'][0], p['arbeitslos']['alg2'][1]))
- f.write(u"%s;%s;%s;\r\n" % (u'Nicht-Erwerbstätig', p['nichterwerb']['gesamt'][0], p['nichterwerb']['gesamt'][1]))
- f.write(u" %s;%s;%s;\r\n" % (u'davon in schulischer Ausbildung', p['nichterwerb']['schule'][0], p['nichterwerb']['gesamt'][1]))
- f.write(u"%s;%s;%s;\r\n" % (u'Ohne Abschluss', p['abschluss']['kein'][0], p['abschluss']['kein'][1]))
- f.write(u"%s;%s;%s;\r\n" % (u'Ausschließlich Hauptschulabschluss, Realschulabschluss BVJ oder BGJ', p['abschluss']['hauptreal'][0], p['abschluss']['hauptreal'][1]))
- f.write(u"%s;%s;%s;\r\n" % (u'Vorhabenaustritte', p['austritte'][0], p['austritte'][1]))
- f.write(u"%s;%s;%s;\r\n" % (u'Reguläre Austritte', p['austritte'][2], p['austritte'][3]))
- f.write(u"%s;%s;%s;\r\n" % (u'Vorzeitige Austritte', p['austritte'][4], p['austritte'][5]))
- f.write(u"%s;%s;%s;\r\n" % (u'Abbrüche', p['austritte'][6], p['austritte'][7]))
-
-class Evaluation_22(Evaluation_11):
- """Schulabschluss beim Zugang (cm)"""
- def __init__(self, compressed_ids):
- Evaluation_11.__init__(self, compressed_ids)
- self.view = 'master_tbl_eval_incm_view'
-
-class Evaluation_23(Evaluation):
- """Anzahl Jugendlicher ohne Abschluss Zugang (cm)"""
- def __init__(self, compressed_ids):
- Evaluation.__init__(self, compressed_ids)
- # Anzahl ohne Abschluss
- self.sql = """select count(id) from master_tbl_eval_incm_view where abschluss_betriebliche_ausbildung = 0 and abschluss_ausserbetriebliche_ausbildung = 0 and schulabschluss_1 = 1 AND (%s)""" % self.where_clause(self.compressed_ids, "id")
-
- def perform(self):
- result = [0,0]
- try:
- try:
- conn = db.getConnection()
- cur = conn.cursor()
-
- if self.total_valid_cm == 0: divisor = 1
- else: divisor = self.total_valid_cm
-
- cur.execute(self.sql)
- row = cur.fetchone()
- result[0] = row[0]
- result[1] = h.formatNumber(float(row[0] / divisor*100))
- return result
- except StandardError, e:
- traceback.print_exc(file=sys.stderr)
- print >> sys.stderr, "No results for eval 23"
- finally:
- db.recycleConnection(conn, cur)
-
- def doExport(self, f):
- p = self.perform()
-
- f.write(u"#%s (Auswertung: Jugendliche im CM)\r\n" % _('cm_eval_summary_header_23'))
- f.write("Anzahl;Prozent\r\n")
- f.write(u"%s;%s\r\n" % (p[0], p[1]))
-
-
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list