← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~zeitgeist/zeitgeist/fix-646124 into lp:zeitgeist

 

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

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  #646124 Wrong understanding of the LeastRecentActors
  https://bugs.launchpad.net/bugs/646124


Basically all I did is replace LeastRecentActor with a new OldestActor and ported LeastRecentActor to our new understanding discussed in bug #646124
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/fix-646124/+merge/36628
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~zeitgeist/zeitgeist/fix-646124 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py	2010-09-24 17:02:50 +0000
+++ _zeitgeist/engine/main.py	2010-09-25 11:45:54 +0000
@@ -343,7 +343,7 @@
 		else:
 			raise NotImplementedError, "Unsupported return_mode."
 		
-		if order == ResultType.LeastRecentActor:
+		if order == ResultType.OldestActor:
 			sql += """
 				NATURAL JOIN (
 					SELECT actor, min(timestamp) AS timestamp
@@ -366,7 +366,8 @@
 			" GROUP BY subj_origin ORDER BY timestamp DESC",
 			" GROUP BY subj_origin ORDER BY timestamp ASC",
 			" GROUP BY subj_origin ORDER BY COUNT(subj_origin) DESC, timestamp DESC",
-			" GROUP BY subj_origin ORDER BY COUNT(subj_origin) ASC, timestamp ASC")[order]
+			" GROUP BY subj_origin ORDER BY COUNT(subj_origin) ASC, timestamp ASC",
+			" GROUP BY actor ORDER BY timestamp ASC")[order]
 		
 		if max_events > 0:
 			sql += " LIMIT %d" % max_events

=== modified file 'test/engine-test.py'
--- test/engine-test.py	2010-09-24 17:02:50 +0000
+++ test/engine-test.py	2010-09-25 11:45:54 +0000
@@ -596,6 +596,15 @@
 		events = self.engine.find_events(
 			TimeRange(105,107), [], StorageState.Any, 0, ResultType.MostRecentActor)
 		self.assertEquals([e[0][1] for e in events], ["107", "105"])
+	
+	def testResultTypesOldestActor(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		events = self.engine.find_events(
+			TimeRange.always(),
+			[Event.new_for_values(subject_manifestation="stfu:File")],
+			StorageState.Any, 0, ResultType.OldestActor)
+		self.assertEquals([e[0][1] for e in events], ["100", "101", "105"])
 
 	def testResultTypesLeastRecentActor(self):
 		import_events("test/data/twenty_events.js", self.engine)
@@ -604,11 +613,9 @@
 			TimeRange.always(),
 			[Event.new_for_values(subject_manifestation="stfu:File")],
 			StorageState.Any, 0, ResultType.LeastRecentActor)
-		self.assertEquals([e[0][1] for e in events], ["100", "101", "105"])
-		# LeastRecentActor should really be: 100, 101, 105. See bug #646124.
-		# This will be renamed to something like OldestActor.
+		self.assertEquals([e[0][1] for e in events], ['105', '114', '119'])
 
-	def testResultTypesLeastRecentActorBug641968(self):
+	def testResultTypesOldestActorBug641968(self):
 		events = [
 			Event.new_for_values(timestamp=1, actor="boo", subject_uri="tmp/boo"),
 			Event.new_for_values(timestamp=2, actor="boo", subject_uri="home/boo"),
@@ -619,20 +626,20 @@
 		
 		# Get the least recent actors
 		ids = self.engine.find_eventids(TimeRange.always(),
-			[], StorageState.Any, 0, ResultType.LeastRecentActor)
+			[], StorageState.Any, 0, ResultType.OldestActor)
 		self.assertEquals(ids, [1, 3, 4])
 		
 		# Get the least recent actors for "home/boo"
 		template = Event.new_for_values(subject_uri="home/boo")
 		ids = self.engine.find_eventids(TimeRange.always(),
-			[template], StorageState.Any, 0, ResultType.LeastRecentActor)
+			[template], StorageState.Any, 0, ResultType.OldestActor)
 		self.assertEquals(ids, [2])
 		
 		# Let's also try the same with MostRecentActor... Although there
 		# should be no problem here.
 		template = Event.new_for_values(subject_uri="home/boo")
 		ids = self.engine.find_eventids(TimeRange.always(),
-			[template], StorageState.Any, 0, ResultType.LeastRecentActor)
+			[template], StorageState.Any, 0, ResultType.OldestActor)
 		self.assertEquals(ids, [2])
 	
 	def testResultTypesMostPopularOrigin(self):

=== modified file 'zeitgeist/datamodel.py'
--- zeitgeist/datamodel.py	2010-08-28 15:14:42 +0000
+++ zeitgeist/datamodel.py	2010-09-25 11:45:54 +0000
@@ -1029,14 +1029,15 @@
 		"ordered by the popularity of the actor"))
 	LeastPopularActor = enum_factory(("The last event of each different actor,"
 		"ordered ascendingly by the popularity of the actor"))
-	MostRecentActor = enum_factory(("The last event of each different actor"))
-	LeastRecentActor = enum_factory(("The first event of each different actor"))	
+	MostRecentActor = enum_factory(("The most recent event of each different actor"))
+	LeastRecentActor = enum_factory(("The least recent event of each different actor"))	
 	MostRecentOrigin = enum_factory(("The last event of each different origin"))
 	LeastRecentOrigin = enum_factory(("The first event of each different origin"))
 	MostPopularOrigin = enum_factory(("The last event of each different origin,"
 		"ordered by the popularity of the origins"))
 	LeastPopularOrigin = enum_factory(("The last event of each different origin,"
 		"ordered ascendingly by the popularity of the origin"))
+	OldestActor = enum_factory(("The first event of each different actor"))	
 
 
 INTERPRETATION_DOC = \


Follow ups