Siegfried Gevatter has proposed merging lp:~rainct/zeitgeist/fts-current-uri 
into lp:zeitgeist.

Requested reviews:
  Michal Hruby (mhr3)

For more details, see:
https://code.launchpad.net/~rainct/zeitgeist/fts-current-uri/+merge/97655
-- 
https://code.launchpad.net/~rainct/zeitgeist/fts-current-uri/+merge/97655
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
=== modified file 'extensions/fts++/indexer.cpp'
--- extensions/fts++/indexer.cpp	2012-03-14 12:31:51 +0000
+++ extensions/fts++/indexer.cpp	2012-03-15 13:47:33 +0000
@@ -1259,7 +1259,6 @@
 {
   try
   {
-    // FIXME: we need to special case MOVE_EVENTs
     const gchar *val;
     guint event_id = zeitgeist_event_get_id (event);
     g_return_if_fail (event_id > 0);
@@ -1288,7 +1287,13 @@
       ZeitgeistSubject *subject;
       subject = (ZeitgeistSubject*) g_ptr_array_index (subjects, i);
 
-      val = zeitgeist_subject_get_uri (subject);
+      // We use current_uri (vs. uri) where since we care about real stuff,
+      // not whatever happened some time ago.
+      //
+      // This will most likely still be the same as URI (unless something
+      // triggers a reindexation of the DB), but at least MOVE_EVENTS
+      // will have the updated URI.
+      val = zeitgeist_subject_get_current_uri (subject);
       if (val == NULL || val[0] == '\0') continue;
 
       std::string uri(val);

=== modified file 'extensions/fts++/test/test-indexer.cpp'
--- extensions/fts++/test/test-indexer.cpp	2012-03-14 15:47:20 +0000
+++ extensions/fts++/test/test-indexer.cpp	2012-03-15 13:47:33 +0000
@@ -203,6 +203,27 @@
   return event;
 }
 
+static ZeitgeistEvent* create_test_event8 (void)
+{
+  ZeitgeistEvent *event = zeitgeist_event_new ();
+  ZeitgeistSubject *subject = zeitgeist_subject_new ();
+  
+  zeitgeist_subject_set_interpretation (subject, ZEITGEIST_NFO_PRESENTATION);
+  zeitgeist_subject_set_manifestation (subject, ZEITGEIST_NFO_FILE_DATA_OBJECT);
+  zeitgeist_subject_set_uri (subject, "file:///home/username/Documents/my_fabulous_presentation.pdf");
+  zeitgeist_subject_set_current_uri (subject, "file:///home/username/Awesome.pdf");
+  zeitgeist_subject_set_text (subject, NULL);
+  zeitgeist_subject_set_mimetype (subject, "application/pdf");
+
+  zeitgeist_event_set_interpretation (event, ZEITGEIST_ZG_MOVE_EVENT);
+  zeitgeist_event_set_manifestation (event, ZEITGEIST_ZG_USER_ACTIVITY);
+  zeitgeist_event_set_actor (event, "application://nautilus.desktop");
+  zeitgeist_event_add_subject (event, subject);
+
+  g_object_unref (subject);
+  return event;
+}
+
 // Steals the event, ref it if you want to keep it
 static guint
 index_event (Fixture *fix, ZeitgeistEvent *event)
@@ -838,6 +859,36 @@
       zeitgeist_event_get_id ((ZeitgeistEvent*) results->pdata[0]));
 }
 
+static void
+test_simple_move_event (Fixture *fix, gconstpointer data)
+{
+  guint matches;
+  guint event_id;
+  ZeitgeistEvent* event;
+ 
+  // add test events to DBs
+  index_event (fix, create_test_event1 ());
+  index_event (fix, create_test_event4 ());
+  event_id = index_event (fix, create_test_event8 ());
+
+  GPtrArray *results =
+    zeitgeist_indexer_search (fix->indexer,
+                              "awesome",
+                              zeitgeist_time_range_new_anytime (),
+                              g_ptr_array_new (),
+                              0,
+                              10,
+                              ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS,
+                              &matches,
+                              NULL);
+
+  g_assert_cmpuint (matches, >, 0);
+  g_assert_cmpuint (results->len, ==, 1);
+
+  event = (ZeitgeistEvent*) results->pdata[0];
+  g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id);
+}
+
 G_BEGIN_DECLS
 
 static void discard_message (const gchar *domain,
@@ -881,6 +932,8 @@
               setup, test_simple_relevancies_query, teardown);
   g_test_add ("/Zeitgeist/FTS/Indexer/RelevanciesSubject", Fixture, 0,
               setup, test_simple_relevancies_subject_query, teardown);
+  g_test_add ("/Zeitgeist/FTS/Indexer/MoveEvent", Fixture, 0,
+              setup, test_simple_move_event, teardown);
 
   // get rid of the "rebuilding index..." messages
   g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, discard_message, NULL);

_______________________________________________
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