zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #03138
[Merge] lp:~zeitgeist/zeitgeist/querybystorage into lp:zeitgeist
Siegfried Gevatter has proposed merging lp:~zeitgeist/zeitgeist/querybystorage into lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/querybystorage/+merge/57911
--
https://code.launchpad.net/~zeitgeist/zeitgeist/querybystorage/+merge/57911
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~zeitgeist/zeitgeist/querybystorage into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py 2011-04-07 08:29:36 +0000
+++ _zeitgeist/engine/main.py 2011-04-15 17:16:28 +0000
@@ -387,22 +387,25 @@
def _build_sql_event_filter(self, time_range, templates, storage_state):
- # FIXME: We need to take storage_state into account
- if storage_state != StorageState.Any:
- raise NotImplementedError
+ where = WhereClause(WhereClause.AND)
# thekorn: we are using the unary operator here to tell sql to not use
# the index on the timestamp column at the first place. This `fix` for
# (LP: #672965) is based on some benchmarks, which suggest a performance
# win, but we might not oversee all implications.
# (see http://www.sqlite.org/optoverview.html section 6.0)
- where = WhereClause(WhereClause.AND)
min_time, max_time = time_range
if min_time != 0:
where.add("+timestamp >= ?", min_time)
if max_time != sys.maxint:
where.add("+timestamp <= ?", max_time)
+ if storage_state in (StorageState.Available, StorageState.NotAvailable):
+ where.add("(subj_storage_state = ? OR subj_storage_state IS NULL)",
+ storage_state)
+ elif storage_state != StorageState.Any:
+ raise ValueError, "Unknown storage state '%d'" % storage_state
+
where.extend(self._build_sql_from_event_templates(templates))
return where
=== modified file 'test/engine-test.py'
--- test/engine-test.py 2011-04-07 06:56:54 +0000
+++ test/engine-test.py 2011-04-15 17:16:28 +0000
@@ -280,10 +280,20 @@
(1, 10000000),
[],
StorageState.Any,
- 5,
- 0,)
- self.assertEquals(5, len(result))
-
+ 0,
+ 0)
+ self.assertEquals(5, len(result))
+
+ def testFindFiveWithStorageState(self):
+ import_events("test/data/five_events.js", self.engine)
+ # The event's storage is unknown, so we get them back always.
+ result = self.engine.find_eventids(TimeRange.always(), [],
+ StorageState.Available, 0, 0)
+ self.assertEquals(5, len(result))
+ result = self.engine.find_eventids(TimeRange.always(), [],
+ StorageState.NotAvailable, 0, 0)
+ self.assertEquals(5, len(result))
+
def testFindWithNonExistantActor(self):
# Bug 496109: filtering by timerange and a non-existing actor gave an
# incorrect result.
@@ -417,18 +427,7 @@
orig_ids = self.engine.insert_events([event])
result_ids = self.engine.find_eventids(TimeRange.always(), [Event()], StorageState.Any, 0, 1)
self.assertEquals(orig_ids, result_ids)
-
- def testDontFindState(self):
- # searchin by storage state is currently not implemented
- # checking for the error
- import_events("test/data/twenty_events.js", self.engine)
- self.assertRaises(NotImplementedError, self.engine.find_eventids,
- (1, 10000000),
- [],
- StorageState.Available,
- 1,
- 0,)
-
+
def testFindEventsEventTemplate(self):
import_events("test/data/five_events.js", self.engine)
subj = Subject.new_for_values(interpretation="stfu:Bee")
Follow ups