mirror of
https://github.com/immich-app/immich.git
synced 2025-01-04 02:46:47 +01:00
fix(server): handle 5 digit years (#6457)
This commit is contained in:
parent
574aecc1e2
commit
6f291006e4
3 changed files with 13 additions and 13 deletions
|
@ -1073,6 +1073,16 @@ describe(`${AssetController.name} (e2e)`, () => {
|
||||||
expect(body).toEqual(errorStub.unauthorized);
|
expect(body).toEqual(errorStub.unauthorized);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle 5 digit years', async () => {
|
||||||
|
const { status, body } = await request(server)
|
||||||
|
.get('/asset/time-bucket')
|
||||||
|
.query({ size: TimeBucketSize.MONTH, timeBucket: '+012345-01-01T00:00:00.000Z' })
|
||||||
|
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||||
|
|
||||||
|
expect(status).toBe(200);
|
||||||
|
expect(body).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
// it('should fail if time bucket is invalid', async () => {
|
// it('should fail if time bucket is invalid', async () => {
|
||||||
// const { status, body } = await request(server)
|
// const { status, body } = await request(server)
|
||||||
// .get('/asset/time-bucket')
|
// .get('/asset/time-bucket')
|
||||||
|
|
|
@ -687,7 +687,7 @@ export class AssetRepository implements IAssetRepository {
|
||||||
const truncated = dateTrunc(options);
|
const truncated = dateTrunc(options);
|
||||||
return (
|
return (
|
||||||
this.getBuilder(options)
|
this.getBuilder(options)
|
||||||
.andWhere(`${truncated} = :timeBucket`, { timeBucket })
|
.andWhere(`${truncated} = :timeBucket`, { timeBucket: timeBucket.replace(/^[+-]/, '') })
|
||||||
// First sort by the day in localtime (put it in the right bucket)
|
// First sort by the day in localtime (put it in the right bucket)
|
||||||
.orderBy(truncated, 'DESC')
|
.orderBy(truncated, 'DESC')
|
||||||
// and then sort by the actual time
|
// and then sort by the actual time
|
||||||
|
@ -757,10 +757,7 @@ export class AssetRepository implements IAssetRepository {
|
||||||
private getBuilder(options: AssetBuilderOptions) {
|
private getBuilder(options: AssetBuilderOptions) {
|
||||||
const { isArchived, isFavorite, isTrashed, albumId, personId, userIds, withStacked, exifInfo, assetType } = options;
|
const { isArchived, isFavorite, isTrashed, albumId, personId, userIds, withStacked, exifInfo, assetType } = options;
|
||||||
|
|
||||||
let builder = this.repository
|
let builder = this.repository.createQueryBuilder('asset').where('asset.isVisible = true');
|
||||||
.createQueryBuilder('asset')
|
|
||||||
.where('asset.isVisible = true')
|
|
||||||
.andWhere('asset.fileCreatedAt < NOW()');
|
|
||||||
if (assetType !== undefined) {
|
if (assetType !== undefined) {
|
||||||
builder = builder.andWhere('asset.type = :assetType', { assetType });
|
builder = builder.andWhere('asset.type = :assetType', { assetType });
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,10 +553,7 @@ FROM
|
||||||
LEFT JOIN "assets" "stack" ON "stack"."stackParentId" = "asset"."id"
|
LEFT JOIN "assets" "stack" ON "stack"."stackParentId" = "asset"."id"
|
||||||
AND ("stack"."deletedAt" IS NULL)
|
AND ("stack"."deletedAt" IS NULL)
|
||||||
WHERE
|
WHERE
|
||||||
(
|
("asset"."isVisible" = true)
|
||||||
"asset"."isVisible" = true
|
|
||||||
AND "asset"."fileCreatedAt" < NOW()
|
|
||||||
)
|
|
||||||
AND ("asset"."deletedAt" IS NULL)
|
AND ("asset"."deletedAt" IS NULL)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
(
|
(
|
||||||
|
@ -668,7 +665,6 @@ FROM
|
||||||
WHERE
|
WHERE
|
||||||
(
|
(
|
||||||
"asset"."isVisible" = true
|
"asset"."isVisible" = true
|
||||||
AND "asset"."fileCreatedAt" < NOW()
|
|
||||||
AND (
|
AND (
|
||||||
date_trunc(
|
date_trunc(
|
||||||
'month',
|
'month',
|
||||||
|
@ -708,7 +704,6 @@ FROM
|
||||||
WHERE
|
WHERE
|
||||||
(
|
(
|
||||||
"asset"."isVisible" = true
|
"asset"."isVisible" = true
|
||||||
AND "asset"."fileCreatedAt" < NOW()
|
|
||||||
AND "asset"."type" = $2
|
AND "asset"."type" = $2
|
||||||
AND "asset"."ownerId" IN ($3)
|
AND "asset"."ownerId" IN ($3)
|
||||||
AND "asset"."isArchived" = $4
|
AND "asset"."isArchived" = $4
|
||||||
|
@ -739,7 +734,6 @@ FROM
|
||||||
WHERE
|
WHERE
|
||||||
(
|
(
|
||||||
"asset"."isVisible" = true
|
"asset"."isVisible" = true
|
||||||
AND "asset"."fileCreatedAt" < NOW()
|
|
||||||
AND "asset"."type" = $2
|
AND "asset"."type" = $2
|
||||||
AND "asset"."ownerId" IN ($3)
|
AND "asset"."ownerId" IN ($3)
|
||||||
AND "asset"."isArchived" = $4
|
AND "asset"."isArchived" = $4
|
||||||
|
@ -761,7 +755,6 @@ FROM
|
||||||
WHERE
|
WHERE
|
||||||
(
|
(
|
||||||
"asset"."isVisible" = true
|
"asset"."isVisible" = true
|
||||||
AND "asset"."fileCreatedAt" < NOW()
|
|
||||||
AND "asset"."ownerId" IN ($1)
|
AND "asset"."ownerId" IN ($1)
|
||||||
AND "asset"."isArchived" = $2
|
AND "asset"."isArchived" = $2
|
||||||
AND (
|
AND (
|
||||||
|
|
Loading…
Reference in a new issue