Merge lp:~thekorn/zeitgeist/fix-650930-opt-complete-timerange into lp:zeitgeist/0.1

Proposed by Markus Korn
Status: Merged
Merged at revision: 1613
Proposed branch: lp:~thekorn/zeitgeist/fix-650930-opt-complete-timerange
Merge into: lp:zeitgeist/0.1
Diff against target: 16 lines (+5/-2)
1 file modified
_zeitgeist/engine/main.py (+5/-2)
To merge this branch: bzr merge lp:~thekorn/zeitgeist/fix-650930-opt-complete-timerange
Reviewer Review Type Date Requested Status
Siegfried Gevatter Approve
Review via email: mp+36962@code.launchpad.net

Description of the change

If FindEvents-queries are run over the complete TimeRange intervall don't add timestamp conditions to the SQL statement (LP: #650930)

To see speed improvements run the script attached to bug 650930 in lp:zeitgeist and in this branch.

To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote :

Nice.

review: Approve
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Don't we have a TimeRange.is_always() method? That would seem cleaner...

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Oh, scratch my previous comment... You check for apply the top and lower bounds individually. Nice

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_zeitgeist/engine/main.py'
2--- _zeitgeist/engine/main.py 2010-09-25 13:19:51 +0000
3+++ _zeitgeist/engine/main.py 2010-09-29 08:44:44 +0000
4@@ -307,8 +307,11 @@
5 raise NotImplementedError
6
7 where = WhereClause(WhereClause.AND)
8- where.add("timestamp >= ?", time_range[0])
9- where.add("timestamp <= ?", time_range[1])
10+ min_time, max_time = time_range
11+ if min_time != 0:
12+ where.add("timestamp >= ?", min_time)
13+ if max_time != sys.maxint:
14+ where.add("timestamp <= ?", max_time)
15
16 where.extend(self._build_sql_from_event_templates(templates))
17

Subscribers

People subscribed via source and target branches