summaryrefslogtreecommitdiff
path: root/src/db/FaceTable.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-14 20:36:17 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-14 20:36:17 +0200
commit31804433d72460cbe0a39f9f8ea5e76058d84cda (patch)
tree2084a84c39f159c6aea254775dc0880d52579d45 /src/db/FaceTable.vala
parenta9898fb3f39c44a85876930ef6b2558052569ae6 (diff)
parentd443a3c2509889533ca812c163056bace396b586 (diff)
Update upstream source from tag 'upstream/0.32.1'
Update to upstream version '0.32.1' with Debian dir c460ad6e13d3c39eaa2d5399059385e64e6fba4c
Diffstat (limited to 'src/db/FaceTable.vala')
-rw-r--r--src/db/FaceTable.vala56
1 files changed, 51 insertions, 5 deletions
diff --git a/src/db/FaceTable.vala b/src/db/FaceTable.vala
index 4836910..e799f97 100644
--- a/src/db/FaceTable.vala
+++ b/src/db/FaceTable.vala
@@ -25,7 +25,9 @@ public struct FaceID {
public class FaceRow {
public FaceID face_id;
public string name;
- public time_t time_created;
+ public int64 time_created;
+ public PhotoID ref;
+ public string vec;
}
public class FaceTable : DatabaseTable {
@@ -40,7 +42,8 @@ public class FaceTable : DatabaseTable {
+ "("
+ "id INTEGER NOT NULL PRIMARY KEY, "
+ "name TEXT NOT NULL, "
- + "time_created TIMESTAMP"
+ + "time_created TIMESTAMP, "
+ + "ref INTEGER DEFAULT -1"
+ ")", -1, out stmt);
assert(res == Sqlite.OK);
@@ -62,7 +65,7 @@ public class FaceTable : DatabaseTable {
out stmt);
assert(res == Sqlite.OK);
- time_t time_created = (time_t) now_sec();
+ var time_created = now_sec();
res = stmt.bind_text(1, name);
assert(res == Sqlite.OK);
@@ -129,7 +132,7 @@ public class FaceTable : DatabaseTable {
FaceRow row = new FaceRow();
row.face_id = face_id;
row.name = stmt.column_text(0);
- row.time_created = (time_t) stmt.column_int64(1);
+ row.time_created = stmt.column_int64(1);
return row;
}
@@ -153,7 +156,7 @@ public class FaceTable : DatabaseTable {
FaceRow row = new FaceRow();
row.face_id = FaceID(stmt.column_int64(0));
row.name = stmt.column_text(1);
- row.time_created = (time_t) stmt.column_int64(2);
+ row.time_created = stmt.column_int64(2);
rows.add(row);
}
@@ -164,4 +167,47 @@ public class FaceTable : DatabaseTable {
public void rename(FaceID face_id, string new_name) throws DatabaseError {
update_text_by_id_2(face_id.id, "name", new_name);
}
+
+ public void set_reference(FaceID face_id, PhotoID photo_id)
+ throws DatabaseError {
+ Sqlite.Statement stmt;
+ int res = db.prepare_v2("UPDATE FaceTable SET ref=? WHERE id=?", -1, out stmt);
+ assert(res == Sqlite.OK);
+ res = stmt.bind_int64(1, photo_id.id);
+ assert(res == Sqlite.OK);
+ res = stmt.bind_int64(2, face_id.id);
+ assert(res == Sqlite.OK);
+
+ res = stmt.step();
+ if (res != Sqlite.DONE)
+ throw_error("FaceTable.set_reference", res);
+ }
+
+ public Gee.List<FaceRow?> get_ref_rows() throws DatabaseError {
+ Sqlite.Statement stmt;
+ int res = db.prepare_v2("SELECT id, name, time_created, ref FROM FaceTable WHERE ref != -1", -1,
+ out stmt);
+ assert(res == Sqlite.OK);
+
+ Gee.List<FaceRow?> rows = new Gee.ArrayList<FaceRow?>();
+
+ for (;;) {
+ res = stmt.step();
+ if (res == Sqlite.DONE)
+ break;
+ else if (res != Sqlite.ROW)
+ throw_error("FaceTable.get_all_rows", res);
+
+ // res == Sqlite.ROW
+ FaceRow row = new FaceRow();
+ row.face_id = FaceID(stmt.column_int64(0));
+ row.name = stmt.column_text(1);
+ row.time_created = stmt.column_int64(2);
+ row.ref = PhotoID(stmt.column_int64(3));
+
+ rows.add(row);
+ }
+
+ return rows;
+ }
}