mirror of https://github.com/buster-so/buster.git
increase resolution slightly
This commit is contained in:
parent
fda1878f09
commit
d443c1c333
|
@ -6,6 +6,7 @@ import {
|
||||||
getCollectionsAssociatedWithDashboard,
|
getCollectionsAssociatedWithDashboard,
|
||||||
getDashboardById,
|
getDashboardById,
|
||||||
getOrganizationMemberCount,
|
getOrganizationMemberCount,
|
||||||
|
getUserOrganizationId,
|
||||||
getUsersWithAssetPermissions,
|
getUsersWithAssetPermissions,
|
||||||
} from '@buster/database/queries';
|
} from '@buster/database/queries';
|
||||||
import {
|
import {
|
||||||
|
@ -54,6 +55,27 @@ const app = new Hono().get(
|
||||||
c
|
c
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const tag = `take-dashboard-screenshot-${id}`;
|
||||||
|
if (
|
||||||
|
await shouldTakeScreenshot({
|
||||||
|
tag,
|
||||||
|
key: screenshots_task_keys.take_dashboard_screenshot,
|
||||||
|
context: c,
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
console.log('Taking dashboard screenshot');
|
||||||
|
tasks.trigger(
|
||||||
|
screenshots_task_keys.take_dashboard_screenshot,
|
||||||
|
{
|
||||||
|
dashboardId: id,
|
||||||
|
organizationId: (await getUserOrganizationId(user.id))?.organizationId || '',
|
||||||
|
accessToken: c.get('accessToken'),
|
||||||
|
isOnSaveEvent: false,
|
||||||
|
} satisfies TakeDashboardScreenshotTrigger,
|
||||||
|
{ tags: [tag] }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return c.json(response);
|
return c.json(response);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import type { Context } from 'hono';
|
||||||
// It checks if a job for the given tag and key is already running or queued before starting a new one.
|
// It checks if a job for the given tag and key is already running or queued before starting a new one.
|
||||||
|
|
||||||
const currentlyCheckingTags = new Set<string>();
|
const currentlyCheckingTags = new Set<string>();
|
||||||
const CACHE_TAG_EXPIRATION_TIME = 1000 * 15; // 15 seconds
|
const CACHE_TAG_EXPIRATION_TIME = 1000 * 30; // 30 seconds
|
||||||
|
|
||||||
export const shouldTakeScreenshot = async ({
|
export const shouldTakeScreenshot = async ({
|
||||||
tag,
|
tag,
|
||||||
|
|
|
@ -53,10 +53,12 @@ const shouldTakeChatScreenshot = async (
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isScreenshotExpired = await hasChatScreenshotBeenTakenWithin(
|
const hasRecentScreenshot = await hasChatScreenshotBeenTakenWithin(
|
||||||
args.chatId,
|
args.chatId,
|
||||||
dayjs().subtract(4, 'weeks')
|
dayjs().subtract(4, 'weeks')
|
||||||
);
|
);
|
||||||
|
|
||||||
return !isScreenshotExpired;
|
logger.info('Has recent screenshot', { hasRecentScreenshot });
|
||||||
|
|
||||||
|
return !hasRecentScreenshot;
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,6 +25,8 @@ export const takeDashboardScreenshotHandlerTask: ReturnType<
|
||||||
isOnSaveEvent,
|
isOnSaveEvent,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.info('Should take new screenshot', { shouldTakeNewScreenshot });
|
||||||
|
|
||||||
if (!shouldTakeNewScreenshot) {
|
if (!shouldTakeNewScreenshot) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -54,10 +56,12 @@ const shouldTakenNewScreenshot = async ({
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isScreenshotExpired = await hasDashboardScreenshotBeenTakenWithin(
|
const hasRecentScreenshot = await hasDashboardScreenshotBeenTakenWithin(
|
||||||
dashboardId,
|
dashboardId,
|
||||||
dayjs().subtract(24, 'hours')
|
dayjs().subtract(24, 'hours')
|
||||||
);
|
);
|
||||||
|
|
||||||
return !isScreenshotExpired;
|
logger.info('Is screenshot expired', { hasRecentScreenshot });
|
||||||
|
|
||||||
|
return !hasRecentScreenshot;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,10 +46,10 @@ export const takeReportScreenshotHandlerTask: ReturnType<
|
||||||
});
|
});
|
||||||
|
|
||||||
const shouldTakenNewScreenshot = async ({ reportId }: { reportId: string }) => {
|
const shouldTakenNewScreenshot = async ({ reportId }: { reportId: string }) => {
|
||||||
const isScreenshotExpired = await hasReportScreenshotBeenTakenWithin(
|
const hasRecentScreenshot = await hasReportScreenshotBeenTakenWithin(
|
||||||
reportId,
|
reportId,
|
||||||
dayjs().subtract(24, 'hours')
|
dayjs().subtract(24, 'hours')
|
||||||
);
|
);
|
||||||
|
|
||||||
return !isScreenshotExpired;
|
return !hasRecentScreenshot;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import type { DashboardConfig, GetDashboardResponse } from '@buster/server-shared/dashboards';
|
import type {
|
||||||
|
DashboardConfig,
|
||||||
|
GetDashboardParams,
|
||||||
|
GetDashboardQuery,
|
||||||
|
GetDashboardResponse,
|
||||||
|
} from '@buster/server-shared/dashboards';
|
||||||
import type {
|
import type {
|
||||||
ShareDeleteRequest,
|
ShareDeleteRequest,
|
||||||
ShareDeleteResponse,
|
ShareDeleteResponse,
|
||||||
|
@ -26,15 +31,8 @@ export const getDashboardById = async ({
|
||||||
id,
|
id,
|
||||||
password,
|
password,
|
||||||
version_number,
|
version_number,
|
||||||
}: {
|
}: GetDashboardParams & GetDashboardQuery) => {
|
||||||
/** The unique identifier of the dashboard */
|
return await mainApiV2
|
||||||
id: string;
|
|
||||||
/** Optional password for accessing protected dashboards */
|
|
||||||
password?: string;
|
|
||||||
/** The version number of the dashboard */
|
|
||||||
version_number?: number;
|
|
||||||
}) => {
|
|
||||||
return await mainApi
|
|
||||||
.get<GetDashboardResponse>(`/dashboards/${id}`, {
|
.get<GetDashboardResponse>(`/dashboards/${id}`, {
|
||||||
params: { password, version_number },
|
params: { password, version_number },
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,5 +4,5 @@ export const DEFAULT_SCREENSHOT_CONFIG = {
|
||||||
width: 400 * multiplier,
|
width: 400 * multiplier,
|
||||||
height: 240 * multiplier,
|
height: 240 * multiplier,
|
||||||
type: 'webp' as const,
|
type: 'webp' as const,
|
||||||
deviceScaleFactor: 1.6,
|
deviceScaleFactor: 1.62,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue