Markus Korn has proposed merging 
lp:~thekorn/zeitgeist/fix-641100-min-max-use-index into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  #641100 ZeitgeistEngine.__init__(): statement to get last row id is not using 
the index
  https://bugs.launchpad.net/bugs/641100


Use event index in the constructor of ZeitgeistEngine to get the first and last 
event id (LP: #641100)
-- 
https://code.launchpad.net/~thekorn/zeitgeist/fix-641100-min-max-use-index/+merge/35786
Your team Zeitgeist Framework Team is requested to review the proposed merge of 
lp:~thekorn/zeitgeist/fix-641100-min-max-use-index into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py	2010-09-17 00:04:11 +0000
+++ _zeitgeist/engine/main.py	2010-09-17 08:30:58 +0000
@@ -105,9 +105,10 @@
 		
 		# Find the last event id we used, and start generating
 		# new ids from that offset
-		row = cursor.execute("SELECT MIN(id), MAX(id) FROM event").fetchone()
-		self._last_event_id = row[1] if row[1] else 0
-		if row[0] == 0:
+		max_id = self._cursor.execute("SELECT MAX(id) FROM event").fetchone()[0]
+		min_id = self._cursor.execute("SELECT MIN(id) FROM event").fetchone()[0]
+		self._last_event_id = max_id or 0
+		if min_id == 0:
 			# old database version raise an error for now,
 			# maybe just change the id to self._last_event_id + 1
 			# looking closer at the old code, it seems like

_______________________________________________
Mailing list: https://launchpad.net/~zeitgeist
Post to     : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp

Reply via email to