[Mpuls-commits] r5477 - base/trunk/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Oct 14 21:15:14 CEST 2011
Author: bh
Date: 2011-10-14 21:15:12 +0200 (Fri, 14 Oct 2011)
New Revision: 5477
Modified:
base/trunk/mpulsweb/controllers/evaluate.py
Log:
Use fkz_tbl table on evaluation servers if required.
If cases have been marked for evaluation on an evaluation server, the
where clause expression that is saved to be used in the evaluation SQL
statement, may refer to the fkz_tbl. Thus we have to include JOIN clause
for that table. This clause is always added now if an sql_where
parameter has been given to the EvaluateController_get_evalparams
method, which may be too often (so it's not really added only when
required).
Also, this heuristic won't work if such a clause is ever used on the
normal application server (see comments in the code) but for now it
should work well enough.
Fixes mpuls/issue2305.
Modified: base/trunk/mpulsweb/controllers/evaluate.py
===================================================================
--- base/trunk/mpulsweb/controllers/evaluate.py 2011-10-14 18:29:04 UTC (rev 5476)
+++ base/trunk/mpulsweb/controllers/evaluate.py 2011-10-14 19:15:12 UTC (rev 5477)
@@ -206,15 +206,29 @@
where_clauses.append(selected_ids)
if sql_where:
+ # The sql_where parameter is currently (2011-10-14) only set
+ # when running as an evaluation server (it's set by
+ # EvaluationSearch). The database of the evaluation server
+ # has an additional table, fkz_tbl, which may be referenced
+ # by the expression in sql_where. That table doesn't exist
+ # in a normal mpuls application database, so we can only add
+ # the join clause for the fkz_tbl on evaluation servers.
+ # FIXME: There should be a better way to communicate the
+ # requirements of the sql_where clause, especially if we
+ # ever extend it to the search on the normal application
+ # server.
where_clauses.append(sql_where)
-
+ join_fkz = "JOIN fkz_tbl f ON f.id::integer = m.fkz::integer"
+ else:
+ join_fkz = ""
where_clauses.append(self.type_ending_clause(params))
params['sql'] = ("SELECT %%(fields)s from master_tbl_eval_total_view m"
" JOIN ka_status_tbl_view st on st.master_id = m.id"
- " WHERE %s " % (" AND ".join(where_clauses)))
+ " %s"
+ " WHERE %s "
+ % (join_fkz, " AND ".join(where_clauses)))
-
#Datefields
if all_phases:
params['start_date_field'] = get_phase_dates(min(all_phases))[0]
More information about the Mpuls-commits
mailing list