[tracker] libtracker-data: Add tracker:added property



commit dc893475435887531b64c1379f46db9a7ea05df9
Author: Jürg Billeter <j bitron ch>
Date:   Mon Sep 14 13:26:00 2009 +0200

    libtracker-data: Add tracker:added property
    
    tracker:added is only set once, when the resource is inserted into
    the database, and it will never be changed after that. This property
    can be used to query for recently added files.

 data/ontologies/11-rdf.ontology            |    5 +++++
 src/libtracker-data/tracker-data-manager.c |    2 +-
 src/libtracker-data/tracker-data-update.c  |    5 +++--
 3 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/data/ontologies/11-rdf.ontology b/data/ontologies/11-rdf.ontology
index 717343a..f61e351 100644
--- a/data/ontologies/11-rdf.ontology
+++ b/data/ontologies/11-rdf.ontology
@@ -85,6 +85,11 @@ tracker:transient a rdf:Property ;
 	rdfs:domain rdf:Property ;
 	rdfs:range xsd:boolean .
 
+tracker:added a rdf:Property ;
+	nrl:maxCardinality 1 ;
+	rdfs:domain rdfs:Resource ;
+	rdfs:range xsd:dateTime .
+
 # implicitly updated modification time
 tracker:modified a rdf:Property ;
 	nrl:maxCardinality 1 ;
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index b94c5b9..953a5d8 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -659,7 +659,7 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
 		TrackerDBStatement *stmt;
 
 		stmt = tracker_db_interface_create_statement (iface,
-							      "INSERT OR IGNORE INTO \"rdfs:Resource\" (ID, Uri, \"tracker:modified\") VALUES (?, ?, ?)");
+							      "INSERT OR IGNORE INTO \"rdfs:Resource\" (ID, Uri, \"tracker:added\", \"tracker:modified\") VALUES (?, ?, ?, 0)");
 		tracker_db_statement_bind_int (stmt, 0, ++(*max_id));
 		tracker_db_statement_bind_text (stmt, 1, tracker_class_get_uri (service));
 		tracker_db_statement_bind_int64 (stmt, 2, (gint64) time (NULL));
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 31fb3b8..d527982 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -289,10 +289,11 @@ ensure_resource_id (const gchar *uri)
 		iface = tracker_db_manager_get_db_interface ();
 
 		id = tracker_data_update_get_new_service_id (common);
-		stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"rdfs:Resource\" (ID, Uri, \"tracker:modified\", Available) VALUES (?, ?, ?, 1)");
+		stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"rdfs:Resource\" (ID, Uri, \"tracker:added\", \"tracker:modified\", Available) VALUES (?, ?, ?, ?, 1)");
 		tracker_db_statement_bind_int (stmt, 0, id);
 		tracker_db_statement_bind_text (stmt, 1, uri);
-		tracker_db_statement_bind_int (stmt, 2, tracker_data_update_get_next_modseq ());
+		tracker_db_statement_bind_int64 (stmt, 2, (gint64) time (NULL));
+		tracker_db_statement_bind_int (stmt, 3, tracker_data_update_get_next_modseq ());
 		tracker_db_statement_execute (stmt, NULL);
 		g_object_unref (stmt);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]