summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2012-07-09 08:47:33 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2012-07-09 08:47:33 (GMT)
commit8bbed058eabe2bfdf80c857215050956db28036f (patch)
treed27638bfbd630b484cce5a053be5d54be49e4756
parent507e8cb4d5cfa7f63fb5b05852c539218878dc9a (diff)
downloadtabellio.pcfdb-8bbed058eabe2bfdf80c857215050956db28036f.zip
tabellio.pcfdb-8bbed058eabe2bfdf80c857215050956db28036f.tar.gz
tabellio.pcfdb-8bbed058eabe2bfdf80c857215050956db28036f.tar.bz2
get written question dates in a single query
-rw-r--r--tabellio/pcfdb/sync.py18
1 files changed, 5 insertions, 13 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index 820a56f..53a2102 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -1087,8 +1087,9 @@ class SyncFromPcfDbView(BrowserView):
cursor.execute('''SELECT t_histo.id, t_histo.st, t_histo.type, t_histo.sess,
t_histo.no, t_histo.intit, t_histo.auteurs,
- t_histo.comppols, t_histo.matiereids, t_histo.objid
- FROM t_histo
+ t_histo.comppols, t_histo.matiereids,
+ t_histo.objid, t_qe.date
+ FROM t_histo LEFT JOIN t_qe ON t_histo.objid = t_qe.id
WHERE t_histo.intit IS NOT NULL
AND t_histo.type IN ('QA', 'QE', 'QO', 'INTERP')
%s''' % where_ts)
@@ -1099,7 +1100,7 @@ class SyncFromPcfDbView(BrowserView):
if row is None:
break
count += 1
- dos_id, state, dostype, sess, no, intit, authors, polgroups, topics, objid = row
+ dos_id, state, dostype, sess, no, intit, authors, polgroups, topics, objid, qedate = row
log.debug('t_qx/dos id: %s', dos_id)
if intit and '\n' in intit:
@@ -1138,16 +1139,7 @@ class SyncFromPcfDbView(BrowserView):
object.date = object.histolines[0].date
if object.questype == 'QE':
- # query into t_qe to get the question date instead of the bqr
- # date
- qe_cursor = self.db_connection.cursor()
- qe_cursor.execute('''SELECT date
- FROM t_qe
- WHERE id = %s''', (objid,))
- row = qe_cursor.fetchone()
- if row is not None:
- object.date = row[0]
- qe_cursor.close()
+ object.date = qedate
notify(ObjectModifiedEvent(object))
self.publish(object)