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
1=== modified file 'extensions/fts++/controller.cpp'
2--- extensions/fts++/controller.cpp 2012-03-26 15:09:54 +0000
3+++ extensions/fts++/controller.cpp 2012-04-03 19:08:21 +0000
4@@ -39,9 +39,23 @@
5 GError *error = NULL;
6 guint32 *event_ids;
7 gint event_ids_size;
8- GPtrArray *templates = g_ptr_array_new ();
9+ GPtrArray *templates = g_ptr_array_new_with_free_func (g_object_unref);
10+ ZeitgeistEvent *event;
11 ZeitgeistTimeRange *time_range = zeitgeist_time_range_new_anytime ();
12
13+ if (g_getenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST") == NULL)
14+ {
15+ // Blacklist Ubuntu One events...
16+
17+ event = zeitgeist_event_new ();
18+ zeitgeist_event_set_actor (event, "!dbus://com.ubuntuone.SyncDaemon.service");
19+ g_ptr_array_add (templates, event);
20+
21+ event = zeitgeist_event_new ();
22+ zeitgeist_event_set_actor (event, "!dbus://org.desktopcouch.CouchDB.service");
23+ g_ptr_array_add (templates, event);
24+ }
25+
26 g_debug ("asking reader for all events");
27 event_ids = zeitgeist_db_reader_find_event_ids (zg_reader,
28 time_range,
29
30=== modified file 'extensions/fts++/indexer.cpp'
31--- extensions/fts++/indexer.cpp 2012-03-26 16:43:07 +0000
32+++ extensions/fts++/indexer.cpp 2012-04-03 19:08:21 +0000
33@@ -1301,8 +1301,25 @@
34 g_assert (digest_size == NULL || *digest_size == HASH_LENGTH);
35 }
36
37+static bool
38+CheckEventBlacklisted (ZeitgeistEvent *event)
39+{
40+ // Blacklist Ubuntu One events...
41+ const gchar *actor;
42+ actor = zeitgeist_event_get_actor (event);
43+ if (g_strcmp0(actor, "dbus://com.ubuntuone.SyncDaemon.service") == 0)
44+ return true;
45+ if (g_strcmp0(actor, "dbus://org.desktopcouch.CouchDB.service") == 0)
46+ return true;
47+
48+ return false;
49+}
50+
51 void Indexer::IndexEvent (ZeitgeistEvent *event)
52 {
53+ if (blacklisting_enabled and CheckEventBlacklisted (event))
54+ return;
55+
56 try
57 {
58 const gchar *val;
59
60=== modified file 'extensions/fts++/indexer.h'
61--- extensions/fts++/indexer.h 2012-03-19 21:42:52 +0000
62+++ extensions/fts++/indexer.h 2012-04-03 19:08:21 +0000
63@@ -29,7 +29,7 @@
64
65 namespace ZeitgeistFTS {
66
67-const std::string INDEX_VERSION = "3";
68+const std::string INDEX_VERSION = "4";
69
70 class Indexer
71 {
72@@ -48,6 +48,7 @@
73 {
74 const gchar *home_dir = g_get_home_dir ();
75 home_dir_path = home_dir != NULL ? home_dir : "/home";
76+ blacklisting_enabled = g_getenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST") == NULL;
77 }
78
79 ~Indexer ()
80@@ -129,6 +130,7 @@
81
82 guint clear_failed_id;
83 std::string home_dir_path;
84+ bool blacklisting_enabled;
85 };
86
87 }
88
89=== modified file 'extensions/fts++/test/test-indexer.cpp'
90--- extensions/fts++/test/test-indexer.cpp 2012-03-20 12:25:59 +0000
91+++ extensions/fts++/test/test-indexer.cpp 2012-04-03 19:08:21 +0000
92@@ -270,6 +270,15 @@
93 return event;
94 }
95
96+static void
97+process_pending (Fixture *fix)
98+{
99+ while (zeitgeist_indexer_has_pending_tasks (fix->indexer))
100+ {
101+ zeitgeist_indexer_process_task (fix->indexer);
102+ }
103+}
104+
105 // Steals the event, ref it if you want to keep it
106 static guint
107 index_event (Fixture *fix, ZeitgeistEvent *event)
108@@ -295,10 +304,7 @@
109 zeitgeist_indexer_index_events (fix->indexer, events);
110 g_ptr_array_unref (events);
111
112- while (zeitgeist_indexer_has_pending_tasks (fix->indexer))
113- {
114- zeitgeist_indexer_process_task (fix->indexer);
115- }
116+ process_pending (fix);
117
118 // sleep for 1 msec to make sure the next event will have a
119 // different timestamp
120@@ -1074,6 +1080,42 @@
121 assert_nth_result_has_id (results, 2, event_id6);
122 }
123
124+static void
125+test_index_ignore_ubuntu_one (Fixture *fix, gconstpointer data)
126+{
127+ guint matches;
128+ ZeitgeistEvent *event;
129+ GPtrArray *results;
130+
131+ // add test events to DBs
132+ index_event (fix, create_test_event_simple ("ubuntuone:uuid", "failme"));
133+ event = create_test_event_simple ("file:///nice%20uri", "failme");
134+ zeitgeist_event_set_actor (event, "dbus://com.ubuntuone.SyncDaemon.service");
135+ index_event (fix, event);
136+
137+ results = search_simple (fix, "failme", NULL,
138+ ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches);
139+
140+ g_assert_cmpuint (results->len, ==, 0);
141+
142+ // disabling blacklisting
143+ g_setenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST", "1", true);
144+
145+ // create a new FTS instance
146+ zeitgeist_indexer_free (fix->indexer);
147+ GError *error = NULL;
148+ fix->indexer = zeitgeist_indexer_new (fix->db, &error);
149+ g_assert (error == NULL);
150+
151+ // wait for it to rebuild the index
152+ process_pending (fix);
153+
154+ results = search_simple (fix, "failme", NULL,
155+ ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches);
156+
157+ g_assert_cmpuint (results->len, ==, 1); // we still don't want ubuntuone:uuid
158+}
159+
160 G_BEGIN_DECLS
161
162 static void discard_message (const gchar *domain,
163@@ -1138,6 +1180,8 @@
164 g_test_add ("/Zeitgeist/FTS/Indexer/Query/MostPopularSubjects", Fixture, 0,
165 setup, test_query_most_popular_subjects, teardown);
166 */
167+ g_test_add ("/Zeitgeist/FTS/Indexer/Index/IgnoreUbuntuOne", Fixture, 0,
168+ setup, test_index_ignore_ubuntu_one, teardown);
169
170 // get rid of the "rebuilding index..." messages
171 g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, discard_message, NULL);

Subscribers

People subscribed via source and target branches