← Back to team overview

zeitgeist team mailing list archive

[Branch ~zeitgeist/zeitgeist/bluebird] Rev 428: FTS++: Log `current_uri' instead of `uri'

 

------------------------------------------------------------
revno: 428
committer: Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
branch nick: bluebird
timestamp: Thu 2012-03-15 14:39:43 +0100
message:
  FTS++: Log `current_uri' instead of `uri'
modified:
  extensions/fts++/indexer.cpp
  extensions/fts++/test/test-indexer.cpp


--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird

Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== 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:39:43 +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:39:43 +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);