← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~seif/zeitgeist/fix-641968 into lp:zeitgeist

 

Seif Lotfy has proposed merging lp:~seif/zeitgeist/fix-641968 into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  #641968 querying on LeastRecentActor and MostRecentActor for a certain subject_uri is not working
  https://bugs.launchpad.net/bugs/641968


Added fix to bug #641968 
basically just like the bug statement
IMHO our current understanding of LeastRecentActor is wrong...
Let's assume we have sequential events. (The actors are defined by numbers)

2, 1, 3, 2, 1, 4

So we have 4 different actors (1,2,3,4) and we want to sort them by least recent.
the least recent is not 2 or 1 since they are used again at the end. the least recent is 3

This means LeastRecentActors should return the latest actors sorted ASC:

3, 2, 1, 4

and not

2, 1, 3, 4

MostRecentActors should return the same last 4 files but in reversed sorting:

4, 3, 1, 2


-- 
https://code.launchpad.net/~seif/zeitgeist/fix-641968/+merge/36428
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~seif/zeitgeist/fix-641968 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py	2010-09-17 08:37:39 +0000
+++ _zeitgeist/engine/main.py	2010-09-23 10:19:40 +0000
@@ -343,14 +343,6 @@
 		else:
 			raise NotImplementedError, "Unsupported return_mode."
 		
-		if order == ResultType.LeastRecentActor:
-			sql += """
-				NATURAL JOIN (
-					SELECT actor, min(timestamp) AS timestamp
-					FROM event_view
-					GROUP BY actor)
-				"""
-		
 		if where:
 			sql += " WHERE " + where.sql
 		

=== modified file 'test/engine-test.py'
--- test/engine-test.py	2010-09-19 09:24:40 +0000
+++ test/engine-test.py	2010-09-23 10:19:40 +0000
@@ -602,7 +602,28 @@
 		
 		events = self.engine.find_events(
 			TimeRange.always(), [], StorageState.Any, 0, ResultType.LeastRecentActor)
-		self.assertEquals([e[0][1] for e in events], ["100", "101", "105"])
+		self.assertEquals([e[0][1] for e in events], ["105", "114", "119"])
+		
+		
+	def testResultTypesLeastRecentActorForSubject(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		event_templates = [Event.new_for_values(subject_uri="file:///tmp/foo.txt"),]
+		
+		events = self.engine.find_events(
+			TimeRange.always(), event_templates, StorageState.Any, 0, ResultType.LeastRecentActor)
+		self.assertEquals([e[0][1] for e in events], ["105", "114", "119"])
+		
+	def testResultTypesMostRecentActorForSubject(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		event_templates = [Event.new_for_values(subject_uri="file:///tmp/foo.txt"),]
+		
+		events = self.engine.find_events(
+			TimeRange.always(), event_templates, StorageState.Any, 0, ResultType.MostRecentActor)
+		self.assertEquals([e[0][1] for e in events], ["119", "114", "105"])
+		
+		
 
 	def testResultTypesMostPopularOrigin(self):
 		import_events("test/data/twenty_events.js", self.engine)


Follow ups