mirror of
https://github.com/immich-app/immich.git
synced 2025-04-14 12:06:25 +02:00
fix(web): No EXIF info on stack navigation (#15533)
* fix(web): No EXIF info on stack navigation * fix(web): No EXIF info on stack navigation * add exif info to get stack query * e2e test
This commit is contained in:
parent
1311189fab
commit
afc6e91c66
3 changed files with 65 additions and 6 deletions
e2e/src/api/specs
server/src
|
@ -172,4 +172,31 @@ describe('/stacks', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('GET /stacks/:id', () => {
|
||||||
|
it('should include exifInfo in stack assets', async () => {
|
||||||
|
const [asset1, asset2] = await Promise.all([
|
||||||
|
utils.createAsset(user1.accessToken),
|
||||||
|
utils.createAsset(user1.accessToken),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const stack = await utils.createStack(user1.accessToken, [asset1.id, asset2.id]);
|
||||||
|
|
||||||
|
const { status, body } = await request(app)
|
||||||
|
.get(`/stacks/${stack.id}`)
|
||||||
|
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||||
|
|
||||||
|
expect(status).toBe(200);
|
||||||
|
expect(body).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
id: stack.id,
|
||||||
|
primaryAssetId: asset1.id,
|
||||||
|
assets: expect.arrayContaining([
|
||||||
|
expect.objectContaining({ id: asset1.id, exifInfo: expect.any(Object) }),
|
||||||
|
expect.objectContaining({ id: asset2.id, exifInfo: expect.any(Object) }),
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,9 +9,18 @@ select
|
||||||
from
|
from
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
*
|
"assets".*,
|
||||||
|
to_json("exifInfo") as "exifInfo"
|
||||||
from
|
from
|
||||||
"assets"
|
"assets"
|
||||||
|
inner join lateral (
|
||||||
|
select
|
||||||
|
"exif".*
|
||||||
|
from
|
||||||
|
"exif"
|
||||||
|
where
|
||||||
|
"exif"."assetId" = "assets"."id"
|
||||||
|
) as "exifInfo" on true
|
||||||
where
|
where
|
||||||
"assets"."deletedAt" is null
|
"assets"."deletedAt" is null
|
||||||
and "assets"."stackId" = "asset_stack"."id"
|
and "assets"."stackId" = "asset_stack"."id"
|
||||||
|
@ -31,7 +40,7 @@ select
|
||||||
from
|
from
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
*,
|
"assets".*,
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
coalesce(json_agg(agg), '[]')
|
coalesce(json_agg(agg), '[]')
|
||||||
|
@ -45,9 +54,18 @@ select
|
||||||
where
|
where
|
||||||
"tag_asset"."assetsId" = "assets"."id"
|
"tag_asset"."assetsId" = "assets"."id"
|
||||||
) as agg
|
) as agg
|
||||||
) as "tags"
|
) as "tags",
|
||||||
|
to_json("exifInfo") as "exifInfo"
|
||||||
from
|
from
|
||||||
"assets"
|
"assets"
|
||||||
|
inner join lateral (
|
||||||
|
select
|
||||||
|
"exif".*
|
||||||
|
from
|
||||||
|
"exif"
|
||||||
|
where
|
||||||
|
"exif"."assetId" = "assets"."id"
|
||||||
|
) as "exifInfo" on true
|
||||||
where
|
where
|
||||||
"assets"."deletedAt" is null
|
"assets"."deletedAt" is null
|
||||||
and "assets"."stackId" = "asset_stack"."id"
|
and "assets"."stackId" = "asset_stack"."id"
|
||||||
|
@ -67,7 +85,7 @@ select
|
||||||
from
|
from
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
*,
|
"assets".*,
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
coalesce(json_agg(agg), '[]')
|
coalesce(json_agg(agg), '[]')
|
||||||
|
@ -81,9 +99,18 @@ select
|
||||||
where
|
where
|
||||||
"tag_asset"."assetsId" = "assets"."id"
|
"tag_asset"."assetsId" = "assets"."id"
|
||||||
) as agg
|
) as agg
|
||||||
) as "tags"
|
) as "tags",
|
||||||
|
to_json("exifInfo") as "exifInfo"
|
||||||
from
|
from
|
||||||
"assets"
|
"assets"
|
||||||
|
inner join lateral (
|
||||||
|
select
|
||||||
|
"exif".*
|
||||||
|
from
|
||||||
|
"exif"
|
||||||
|
where
|
||||||
|
"exif"."assetId" = "assets"."id"
|
||||||
|
) as "exifInfo" on true
|
||||||
where
|
where
|
||||||
"assets"."deletedAt" is null
|
"assets"."deletedAt" is null
|
||||||
and "assets"."stackId" = "asset_stack"."id"
|
and "assets"."stackId" = "asset_stack"."id"
|
||||||
|
|
|
@ -12,7 +12,11 @@ const withAssets = (eb: ExpressionBuilder<DB, 'asset_stack'>, withTags = false)
|
||||||
return jsonArrayFrom(
|
return jsonArrayFrom(
|
||||||
eb
|
eb
|
||||||
.selectFrom('assets')
|
.selectFrom('assets')
|
||||||
.selectAll()
|
.selectAll('assets')
|
||||||
|
.innerJoinLateral(
|
||||||
|
(eb) => eb.selectFrom('exif').selectAll('exif').whereRef('exif.assetId', '=', 'assets.id').as('exifInfo'),
|
||||||
|
(join) => join.onTrue(),
|
||||||
|
)
|
||||||
.$if(withTags, (eb) =>
|
.$if(withTags, (eb) =>
|
||||||
eb.select((eb) =>
|
eb.select((eb) =>
|
||||||
jsonArrayFrom(
|
jsonArrayFrom(
|
||||||
|
@ -24,6 +28,7 @@ const withAssets = (eb: ExpressionBuilder<DB, 'asset_stack'>, withTags = false)
|
||||||
).as('tags'),
|
).as('tags'),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.select((eb) => eb.fn.toJson('exifInfo').as('exifInfo'))
|
||||||
.where('assets.deletedAt', 'is', null)
|
.where('assets.deletedAt', 'is', null)
|
||||||
.whereRef('assets.stackId', '=', 'asset_stack.id'),
|
.whereRef('assets.stackId', '=', 'asset_stack.id'),
|
||||||
).as('assets');
|
).as('assets');
|
||||||
|
|
Loading…
Add table
Reference in a new issue