Fix recent upload time calculation
This commit is contained in:
parent
6b4c4970a3
commit
5f20bbd0f4
@ -42,10 +42,10 @@ export const NULL_CATEGORY_DATA: CategoryData = {
|
|||||||
export const getDataForCategories = () => Promise.all([
|
export const getDataForCategories = () => Promise.all([
|
||||||
SHOW_RECENTS
|
SHOW_RECENTS
|
||||||
? getPhotosMetaCached({ recent: true })
|
? getPhotosMetaCached({ recent: true })
|
||||||
.then(({ count, dateRange }) => count && dateRange
|
.then(({ count, dateRangeCreatedAt }) => count && dateRangeCreatedAt
|
||||||
? [{
|
? [{
|
||||||
count,
|
count,
|
||||||
lastModified: new Date(dateRange?.end ?? ''),
|
lastModified: new Date(dateRangeCreatedAt?.end ?? ''),
|
||||||
}] : undefined)
|
}] : undefined)
|
||||||
.catch(() => [])
|
.catch(() => [])
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@ -497,8 +497,12 @@ export const getPhotosNearId = async (
|
|||||||
|
|
||||||
export const getPhotosMeta = (options: PhotoQueryOptions = {}) =>
|
export const getPhotosMeta = (options: PhotoQueryOptions = {}) =>
|
||||||
safelyQuery(async () => {
|
safelyQuery(async () => {
|
||||||
// eslint-disable-next-line max-len
|
let sql = `
|
||||||
let sql = 'SELECT COUNT(*), MIN(p.taken_at_naive) as start, MAX(p.taken_at_naive) as end FROM photos p';
|
SELECT COUNT(*),
|
||||||
|
MIN(p.taken_at_naive) as start, MAX(p.taken_at_naive) as end,
|
||||||
|
MIN(p.created_at) as start_created_at, MAX(p.created_at) as end_created_at
|
||||||
|
FROM photos p
|
||||||
|
`;
|
||||||
const joins = getJoinsFromOptions(options);
|
const joins = getJoinsFromOptions(options);
|
||||||
if (joins) { sql += ` ${joins}`; }
|
if (joins) { sql += ` ${joins}`; }
|
||||||
const { wheres, wheresValues } = getWheresFromOptions(options);
|
const { wheres, wheresValues } = getWheresFromOptions(options);
|
||||||
@ -512,6 +516,13 @@ export const getPhotosMeta = (options: PhotoQueryOptions = {}) =>
|
|||||||
end: rows[0].end as string,
|
end: rows[0].end as string,
|
||||||
} as PhotoDateRangePostgres }
|
} as PhotoDateRangePostgres }
|
||||||
: undefined,
|
: undefined,
|
||||||
|
// Used to calculate upload time for 'recents'
|
||||||
|
...rows[0]?.start_created_at && rows[0]?.end_created_at
|
||||||
|
? { dateRangeCreatedAt: {
|
||||||
|
start: rows[0].start_created_at as string,
|
||||||
|
end: rows[0].end_created_at as string,
|
||||||
|
} as PhotoDateRangePostgres }
|
||||||
|
: undefined,
|
||||||
}));
|
}));
|
||||||
}, 'getPhotosMeta');
|
}, 'getPhotosMeta');
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user