[Mpuls-commits] r6089 - base/trunk/mpulsweb/model

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 2 11:38:00 CEST 2012


Author: roland
Date: 2012-10-02 11:38:00 +0200 (Tue, 02 Oct 2012)
New Revision: 6089

Added:
   base/trunk/mpulsweb/model/percentage.py
Log:
Add a model for the job percentage (2066-5)

Added: base/trunk/mpulsweb/model/percentage.py
===================================================================
--- base/trunk/mpulsweb/model/percentage.py	                        (rev 0)
+++ base/trunk/mpulsweb/model/percentage.py	2012-10-02 09:38:00 UTC (rev 6089)
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008, 2010 Intevation GmbH, Germany, <info at intevation.de>
+#
+# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
+# Web-Anwendungs-Server fuer Kompetenzagenturen).
+#
+# mpuls WASKA is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
+#
+# mpuls WASKA has been developed on behalf of the
+# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
+# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
+# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
+# European Social Fund resources.
+# Authors:
+# Roland Geider <roland.geider at intevation.de>
+#
+
+from mpulsweb.lib.db import db
+from mpulsweb.model.agencysettings import Agency
+
+import logging
+log = logging.getLogger(__name__)
+
+COUNT_ALL_CASES = """
+SELECT COUNT(1) FROM master_tbl_view m 
+    JOIN ka_status_tbl_view s ON m.id = s.master_id 
+    WHERE zugriff BETWEEN (now() - INTERVAL '1 day') AND now()
+    AND s.status = 1
+    """
+
+class JobPercentage:
+    
+    def calulate_percentage(self):
+
+        conn = db.getConnection()
+        cur = conn.cursor()
+        cur.execute(COUNT_ALL_CASES)
+        cases = cur.fetchone()[0]
+        
+        agency = Agency()
+        job_percentage = float(agency.getJobPercentage())
+        
+        if job_percentage and cases:
+            
+            # cases = # of cases
+            # stellenanteile (job percentage) of the agency
+            percentage = cases / float(job_percentage)
+
+            return percentage
+        else:
+            return 0
\ No newline at end of file



More information about the Mpuls-commits mailing list