From 840178b6aef3b153620375bff6035356a9b1132c Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sat, 4 Jan 2020 15:58:25 -0800 Subject: [PATCH] Identify which faces need to have distances calculated Signed-off-by: James Ketrenos --- server/face-recognizer.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server/face-recognizer.js b/server/face-recognizer.js index 5409430..2b167d4 100644 --- a/server/face-recognizer.js +++ b/server/face-recognizer.js @@ -143,6 +143,27 @@ faceapi.nets.ssdMobilenetv1.loadFromDisk('./models') concurrency: maxConcurrency }); }); + }).then(() => { + console.log("Looking for face distances that need to be updated."); + + return photoDB.sequelize.query("SELECT id FROM faces ORDER BY id DESC LIMIT 1", { + type: photoDB.sequelize.QueryTypes.SELECT + } + }).then((results) => { + if (!results.length) { + console.log("No faces exist yet to generate distances."); + return; + } + const maxId = results[0].id; + return photoDB.sequelize.query("SELECT id FROM faces WHERE lastComparedId<:maxId OR lastComparedId IS NULL", { + replacements: { + maxId: maxId + }, + type: photoDB.sequelize.QueryTypes.SELECT + }).then((results) => { + console.log(`${results.length} faces need to be updated.`); + }); + }); }).then(() => { console.log("Face detection scanning completed."); }).catch((error) => {