You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-11-29 22:48:28 +02:00
fix leap year searching and tests. small metadatabuffer size optimization.
This commit is contained in:
@@ -115,16 +115,36 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => {
|
||||
subDir2 = TestHelper.getDirectoryEntry(directory, 'Return of the Jedi');
|
||||
p = TestHelper.getPhotoEntry1(directory);
|
||||
p.metadata.creationDate = Date.now();
|
||||
p.metadata.creationDateOffset = "+02:00";
|
||||
p2 = TestHelper.getPhotoEntry2(directory);
|
||||
p2.metadata.creationDate = Date.now() - 60 * 60 * 24 * 1000;
|
||||
p2.metadata.creationDateOffset = "+02:00";
|
||||
v = TestHelper.getVideoEntry1(directory);
|
||||
v.metadata.creationDate = Date.now() - 60 * 60 * 24 * 7 * 1000;
|
||||
v.metadata.creationDateOffset = "+02:00";
|
||||
gpx = TestHelper.getRandomizedGPXEntry(directory);
|
||||
p4 = TestHelper.getPhotoEntry4(subDir2);
|
||||
p4.metadata.creationDate = Date.now() - 60 * 60 * 24 * 366 * 1000;
|
||||
let d = new Date();
|
||||
//set creation date to one year and one day earlier
|
||||
p4.metadata.creationDate = d.getTime() - 60 * 60 * 24 * (Utils.isDateFromLeapYear(d) ? 367 : 366) * 1000;
|
||||
p4.metadata.creationDateOffset = "+02:00";
|
||||
const pFaceLessTmp = TestHelper.getPhotoEntry3(subDir);
|
||||
delete pFaceLessTmp.metadata.faces;
|
||||
pFaceLessTmp.metadata.creationDate = Date.now() - 60 * 60 * 24 * 32 * 1000;
|
||||
d = new Date();
|
||||
//we create a date 1 month and 1 day before now
|
||||
if ([1, 3, 5, 7, 8, 10, 0].includes(d.getMonth())) {
|
||||
//Now is a month after a long month: feb (1), april (3), june (5), august(7), september(8), november (10), january (0)
|
||||
pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 32 * 1000;
|
||||
} else if (d.getMonth() == 2 && Utils.isDateFromLeapYear(d)) {
|
||||
//march on leap years
|
||||
pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 30 * 1000;
|
||||
} else if (d.getMonth() == 2) {
|
||||
//march (and not leap years)
|
||||
pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 29 * 1000;
|
||||
} else { //all other months must come after a short month with 30 days, so we subtract 31
|
||||
pFaceLessTmp.metadata.creationDate = d.getTime() - 60 * 60 * 24 * 31 * 1000;
|
||||
}
|
||||
pFaceLessTmp.metadata.creationDateOffset = "+02:00";
|
||||
|
||||
dir = await DBTestHelper.persistTestDir(directory);
|
||||
subDir = dir.directories[0];
|
||||
@@ -937,13 +957,16 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => {
|
||||
await setUpSqlDB();
|
||||
p5 = TestHelper.getBasePhotoEntry(subDir2, 'p5-23h-ago.jpg');
|
||||
p5.metadata.creationDate = Date.now() - 60 * 60 * 24 * 1000 - 1000;
|
||||
//p5.metadata.creationDateOffset = "+02:00";
|
||||
p6 = TestHelper.getBasePhotoEntry(subDir2, 'p6-300d-ago.jpg');
|
||||
p6.metadata.creationDate = Date.now() - 60 * 60 * 24 * 300 * 1000;
|
||||
//p6.metadata.creationDateOffset = "+02:00";
|
||||
p7 = TestHelper.getBasePhotoEntry(subDir2, 'p7-1y-1min-ago.jpg');
|
||||
const d = new Date();
|
||||
d.setUTCFullYear(d.getUTCFullYear() - 1);
|
||||
d.setUTCMinutes(d.getUTCMinutes() - 1);
|
||||
p7.metadata.creationDate = d.getTime();
|
||||
//p7.metadata.creationDateOffset = "+02:00";
|
||||
|
||||
subDir2 = await DBTestHelper.persistTestDir(subDir2) as any;
|
||||
p4 = subDir2.media[0];
|
||||
|
||||
Reference in New Issue
Block a user