Display 5 thinned out screenshots as thumbnails
continuous-integration/drone Build is passing Details

This commit is contained in:
Erki Aas 2022-12-16 13:54:53 +02:00
parent 45fb0ea4f4
commit 37e9e061d4
1 changed files with 13 additions and 1 deletions

View File

@ -24,6 +24,18 @@ const signer = async function (asset: string) {
return await presigner.presign(new HttpRequest(s3ObjectUrl));
}
const shots = 5
const reduceScreenshots = function (screenshots: Array<any>) {
if (screenshots.length <= shots)
return screenshots
else
var sc = []
for (let i = 0; i < shots; i++) {
sc.push(screenshots[i * Math.floor((screenshots.length - 1) / (shots - 1))])
}
return sc
}
const getScreenshots = async function (resp: object, path: string): Promise<any> {
const screenshots = resp.screenshots ? resp.screenshots : []
if (path === '/details/') {
@ -34,7 +46,7 @@ const getScreenshots = async function (resp: object, path: string): Promise<any>
}
});
} else if (path === '/initial/' || path === '/query/' || path === '/streaming/') {
return screenshots.splice(0, 5).map(async (x) => {
return reduceScreenshots(screenshots).map(async (x) => {
return {
thumb: formatUrl(await signer(`thumb/${x}`)),
}