Mikkel Kamstrup Erlandsen has proposed merging 
lp:~zeitgeist/zeitgeist/sort-by-orig into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  #487321 What value should subject.origin have?
  https://bugs.launchpad.net/bugs/487321


Implements new ResultTypes sorting and grouping events by origin. Also updates 
the docs strings of origin to reflect the consensus we reached. 
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/sort-by-orig/+merge/31201
Your team Zeitgeist Framework Team is requested to review the proposed merge of 
lp:~zeitgeist/zeitgeist/sort-by-orig into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py	2010-07-14 06:52:01 +0000
+++ _zeitgeist/engine/main.py	2010-07-28 20:12:49 +0000
@@ -358,12 +358,16 @@
 			" ORDER BY timestamp ASC",
 			" GROUP BY subj_uri ORDER BY timestamp DESC",
 			" GROUP BY subj_uri ORDER BY timestamp ASC",
-			" GROUP BY subj_uri ORDER BY COUNT(id) DESC, timestamp DESC",
-			" GROUP BY subj_uri ORDER BY COUNT(id) ASC, timestamp ASC",
-			" GROUP BY actor ORDER BY COUNT(id) DESC, timestamp DESC",
-			" GROUP BY actor ORDER BY COUNT(id) ASC, timestamp ASC",
-			" GROUP BY actor", # implicit: ORDER BY max(timestamp) DESC
-			" ORDER BY timestamp ASC")[order]
+			" GROUP BY subj_uri ORDER BY COUNT(subj_uri) DESC, timestamp DESC",
+			" GROUP BY subj_uri ORDER BY COUNT(subj_uri) ASC, timestamp ASC",
+			" GROUP BY actor ORDER BY COUNT(actor) DESC, timestamp DESC", 
+			" GROUP BY actor ORDER BY COUNT(actor) ASC, timestamp ASC",
+			" GROUP BY actor ORDER BY timestamp DESC",
+			" GROUP BY actor ORDER BY timestamp ASC",
+			" 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]
 		
 		if max_events > 0:
 			sql += " LIMIT %d" % max_events

=== modified file 'test/data/twenty_events.js'
--- test/data/twenty_events.js	2010-01-20 20:11:54 +0000
+++ test/data/twenty_events.js	2010-07-28 20:12:49 +0000
@@ -281,7 +281,7 @@
 				"uri" : "file:///tmp/foo.txt",
 				"interpretation" : "stfu:Document",
 				"manifestation" : "stfu:File",
-				"origin" : "file:///tmp",
+				"origin" : "file:///home",
 				"mimetype" : "text/plain",
 				"text" : "this item has not text... rly!",
 				"storage" : "368c991f-8b59-4018-8130-3ce0ec944157"
@@ -297,7 +297,7 @@
 				"uri" : "file:///tmp/foo.txt",
 				"interpretation" : "stfu:Document",
 				"manifestation" : "stfu:File",
-				"origin" : "file:///tmp",
+				"origin" : "file:///home",
 				"mimetype" : "text/plain",
 				"text" : "this item has not text... rly!",
 				"storage" : "368c991f-8b59-4018-8130-3ce0ec944157"
@@ -313,7 +313,7 @@
 				"uri" : "file:///tmp/foo.txt",
 				"interpretation" : "stfu:Document",
 				"manifestation" : "stfu:File",
-				"origin" : "file:///tmp",
+				"origin" : "file:///etc",
 				"mimetype" : "text/plain",
 				"text" : "this item has not text... rly!",
 				"storage" : "368c991f-8b59-4018-8130-3ce0ec944157"

=== modified file 'test/engine-test.py'
--- test/engine-test.py	2010-07-28 12:50:05 +0000
+++ test/engine-test.py	2010-07-28 20:12:49 +0000
@@ -540,6 +540,15 @@
 		self.assertEquals([e[0][4] for e in events], ["firefox", "icedove",
 			"frobnicator"])
 		self.assertEquals([e[0][1] for e in events], ["119", "114", "105"])
+	
+	def testResultTypesMostPopularActor2(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		events = self.engine.find_events(
+			TimeRange(105,107), [], StorageState.Any, 0, ResultType.MostPopularActor)
+		self.assertEquals(len(events), 2)
+		self.assertEquals([e[0][4] for e in events], ["firefox", "frobnicator"])
+		self.assertEquals([e[0][1] for e in events], ["107", "105"])
 
 	def testResultTypesLeastPopularActor(self):
 		import_events("test/data/twenty_events.js", self.engine)
@@ -550,6 +559,7 @@
 			"firefox"])
 		self.assertEquals([e[0][1] for e in events], ["105", "114", "119"])
 
+<<<<<<< TREE
 	def testResultTypesMostPopularSubject(self):
 		import_events("test/data/five_events.js", self.engine)
 		
@@ -564,12 +574,30 @@
 			TimeRange.always(), [], StorageState.Any, 0, ResultType.LeastPopularSubjects)
 		self.assertEquals(events, [1, 4, 5, 3])
 	
+=======
+	def testResultTypesLeastPopularActor2(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		events = self.engine.find_events(
+			TimeRange(105,107), [], StorageState.Any, 0, ResultType.LeastPopularActor)
+		self.assertEquals(len(events), 2)
+		self.assertEquals([e[0][4] for e in events], ["frobnicator", "firefox"])
+		self.assertEquals([e[0][1] for e in events], ["105", "107"])
+
+>>>>>>> MERGE-SOURCE
 	def testResultTypesMostRecentActor(self):
 		import_events("test/data/twenty_events.js", self.engine)
 		
 		events = self.engine.find_events(
 			TimeRange.always(), [], StorageState.Any, 0, ResultType.MostRecentActor)
 		self.assertEquals([e[0][1] for e in events], ["119", "114", "105"])
+	
+	def testResultTypesMostRecentActor2(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		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 testResultTypesLeastRecentActor(self):
 		import_events("test/data/twenty_events.js", self.engine)
@@ -578,6 +606,38 @@
 			TimeRange.always(), [], StorageState.Any, 0, ResultType.LeastRecentActor)
 		self.assertEquals([e[0][1] for e in events], ["100", "101", "105"])
 
+	def testResultTypesMostPopularOrigin(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		events = self.engine.find_events(
+			TimeRange.always(), [], StorageState.Any, 0, ResultType.MostPopularOrigin)
+		self.assertEquals([e[1][0][3] for e in events], ["file:///tmp", "file:///home",
+			"file:///etc"])
+		self.assertEquals([e[0][1] for e in events], ["116", "118", "119"])
+
+	def testResultTypesLeastPopularOrigin(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		events = self.engine.find_events(
+			TimeRange.always(), [], StorageState.Any, 0, ResultType.LeastPopularOrigin)
+		self.assertEquals([e[1][0][3] for e in events], ["file:///etc", "file:///home",
+			"file:///tmp"])
+		self.assertEquals([e[0][1] for e in events], ["119", "118", "116"])
+
+	def testResultTypesMostRecentOrigin(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		events = self.engine.find_events(
+			TimeRange.always(), [], StorageState.Any, 0, ResultType.MostRecentOrigin)
+		self.assertEquals([e[0][1] for e in events], ["119", "118", "116"])
+
+	def testResultTypesLeastRecentOrigin(self):
+		import_events("test/data/twenty_events.js", self.engine)
+		
+		events = self.engine.find_events(
+			TimeRange.always(), [], StorageState.Any, 0, ResultType.LeastRecentOrigin)
+		self.assertEquals([e[0][1] for e in events], ["116", "118", "119"])
+
 	def testRelatedForEventsSortRelevancy(self):
 		import_events("test/data/apriori_events.js", self.engine)
 		result = self.engine.find_related_uris(

=== modified file 'zeitgeist/datamodel.py'
--- zeitgeist/datamodel.py	2010-06-09 09:50:05 +0000
+++ zeitgeist/datamodel.py	2010-07-28 20:12:49 +0000
@@ -475,7 +475,7 @@
 		:param uri: The URI of the subject. Eg. *file:///tmp/ratpie.txt*
 		:param interpretation: The interpretation type of the subject, given either as a string URI or as a :class:`Interpretation` instance
 		:param manifestation: The manifestation type of the subject, given either as a string URI or as a :class:`Manifestation` instance
-		:param origin: The URI of the location where subject resides or can be said to originate from
+		:param origin: The URI of the location where subject resides or can be found
 		:param mimetype: The mimetype of the subject encoded as a string, if applicable. Eg. *text/plain*.
 		:param text: Free form textual annotation of the subject.
 		:param storage: String identifier for the storage medium of the subject. This should be the UUID of the volume or the string "net" for resources requiring a network interface, and the string "deleted" for subjects that are deleted.
@@ -515,7 +515,7 @@
 	def set_origin(self, value):
 		self[Subject.Origin] = value
 	origin = property(get_origin, set_origin,
-	doc="Read/write property with the URI of the location where the subject resides or where it can be said to originate from")
+	doc="Read/write property with the URI of the location where the subject can be found. For files this is the parent directory, or for downloaded files it would be the URL of the page where you clicked the download link")
 		
 	def get_mimetype(self):
 		return self[Subject.Mimetype]
@@ -963,13 +963,19 @@
 	MostPopularSubjects = enum_factory(("One event for each subject only, "
 		"ordered by the popularity of the subject"))
 	LeastPopularSubjects = enum_factory(("One event for each subject only, "
-		"ordered ascendently by popularity"))
+		"ordered ascendingly by popularity"))
 	MostPopularActor = enum_factory(("The last event of each different actor,"
 		"ordered by the popularity of the actor"))
 	LeastPopularActor = enum_factory(("The last event of each different actor,"
-		"ordered ascendently by the popularity of the 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"))
+	LeastRecentActor = enum_factory(("The first 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"))
 
 
 INTERPRETATION_DOC = \

_______________________________________________
Mailing list: https://launchpad.net/~zeitgeist
Post to     : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp

Reply via email to