Siegfried Gevatter has proposed merging 
lp:~zeitgeist/zeitgeist/bluebird-no-distinct into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)

For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird-no-distinct/+merge/87175
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird-no-distinct/+merge/87175
Your team Zeitgeist Framework Team is requested to review the proposed merge of 
lp:~zeitgeist/zeitgeist/bluebird-no-distinct into lp:zeitgeist.
=== modified file 'src/engine.vala'
--- src/engine.vala	2011-12-29 13:59:16 +0000
+++ src/engine.vala	2011-12-31 00:36:25 +0000
@@ -207,7 +207,7 @@
         //if (!where.may_have_results ())
         //    return new uint32[0];
 
-        string sql = "SELECT DISTINCT id FROM event_view ";
+        string sql = "SELECT id FROM event_view ";
         string where_sql = "";
         if (!where.is_empty ())
         {
@@ -321,9 +321,6 @@
                 throw new EngineError.INVALID_ARGUMENT (error_message);
         }
 
-        if (max_events > 0)
-            sql += " LIMIT %u".printf (max_events);
-
         int rc;
         Sqlite.Statement stmt;
 
@@ -338,11 +335,15 @@
 
         while ((rc = stmt.step()) == Sqlite.ROW)
         {
-            var id = (uint32) uint64.parse(
+            var event_id = (uint32) uint64.parse(
                 stmt.column_text (EventViewRows.ID));
-            event_ids += id;
+            // Events are supposed to be contiguous in the database
+            if (event_ids[event_ids.length] != event_id) {
+                event_ids += event_id;
+                if (event_ids.length == max_events) break;
+            }
         }
-        if (rc != Sqlite.DONE)
+        if (rc != Sqlite.DONE && rc != Sqlite.ROW)
         {
             string error_message = "Error in find_event_ids: %d, %s".printf (
                 rc, db.errmsg ());

_______________________________________________
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