Fix #9: Restructured a bit of the pendingItems calculation, and the query used in non-memory fetches
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
14f1051f4d
commit
54ed982a42
@ -773,7 +773,10 @@
|
|||||||
triggerLoadMore: function() {
|
triggerLoadMore: function() {
|
||||||
if (this.$.bottom.getBoundingClientRect().bottom < window.innerHeight + 200) {
|
if (this.$.bottom.getBoundingClientRect().bottom < window.innerHeight + 200) {
|
||||||
if (this.pendingPhotos.length) {
|
if (this.pendingPhotos.length) {
|
||||||
|
console.log("At bottom - more items; processItems requested.");
|
||||||
this.async(this.processItems.bind(this));
|
this.async(this.processItems.bind(this));
|
||||||
|
} else {
|
||||||
|
console.log("At bottom - no more items.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -787,12 +790,6 @@
|
|||||||
|
|
||||||
this.triggerLoadMore();
|
this.triggerLoadMore();
|
||||||
|
|
||||||
if (this.$.bottom.getBoundingClientRect().bottom < window.innerHeight + 200) {
|
|
||||||
if (this.pendingPhotos.length) {
|
|
||||||
this.async(this.processItems.bind(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var headerHeight = this.$.header.offsetHeight;
|
var headerHeight = this.$.header.offsetHeight;
|
||||||
|
|
||||||
var i, date = null, top = null, lowest = window.innerHeight;
|
var i, date = null, top = null, lowest = window.innerHeight;
|
||||||
@ -1053,12 +1050,9 @@
|
|||||||
|
|
||||||
photos.forEach(function(photo) {
|
photos.forEach(function(photo) {
|
||||||
var year = (photo.taken || photo.modified || photo.added).replace(/^(....).*$/, "$1");
|
var year = (photo.taken || photo.modified || photo.added).replace(/^(....).*$/, "$1");
|
||||||
for (var i = 0; i < this.years.length; i++) {
|
if (this.years.indexOf(year) == -1) {
|
||||||
if (this.years[i] == year) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.push("years", year);
|
this.push("years", year);
|
||||||
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.pendingPhotos = this.pendingPhotos.concat(photos);
|
this.pendingPhotos = this.pendingPhotos.concat(photos);
|
||||||
@ -1090,6 +1084,7 @@
|
|||||||
|
|
||||||
var photos = this.pendingPhotos.splice(0, 50);
|
var photos = this.pendingPhotos.splice(0, 50);
|
||||||
this.notifyPath("pendingPhotos.length");
|
this.notifyPath("pendingPhotos.length");
|
||||||
|
console.log(this.pendingPhotos.length + " photos remain to be converted to photo-thumbnail");
|
||||||
|
|
||||||
for (var i = 0; i < photos.length; i++) {
|
for (var i = 0; i < photos.length; i++) {
|
||||||
var photo = photos[i], datetime;
|
var photo = photos[i], datetime;
|
||||||
|
@ -62,7 +62,7 @@ app.use(bodyParser.urlencoded({
|
|||||||
|
|
||||||
/* Any path starting with the following won't be logged via morgan */
|
/* Any path starting with the following won't be logged via morgan */
|
||||||
const logSkipPaths = new RegExp("^" + basePath + "(" + [
|
const logSkipPaths = new RegExp("^" + basePath + "(" + [
|
||||||
".*\/thumbs\/",
|
".*thumbs\\/",
|
||||||
"bower_components",
|
"bower_components",
|
||||||
].join(")|(") + ")");
|
].join(")|(") + ")");
|
||||||
app.use(morgan('common', {
|
app.use(morgan('common', {
|
||||||
|
@ -480,16 +480,17 @@ router.get("/*", function(req, res/*, next*/) {
|
|||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
index = "";
|
index = "";
|
||||||
} else {
|
} else {
|
||||||
index = "AND ((strftime('%Y-%m-%d',taken)=strftime('%Y-%m-%d',:cursor) AND photos.id<"+id+ ") OR " +
|
index = "AND ((strftime('%Y-%m-%d',taken)=strftime('%Y-%m-%d',:cursor) AND photos.id<:id) OR " +
|
||||||
"(strftime('%m-%d',taken)=strftime('%m-%d',:cursor) AND strftime('%Y',taken)<strftime('%Y',:cursor)))";
|
"strftime('%Y-%m-%d',taken)<strftime('%Y-%m-%d',:cursor))";
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = decodeURI(req.url).replace(/\?.*$/, "").replace(/^\//, ""),
|
let path = decodeURI(req.url).replace(/\?.*$/, "").replace(/^\//, ""),
|
||||||
query = "SELECT photos.*,albums.path AS path FROM photos " +
|
query = "SELECT photos.*,albums.path AS path FROM photos " +
|
||||||
"INNER JOIN albums ON (albums.id=photos.albumId AND albums.path LIKE :path) " +
|
"INNER JOIN albums ON (albums.id=photos.albumId AND albums.path LIKE :path) " +
|
||||||
"WHERE (photos.duplicate=0 AND photos.deleted=0 AND photos.scanned NOT NULL " + index + ") " +
|
"WHERE (photos.duplicate=0 AND photos.deleted=0 AND photos.scanned NOT NULL) " + index + " " +
|
||||||
"ORDER BY strftime('%Y-%m-%d',taken) DESC,id DESC LIMIT " + (limit + 1),
|
"ORDER BY strftime('%Y-%m-%d',taken) DESC,id DESC LIMIT " + (limit + 1),
|
||||||
replacements = {
|
replacements = {
|
||||||
|
id: id,
|
||||||
cursor: cursor,
|
cursor: cursor,
|
||||||
path: path + "%"
|
path: path + "%"
|
||||||
};
|
};
|
||||||
@ -510,6 +511,8 @@ router.get("/*", function(req, res/*, next*/) {
|
|||||||
|
|
||||||
let more = photos.length > limit; /* We queried one extra item to see if there are more than LIMIT available */
|
let more = photos.length > limit; /* We queried one extra item to see if there are more than LIMIT available */
|
||||||
|
|
||||||
|
// console.log("Requested " + limit + " and matched " + photos.length);
|
||||||
|
|
||||||
let last;
|
let last;
|
||||||
if (more) {
|
if (more) {
|
||||||
photos.splice(limit);
|
photos.splice(limit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user