tracker r1507 - in branches/xesam-support: . data src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1507 - in branches/xesam-support: . data src/trackerd
- Date: Wed, 28 May 2008 09:51:02 +0000 (UTC)
Author: pvanhoof
Date: Wed May 28 09:51:01 2008
New Revision: 1507
URL: http://svn.gnome.org/viewvc/tracker?rev=1507&view=rev
Log:
2008-05-28 Philip Van Hoof <pvanhoof gnome org>
* src/trackerd/tracker-xesam-live-search.c:
* src/trackerd/tracker-db-sqlite.c:
* src/trackerd/tracker-db-sqlite.h:
* data/sqlite-stored-procs.sql:
The initial HitsAdded after a search is activated. Updated the
stored-proc executers to also remove and add items into the
LiveSearches table
New TODO item: we are only detecting the Updates and Deletes for
the live searches, not the creates
Modified:
branches/xesam-support/ChangeLog
branches/xesam-support/data/sqlite-stored-procs.sql
branches/xesam-support/src/trackerd/tracker-db-sqlite.c
branches/xesam-support/src/trackerd/tracker-db-sqlite.h
branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
Modified: branches/xesam-support/data/sqlite-stored-procs.sql
==============================================================================
--- branches/xesam-support/data/sqlite-stored-procs.sql (original)
+++ branches/xesam-support/data/sqlite-stored-procs.sql Wed May 28 09:51:01 2008
@@ -30,6 +30,8 @@
SetEventsBeingHandled UPDATE Events SET BeingHandled = 1;
GetLiveSearchDeletedIDs SELECT E.ServiceID FROM Events as E, LiveSearches as X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType IS 'Delete';
+DeleteLiveSearchDeletedIDs DELETE FROM LiveSearches AS Y WHERE Y.ServiceID IN SELECT ServiceID FROM Events as E, LiveSearches as X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType IS 'Delete'
+
GetLiveSearchHitCount SELECT count(*) FROM LiveSearches WHERE SearchID = ?;
LiveSearchStopSearch DELETE FROM LiveSearches as X WHERE E.SearchID = ?
Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.c Wed May 28 09:51:01 2008
@@ -3316,7 +3316,15 @@
* AND X.SearchID = ?
* AND E.EventType IS 'Delete' */
- return tracker_db_exec_proc (db_con->db, "GetLiveSearchDeletedIDs", search_id, NULL);
+ /* DELETE FROM LiveSearches AS Y WHERE Y.ServiceID IN
+ * SELECT ServiceID FROM Events as E, LiveSearches as X
+ * WHERE E.ServiceID = X.ServiceID
+ * AND X.SearchID = ?
+ * AND E.EventType IS 'Delete' */
+
+ TrackerDBResultSet *result_set = tracker_db_exec_proc (db_con->db, "GetLiveSearchDeletedIDs", search_id, NULL);
+ tracker_exec_proc_no_reply (db_con->db, "DeleteLiveSearchDeletedIDs", search_id, NULL);
+ return result_set;
}
void
@@ -3349,15 +3357,29 @@
TrackerDBResultSet*
tracker_db_get_live_search_new_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *from_query, const gchar *where_query)
{
+ TrackerDBResultSet *result_set;
+
// todo: this is a query for ottela to review
/* Contract, in @result:
* ServiceID is #1
* EventType is #2 */
+ // todo: we will only find updates with this one
/**
* SELECT E.ServiceID, E.EventType, COLUMNS
- * FROM_QUERY XesamLiveSearches as X, Events as E
+ * FROM_QUERY LiveSearches as X, Events as E
+ * WHERE_QUERY"
+ * AND X.ServiceID = E.ServiceID
+ * AND X.SearchID = SEARCH_ID
+ * AND (X.EventType IS 'Create'
+ * OR X.EventType IS 'Update')
+ **/
+
+ // todo: we will only find updates with this one
+ /**
+ * INSERT INTO LiveSearches SELECT E.ServiceID, SEARCH_ID
+ * FROM_QUERY LiveSearches as X, Events as E
* WHERE_QUERY"
* AND X.ServiceID = E.ServiceID
* AND X.SearchID = SEARCH_ID
@@ -3367,7 +3389,7 @@
g_debug("tracker_db_get_live_search_new_ids");
- return tracker_db_exec (db_con->db,
+ result_set = tracker_db_exec (db_con->db,
/* COLUMNS */ "SELECT E.ServiceID, E.EventType%s%s "
/* FROM_QUERY */ "%s%s LiveSearches as X, Events as E "
/* WHERE_QUERY */ "%s"
@@ -3383,6 +3405,58 @@
where_query?where_query:"WHERE",
where_query?"AND":" ",
search_id);
+
+
+ tracker_db_exec_no_reply (db_con->db,
+ "INSERT INTO LiveSearches SELECT E.ServiceID, '%s' "
+ /* FROM_QUERY */ "%s%s LiveSearches as X, Events as E "
+ /* WHERE_QUERY */ "%s"
+ /* AND or space */ "%sX.ServiceID = E.ServiceID "
+ "AND X.SearchID = '%s' " /* search_id arg */
+ "AND (X.EventType IS 'Create' "
+ "OR X.EventType IS 'Update') ",
+ search_id,
+ from_query?from_query:"FROM",
+ from_query?",":"",
+ where_query?where_query:"WHERE",
+ where_query?"AND ":" ",
+ search_id);
+
+ return result_set;
+}
+
+
+TrackerDBResultSet*
+tracker_db_get_live_search_all_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *from_query, const gchar *where_query)
+{
+ // todo: this is a query for ottela to review
+
+ /* Contract, in @result:
+ * ServiceID is #1
+ * EventType is #2 */
+
+ /**
+ * SELECT E.ServiceID, COLUMNS
+ * FROM_QUERY XesamLiveSearches as X
+ * WHERE_QUERY
+ * AND X.SearchID = SEARCH_ID
+ **/
+
+ g_debug("tracker_db_get_live_search_all_ids");
+
+ return tracker_db_exec (db_con->db,
+ /* COLUMNS */ "SELECT E.ServiceID%s%s "
+ /* FROM_QUERY */ "%s%s LiveSearches as X "
+ /* WHERE_QUERY */ "%s"
+ /* AND or space */ "%X.SearchID = '%s' " /* search_id arg */,
+
+ columns?", ":"",
+ columns?columns:"",
+ from_query?from_query:"FROM",
+ from_query?",":"",
+ where_query?where_query:"WHERE",
+ where_query?"AND ":" ",
+ search_id);
}
TrackerDBResultSet *
Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.h (original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.h Wed May 28 09:51:01 2008
@@ -330,6 +330,11 @@
const gchar *columns,
const gchar *tables,
const gchar *query);
+TrackerDBResultSet *tracker_db_get_live_search_all_ids (DBConnection *db_con,
+ const gchar *search_id,
+ const gchar *columns,
+ const gchar *tables,
+ const gchar *query);
TrackerDBResultSet *tracker_db_get_live_search_hit_count (DBConnection *db_con,
const gchar *search_id);
Modified: branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-live-search.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.c Wed May 28 09:51:01 2008
@@ -276,6 +276,47 @@
*modified = m_modified;
}
+
+
+/* Created and Modified items */
+static void
+get_all_hits (TrackerXesamLiveSearch *self, DBConnection *db_con, GArray **hits)
+{
+ GArray *m_hits = NULL;
+ gboolean ls_valid = TRUE;
+ TrackerDBResultSet *result_set;
+
+ result_set = tracker_db_get_live_search_all_ids (db_con,
+ tracker_xesam_live_search_get_id (self),
+ NULL, /* Columns */
+ tracker_xesam_live_search_get_from_query (self),
+ tracker_xesam_live_search_get_where_query (self)); /* Query */
+
+ if (!result_set)
+ return;
+
+ while (ls_valid) {
+ GValue ls_value = { 0, };
+ gint ls_i_value;
+
+ _tracker_db_result_set_get_value (result_set, 0, &ls_value);
+
+ ls_i_value = g_value_get_int (&ls_value);
+
+ if (m_hits == NULL)
+ m_hits = g_array_new (FALSE, TRUE, sizeof (guint32));
+ g_array_append_val (m_hits, ls_i_value);
+
+ g_value_unset (&ls_value);
+
+ ls_valid = tracker_db_result_set_iter_next (result_set);
+ }
+
+ g_object_unref (result_set);
+
+ *hits = m_hits;
+}
+
/**
* tracker_xesam_live_search_match_with_events:
* @self: A #TrackerXesamLiveSearch
@@ -675,7 +716,7 @@
else {
DBConnection *db_con = NULL;
TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
- GArray *added = NULL, *modified = NULL;
+ GArray *hits = NULL;
g_object_get (proxy, "db-connection", &db_con, NULL);
@@ -686,22 +727,14 @@
tracker_xesam_live_search_get_where_query (self),
tracker_xesam_live_search_get_id (self));
- get_hits_added_modified (self, db_con, &added, &modified);
-
- if (added && added->len > 0) {
- tracker_xesam_live_search_emit_hits_added (self, added->len);
- }
-
- if (added) {
- g_array_free (added, TRUE);
- }
+ get_all_hits (self, db_con, &hits);
- if (modified && modified->len > 0) {
- tracker_xesam_live_search_emit_hits_modified (self, modified);
+ if (hits && hits->len > 0) {
+ tracker_xesam_live_search_emit_hits_added (self, hits->len);
}
- if (modified) {
- g_array_free (modified, TRUE);
+ if (hits) {
+ g_array_free (hits, TRUE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]