Do not scan duplicates or deleted images
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
6c5de402db
commit
756272ea6a
@ -294,7 +294,12 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
}
|
||||
|
||||
window.fetch("api/v1/photos/random" + id)
|
||||
.then(res => res.json()).then(function(data) {
|
||||
.then((res) => {
|
||||
if (res.status >= 400) {
|
||||
throw res.status;
|
||||
}
|
||||
return res.json();
|
||||
}).then(function(data) {
|
||||
info.textContent = "Random photo: " + data.id;
|
||||
photoIndex = 0;
|
||||
photos = [data];
|
||||
|
@ -61,7 +61,7 @@ faceapi.nets.ssdMobilenetv1.loadFromDisk('./models')
|
||||
return photoDB.sequelize.query("SELECT photos.id,photos.filename,photos.width,photos.height,albums.path " +
|
||||
"FROM photos " +
|
||||
"LEFT JOIN albums ON (albums.id=photos.albumId) " +
|
||||
"WHERE faces=-1 AND deleted=0 ORDER BY albums.path,photos.filename", {
|
||||
"WHERE faces=-1 AND photos.duplicate=0 AND photos.deleted=0 ORDER BY albums.path,photos.filename", {
|
||||
type: photoDB.sequelize.QueryTypes.SELECT,
|
||||
raw: true
|
||||
}
|
||||
@ -166,7 +166,7 @@ faceapi.nets.ssdMobilenetv1.loadFromDisk('./models')
|
||||
console.log("Looking for face distances that need to be updated...");
|
||||
const descriptors = {};
|
||||
|
||||
return photoDB.sequelize.query("SELECT id FROM faces ORDER BY id DESC LIMIT 1", {
|
||||
return photoDB.sequelize.query("SELECT faces.id FROM faces ORDER BY faces.id DESC LIMIT 1", {
|
||||
type: photoDB.sequelize.QueryTypes.SELECT,
|
||||
raw: true
|
||||
}).then((results) => {
|
||||
@ -176,9 +176,9 @@ faceapi.nets.ssdMobilenetv1.loadFromDisk('./models')
|
||||
}
|
||||
const maxId = results[0].id;
|
||||
return photoDB.sequelize.query(
|
||||
"SELECT id,lastComparedId " +
|
||||
"FROM faces " +
|
||||
"WHERE lastComparedId<:maxId OR lastComparedId IS NULL", {
|
||||
"SELECT faces.id,faces.lastComparedId " +
|
||||
"FROM faces INNER JOIN photos ON photos.duplicate=0 AND photos.deleted=0 AND photos.id=faces.photoId " +
|
||||
"WHERE faces.lastComparedId<:maxId OR faces.lastComparedId IS NULL", {
|
||||
replacements: {
|
||||
maxId: maxId
|
||||
},
|
||||
|
@ -836,15 +836,18 @@ router.get("/faces/:id", (req, res) => {
|
||||
});
|
||||
|
||||
router.get("/random/:id?", (req, res) => {
|
||||
const id = parseInt(req.params.id);
|
||||
let filter = "";
|
||||
let id = parseInt(req.params.id),
|
||||
filter = "";
|
||||
|
||||
if (id == req.params.id) {
|
||||
console.log("GET /random/" + id);
|
||||
filter = "AND id=:id";
|
||||
} else {
|
||||
filter = "AND faces>0";
|
||||
id = undefined;
|
||||
}
|
||||
return photoDB.sequelize.query("SELECT id FROM photos WHERE deleted=0 " + filter, {
|
||||
|
||||
return photoDB.sequelize.query("SELECT id,duplicate FROM photos WHERE deleted=0 " + filter, {
|
||||
replacements: {
|
||||
id: id
|
||||
},
|
||||
@ -852,9 +855,15 @@ router.get("/random/:id?", (req, res) => {
|
||||
raw: true
|
||||
}).then((results) => {
|
||||
if (!results.length) {
|
||||
return res.status(404);
|
||||
return res.status(404).send(id + " not found.");
|
||||
}
|
||||
if (id) {
|
||||
if (results[0].duplicate) {
|
||||
id = results[0].duplicate;
|
||||
}
|
||||
} else {
|
||||
id = results[Math.floor(Math.random() * results.length)].id;
|
||||
}
|
||||
const id = results[Math.floor(Math.random() * results.length)].id;
|
||||
|
||||
return photoDB.sequelize.query(
|
||||
"SELECT photos.*,albums.path AS path FROM photos " +
|
||||
@ -868,7 +877,7 @@ router.get("/random/:id?", (req, res) => {
|
||||
});
|
||||
}).then(function(photos) {
|
||||
if (!photos.length) {
|
||||
return res.status(404);
|
||||
return res.status(404).send(id + " not found.");
|
||||
}
|
||||
const photo = photos[0];
|
||||
for (var key in photo) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user