mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00: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);
|
||||
});
|
||||
|
||||
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 () => {
|
||||
// const { status, body } = await request(server)
|
||||
// .get('/asset/time-bucket')
|
||||
|
|
|
@ -687,7 +687,7 @@ export class AssetRepository implements IAssetRepository {
|
|||
const truncated = dateTrunc(options);
|
||||
return (
|
||||
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)
|
||||
.orderBy(truncated, 'DESC')
|
||||
// and then sort by the actual time
|
||||
|
@ -757,10 +757,7 @@ export class AssetRepository implements IAssetRepository {
|
|||
private getBuilder(options: AssetBuilderOptions) {
|
||||
const { isArchived, isFavorite, isTrashed, albumId, personId, userIds, withStacked, exifInfo, assetType } = options;
|
||||
|
||||
let builder = this.repository
|
||||
.createQueryBuilder('asset')
|
||||
.where('asset.isVisible = true')
|
||||
.andWhere('asset.fileCreatedAt < NOW()');
|
||||
let builder = this.repository.createQueryBuilder('asset').where('asset.isVisible = true');
|
||||
if (assetType !== undefined) {
|
||||
builder = builder.andWhere('asset.type = :assetType', { assetType });
|
||||
}
|
||||
|
|
|
@ -553,10 +553,7 @@ FROM
|
|||
LEFT JOIN "assets" "stack" ON "stack"."stackParentId" = "asset"."id"
|
||||
AND ("stack"."deletedAt" IS NULL)
|
||||
WHERE
|
||||
(
|
||||
"asset"."isVisible" = true
|
||||
AND "asset"."fileCreatedAt" < NOW()
|
||||
)
|
||||
("asset"."isVisible" = true)
|
||||
AND ("asset"."deletedAt" IS NULL)
|
||||
GROUP BY
|
||||
(
|
||||
|
@ -668,7 +665,6 @@ FROM
|
|||
WHERE
|
||||
(
|
||||
"asset"."isVisible" = true
|
||||
AND "asset"."fileCreatedAt" < NOW()
|
||||
AND (
|
||||
date_trunc(
|
||||
'month',
|
||||
|
@ -708,7 +704,6 @@ FROM
|
|||
WHERE
|
||||
(
|
||||
"asset"."isVisible" = true
|
||||
AND "asset"."fileCreatedAt" < NOW()
|
||||
AND "asset"."type" = $2
|
||||
AND "asset"."ownerId" IN ($3)
|
||||
AND "asset"."isArchived" = $4
|
||||
|
@ -739,7 +734,6 @@ FROM
|
|||
WHERE
|
||||
(
|
||||
"asset"."isVisible" = true
|
||||
AND "asset"."fileCreatedAt" < NOW()
|
||||
AND "asset"."type" = $2
|
||||
AND "asset"."ownerId" IN ($3)
|
||||
AND "asset"."isArchived" = $4
|
||||
|
@ -761,7 +755,6 @@ FROM
|
|||
WHERE
|
||||
(
|
||||
"asset"."isVisible" = true
|
||||
AND "asset"."fileCreatedAt" < NOW()
|
||||
AND "asset"."ownerId" IN ($1)
|
||||
AND "asset"."isArchived" = $2
|
||||
AND (
|
||||
|
|
Loading…
Reference in a new issue