Merge lp:~seif/zeitgeist/fix-redundant-statement into lp:zeitgeist/0.1

Proposed by Seif Lotfy
Status: Rejected
Rejected by: Seif Lotfy
Proposed branch: lp:~seif/zeitgeist/fix-redundant-statement
Merge into: lp:zeitgeist/0.1
Diff against target: 14 lines (+1/-3)
1 file modified
_zeitgeist/engine/main.py (+1/-3)
To merge this branch: bzr merge lp:~seif/zeitgeist/fix-redundant-statement
Reviewer Review Type Date Requested Status
Markus Korn Disapprove
Review via email: mp+41751@code.launchpad.net

Description of the change

Basically I found this statement. For me we could get rid of one of them. Right now using only one statement of both works for all our test cases.

if return_mode == 0:
    sql = "SELECT DISTINCT id FROM event_view"
elif return_mode == 1:
    sql = "SELECT id FROM event_view"

Do we really need both? In any case here is a little merge proposal

To post a comment you must log in.
Revision history for this message
Markus Korn (thekorn) wrote :

If you are sure that we don't need `DISTINCT` in this query (I have not checked it in detail), you should also remove the `return_mode` argument.

review: Needs Fixing
Revision history for this message
Markus Korn (thekorn) wrote :

This testcase [0] works fine in lp:zeitgeist, but fails in your branch. So removing DISTINCT seems to be wrong, Disapproved ;)

[0] http://paste.ubuntu.com/535972/

review: Disapprove
Revision history for this message
Siegfried Gevatter (rainct) wrote :

Yeah, don't remove DISTINCT.

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

I can see what you're getting at. I recall that I told Siegfried to
add DISTINCT at the hackfest because we where getting some wrong
results... I can't remember the exact details...

Revision history for this message
Siegfried Gevatter (rainct) wrote :

Uhm? Without the distinct FindEventIds will be giving duplicated stuff.

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

review needsfixing

Ah right. Now I get it.

If we have multiple subjects for one event we'll have multiple rows in
events_view with the same id. I can't see how our multi-subject tests
can pass if you remove the DISTINCT. It may be worthwhile adding a
test that proves my point...

If you're very keen on removing the DISTINCT (fx. if you have
profiling data to back it up) then it looks like you can do it if you
manually coalesce the id list before returning it or passing it to
get_events().

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

I just added this test in trunk rev 1638. And indeed it fails if I
remove DISTINCT.

Unmerged revisions

1637. By Seif Lotfy

removed redundant statement

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-11-12 18:09:45 +0000
3+++ _zeitgeist/engine/main.py 2010-11-24 15:51:17 +0000
4@@ -335,9 +335,7 @@
5 if not where.may_have_results():
6 return []
7
8- if return_mode == 0:
9- sql = "SELECT DISTINCT id FROM event_view"
10- elif return_mode == 1:
11+ if return_mode in (0,1):
12 sql = "SELECT id FROM event_view"
13 else:
14 raise NotImplementedError, "Unsupported return_mode."

Subscribers

People subscribed via source and target branches