[tracker] tracker-needle: Order results properly
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-needle: Order results properly
- Date: Tue, 6 Mar 2012 17:10:13 +0000 (UTC)
commit 9dd59d0a2ac1da47954f1cd91e4d741f4d47e2ee
Author: Martyn Russell <martyn lanedo com>
Date: Tue Mar 6 17:08:48 2012 +0000
tracker-needle: Order results properly
Now results are ordered by the last changed dates or titles nicely.
Fixes GB#37899.
src/tracker-needle/tracker-query.vala | 57 +++++++++++++++++++++++++++++++--
1 files changed, 54 insertions(+), 3 deletions(-)
---
diff --git a/src/tracker-needle/tracker-query.vala b/src/tracker-needle/tracker-query.vala
index cfc9755..6e2e73f 100644
--- a/src/tracker-needle/tracker-query.vala
+++ b/src/tracker-needle/tracker-query.vala
@@ -169,6 +169,41 @@ public class Tracker.Query {
}"
};
+ private string [] sort_clauses = {
+ // ALL
+ "DESC(nfo:fileLastModified(?urn)) DESC(nie:contentCreated(?urn)) ASC(nie:title(?urn))",
+
+ // CONTACTS
+ "ASC(nco:fullname(?urn))",
+
+ // APPLICATIONS
+ "ASC(nie:title(?urn)) ASC(nie:comment(?urn))",
+
+ // MUSIC
+ "DESC(nfo:fileLastModified(?urn)) ASC(nie:title(?urn))",
+
+ // IMAGES
+ "DESC(nfo:fileLastModified(?urn)) ASC(nie:title(?urn))",
+
+ // VIDEOS
+ "DESC(nfo:fileLastModified(?urn)) ASC(nie:title(?urn))",
+
+ // DOCUMENTS
+ "DESC(nfo:fileLastModified(?urn)) ASC(nie:title(?urn))",
+
+ // MAIL
+ "DESC(nmo:receivedDate(?urn)) ASC(nmo:messageSubject(?urn))",
+
+ // CALENDAR
+ "DESC(nie:contentCreated(?urn))",
+
+ // FOLDERS
+ "DESC(nfo:fileLastModified(?urn)) ASC(nie:title(?urn))",
+
+ // BOOKMARKS
+ "DESC(nie:contentLastModified(?urn)) ASC(nie:title(?urn))"
+ };
+
public string criteria { get; set; }
public uint offset { get; set; }
public uint limit { get; set; }
@@ -270,7 +305,15 @@ public class Tracker.Query {
}
}
- query = "SELECT count(?urn) " + where_clauses[query_type].printf (match);
+ query = "SELECT count(?urn)";
+
+ if (where_clauses[query_type].length > 0) {
+ query += " " + where_clauses[query_type].printf (match);
+ }
+
+ if (sort_clauses[query_type].length > 0) {
+ query += " ORDER BY " + sort_clauses[query_type];
+ }
try {
cursor = yield connection.query_async (query, null);
@@ -330,8 +373,16 @@ public class Tracker.Query {
}
}
- query = "SELECT " + string.joinv (" ", args) + " " + where_clauses[query_type].printf (match);
- query += @" OFFSET $offset LIMIT $limit";
+ query = "SELECT " + string.joinv (" ", args);
+ if (where_clauses[query_type].length > 0) {
+ query += " " + where_clauses[query_type].printf (match);
+ }
+
+ if (sort_clauses[query_type].length > 0) {
+ query += " ORDER BY " + sort_clauses[query_type];
+ }
+
+ query += " OFFSET %u LIMIT %u".printf (offset, limit);
debug ("Running query: '%s'", query);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]