[Mpuls-commits] r2992 - jmd/trunk/jmdstrukturweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jun 10 17:08:59 CEST 2010
Author: torsten
Date: 2010-06-10 17:08:59 +0200 (Thu, 10 Jun 2010)
New Revision: 2992
Modified:
jmd/trunk/jmdstrukturweb/model/appointment.py
Log:
Fixed getting recent statistik
Modified: jmd/trunk/jmdstrukturweb/model/appointment.py
===================================================================
--- jmd/trunk/jmdstrukturweb/model/appointment.py 2010-06-10 14:45:49 UTC (rev 2991)
+++ jmd/trunk/jmdstrukturweb/model/appointment.py 2010-06-10 15:08:59 UTC (rev 2992)
@@ -10,6 +10,8 @@
from mpulsweb.model.appointment import AppointmentOverview, CaseAppointmentFactory
+log = logging.getLogger(__name__)
+
class StatisticReminderOverview(AppointmentOverview):
def __init__(self):
@@ -24,36 +26,60 @@
# longer than maxage.
# orphaned means that all last appointments, aids or the
# modification date is older than maxage
- oldAndActive = self.get_recent_statistic(maxage, user)
+ oldAndActive = self.check_recent_statistic(maxage, user)
if not oldAndActive:
- appointment = self.makeAppointment()
+ case = self.get_recent_statistic(maxage, user)
+ appointment = self.makeAppointment(case)
self.appointment_list.append(appointment)
-
def get_recent_statistic(self, days, user):
conn, cur = None, None
+ try:
+ conn = db.getConnection()
+ cur = conn.cursor()
+ sql = ("SELECT id, datum_begin_zeitraum, datum_ende_zeitraum \
+ from master_tbl_view \
+ order by datum_begin_zeitraum desc")
+ cur.execute(sql, {'maxdays': days})
+ log.debug(cur.query)
+ result = cur.fetchone()
+ case = {'id': result[0], 'start': result[1], 'end': result[2]}
+ return case
+ finally:
+ db.recycleConnection(conn, cur)
+ return False
+
+ def check_recent_statistic(self, days, user):
+ conn, cur = None, None
list = {}
- remindercondition = g.mpuls_config.get('case', 'remindercondition')
try:
conn = db.getConnection()
cur = conn.cursor()
- sql = ("SELECT id from master_tbl_view where extract(day from (now() - datum_begin_zeitraum)) < %(maxdays)s")
+ sql = ("SELECT id, datum_begin_zeitraum, datum_ende_zeitraum \
+ from master_tbl_view where \
+ extract(\
+ day from (now() - datum_begin_zeitraum)\
+ ) < %(maxdays)s \
+ order by datum_begin_zeitraum desc")
cur.execute(sql, {'maxdays': days})
+ log.debug(cur.query)
result = cur.fetchall()
for r in result:
- list[r[0]] = {}
+ list[r[0]] = {'start': r[1], 'end': r[2]}
return list
finally:
db.recycleConnection(conn, cur)
return False
- def makeAppointment(self):
+ def makeAppointment(self, case):
factory = CaseAppointmentFactory()
type = 1
- title = u"JMDSTRUKTURTEST"
- desc = u"Statistik fehlt"
+ title = u"Neue JMD-Statistik erstellen"
+ desc = u"Für den aktuellen Zeitraum konnte keine JMD-Statistik \
+ gefunden werden. Die letzte JMD-Statistik ist für den \
+ Zeitraum %s - %s." % (case.get('start'), case.get('end'))
mydate = datetime.now()
appointment = factory.createByData(None, title, mydate, None, desc,
- 0, type)
+ case.get('id'), type)
return appointment
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list