Merge lp:~rainct/zeitgeist/ignore-ubuntuone-actor into lp:~zeitgeist/zeitgeist/bluebird

Proposed by Siegfried Gevatter
Status: Merged
Approved by: Michal Hruby
Approved revision: 459
Merged at revision: 459
Proposed branch: lp:~rainct/zeitgeist/ignore-ubuntuone-actor
Merge into: lp:~zeitgeist/zeitgeist/bluebird
Diff against target: 171 lines (+83/-6)
4 files modified
extensions/fts++/controller.cpp (+15/-1)
extensions/fts++/indexer.cpp (+17/-0)
extensions/fts++/indexer.h (+3/-1)
extensions/fts++/test/test-indexer.cpp (+48/-4)
To merge this branch: bzr merge lp:~rainct/zeitgeist/ignore-ubuntuone-actor
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+99986@code.launchpad.net

Description of the change

<mhr3_> ok, so it seems we decided to skip the u1 events when indexing
<mhr3_> (they can be uniquely identified by actor)

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Can we add an envvar which would control the ignoring (ignore by default)? Plus can we change the primary template when doing reindex, so we don't grab the U1 events in the first place?

review: Needs Fixing
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

8 + // Blacklist Ubuntu One events...
9 + const gchar *actor;
10 + actor = zeitgeist_event_get_actor (event);
11 + if (strcmp(actor, "dbus://com.ubuntuone.SyncDaemon.service") == 0)
12 + return;
13 + if (strcmp(actor, "dbus://org.desktopcouch.CouchDB.service") == 0)
14 + return;

Can we move this out into a separate function, to make this hack less impacting on the main codepath?

Ala if (CheckEventBlacklisted(event)) return;

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Another benefit of a separate function is also that we can unit test the function directly as well.

458. By Siegfried Gevatter

FTS++: Ubuntu One events blacklist:
 - Move blacklist check to separate function.
 - Exclude blacklisted events from the Zeitgeist query when reindexing.
 - Add environment variable to disable blacklisting.

459. By Siegfried Gevatter

Bump FTS++ index version.

Revision history for this message
Michal Hruby (mhr3) wrote :

Great job as always, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/fts++/controller.cpp'
--- extensions/fts++/controller.cpp 2012-03-26 15:09:54 +0000
+++ extensions/fts++/controller.cpp 2012-04-03 19:08:21 +0000
@@ -39,9 +39,23 @@
39 GError *error = NULL;39 GError *error = NULL;
40 guint32 *event_ids;40 guint32 *event_ids;
41 gint event_ids_size;41 gint event_ids_size;
42 GPtrArray *templates = g_ptr_array_new ();42 GPtrArray *templates = g_ptr_array_new_with_free_func (g_object_unref);
43 ZeitgeistEvent *event;
43 ZeitgeistTimeRange *time_range = zeitgeist_time_range_new_anytime ();44 ZeitgeistTimeRange *time_range = zeitgeist_time_range_new_anytime ();
4445
46 if (g_getenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST") == NULL)
47 {
48 // Blacklist Ubuntu One events...
49
50 event = zeitgeist_event_new ();
51 zeitgeist_event_set_actor (event, "!dbus://com.ubuntuone.SyncDaemon.service");
52 g_ptr_array_add (templates, event);
53
54 event = zeitgeist_event_new ();
55 zeitgeist_event_set_actor (event, "!dbus://org.desktopcouch.CouchDB.service");
56 g_ptr_array_add (templates, event);
57 }
58
45 g_debug ("asking reader for all events");59 g_debug ("asking reader for all events");
46 event_ids = zeitgeist_db_reader_find_event_ids (zg_reader,60 event_ids = zeitgeist_db_reader_find_event_ids (zg_reader,
47 time_range,61 time_range,
4862
=== modified file 'extensions/fts++/indexer.cpp'
--- extensions/fts++/indexer.cpp 2012-03-26 16:43:07 +0000
+++ extensions/fts++/indexer.cpp 2012-04-03 19:08:21 +0000
@@ -1301,8 +1301,25 @@
1301 g_assert (digest_size == NULL || *digest_size == HASH_LENGTH);1301 g_assert (digest_size == NULL || *digest_size == HASH_LENGTH);
1302}1302}
13031303
1304static bool
1305CheckEventBlacklisted (ZeitgeistEvent *event)
1306{
1307 // Blacklist Ubuntu One events...
1308 const gchar *actor;
1309 actor = zeitgeist_event_get_actor (event);
1310 if (g_strcmp0(actor, "dbus://com.ubuntuone.SyncDaemon.service") == 0)
1311 return true;
1312 if (g_strcmp0(actor, "dbus://org.desktopcouch.CouchDB.service") == 0)
1313 return true;
1314
1315 return false;
1316}
1317
1304void Indexer::IndexEvent (ZeitgeistEvent *event)1318void Indexer::IndexEvent (ZeitgeistEvent *event)
1305{1319{
1320 if (blacklisting_enabled and CheckEventBlacklisted (event))
1321 return;
1322
1306 try1323 try
1307 {1324 {
1308 const gchar *val;1325 const gchar *val;
13091326
=== modified file 'extensions/fts++/indexer.h'
--- extensions/fts++/indexer.h 2012-03-19 21:42:52 +0000
+++ extensions/fts++/indexer.h 2012-04-03 19:08:21 +0000
@@ -29,7 +29,7 @@
2929
30namespace ZeitgeistFTS {30namespace ZeitgeistFTS {
3131
32const std::string INDEX_VERSION = "3";32const std::string INDEX_VERSION = "4";
3333
34class Indexer34class Indexer
35{35{
@@ -48,6 +48,7 @@
48 {48 {
49 const gchar *home_dir = g_get_home_dir ();49 const gchar *home_dir = g_get_home_dir ();
50 home_dir_path = home_dir != NULL ? home_dir : "/home";50 home_dir_path = home_dir != NULL ? home_dir : "/home";
51 blacklisting_enabled = g_getenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST") == NULL;
51 }52 }
5253
53 ~Indexer ()54 ~Indexer ()
@@ -129,6 +130,7 @@
129130
130 guint clear_failed_id;131 guint clear_failed_id;
131 std::string home_dir_path;132 std::string home_dir_path;
133 bool blacklisting_enabled;
132};134};
133135
134}136}
135137
=== modified file 'extensions/fts++/test/test-indexer.cpp'
--- extensions/fts++/test/test-indexer.cpp 2012-03-20 12:25:59 +0000
+++ extensions/fts++/test/test-indexer.cpp 2012-04-03 19:08:21 +0000
@@ -270,6 +270,15 @@
270 return event;270 return event;
271}271}
272272
273static void
274process_pending (Fixture *fix)
275{
276 while (zeitgeist_indexer_has_pending_tasks (fix->indexer))
277 {
278 zeitgeist_indexer_process_task (fix->indexer);
279 }
280}
281
273// Steals the event, ref it if you want to keep it282// Steals the event, ref it if you want to keep it
274static guint283static guint
275index_event (Fixture *fix, ZeitgeistEvent *event)284index_event (Fixture *fix, ZeitgeistEvent *event)
@@ -295,10 +304,7 @@
295 zeitgeist_indexer_index_events (fix->indexer, events);304 zeitgeist_indexer_index_events (fix->indexer, events);
296 g_ptr_array_unref (events);305 g_ptr_array_unref (events);
297306
298 while (zeitgeist_indexer_has_pending_tasks (fix->indexer))307 process_pending (fix);
299 {
300 zeitgeist_indexer_process_task (fix->indexer);
301 }
302308
303 // sleep for 1 msec to make sure the next event will have a309 // sleep for 1 msec to make sure the next event will have a
304 // different timestamp310 // different timestamp
@@ -1074,6 +1080,42 @@
1074 assert_nth_result_has_id (results, 2, event_id6);1080 assert_nth_result_has_id (results, 2, event_id6);
1075}1081}
10761082
1083static void
1084test_index_ignore_ubuntu_one (Fixture *fix, gconstpointer data)
1085{
1086 guint matches;
1087 ZeitgeistEvent *event;
1088 GPtrArray *results;
1089
1090 // add test events to DBs
1091 index_event (fix, create_test_event_simple ("ubuntuone:uuid", "failme"));
1092 event = create_test_event_simple ("file:///nice%20uri", "failme");
1093 zeitgeist_event_set_actor (event, "dbus://com.ubuntuone.SyncDaemon.service");
1094 index_event (fix, event);
1095
1096 results = search_simple (fix, "failme", NULL,
1097 ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches);
1098
1099 g_assert_cmpuint (results->len, ==, 0);
1100
1101 // disabling blacklisting
1102 g_setenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST", "1", true);
1103
1104 // create a new FTS instance
1105 zeitgeist_indexer_free (fix->indexer);
1106 GError *error = NULL;
1107 fix->indexer = zeitgeist_indexer_new (fix->db, &error);
1108 g_assert (error == NULL);
1109
1110 // wait for it to rebuild the index
1111 process_pending (fix);
1112
1113 results = search_simple (fix, "failme", NULL,
1114 ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches);
1115
1116 g_assert_cmpuint (results->len, ==, 1); // we still don't want ubuntuone:uuid
1117}
1118
1077G_BEGIN_DECLS1119G_BEGIN_DECLS
10781120
1079static void discard_message (const gchar *domain,1121static void discard_message (const gchar *domain,
@@ -1138,6 +1180,8 @@
1138 g_test_add ("/Zeitgeist/FTS/Indexer/Query/MostPopularSubjects", Fixture, 0,1180 g_test_add ("/Zeitgeist/FTS/Indexer/Query/MostPopularSubjects", Fixture, 0,
1139 setup, test_query_most_popular_subjects, teardown);1181 setup, test_query_most_popular_subjects, teardown);
1140 */1182 */
1183 g_test_add ("/Zeitgeist/FTS/Indexer/Index/IgnoreUbuntuOne", Fixture, 0,
1184 setup, test_index_ignore_ubuntu_one, teardown);
11411185
1142 // get rid of the "rebuilding index..." messages1186 // get rid of the "rebuilding index..." messages
1143 g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, discard_message, NULL);1187 g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, discard_message, NULL);

Subscribers

People subscribed via source and target branches