increase resolution slightly

This commit is contained in:
Nate Kelley 2025-10-08 23:24:50 -06:00
parent fda1878f09
commit d443c1c333
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
7 changed files with 44 additions and 18 deletions

View File

@ -6,6 +6,7 @@ import {
getCollectionsAssociatedWithDashboard,
getDashboardById,
getOrganizationMemberCount,
getUserOrganizationId,
getUsersWithAssetPermissions,
} from '@buster/database/queries';
import {
@ -54,6 +55,27 @@ const app = new Hono().get(
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);
}
);

View File

@ -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.
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 ({
tag,

View File

@ -53,10 +53,12 @@ const shouldTakeChatScreenshot = async (
return true;
}
const isScreenshotExpired = await hasChatScreenshotBeenTakenWithin(
const hasRecentScreenshot = await hasChatScreenshotBeenTakenWithin(
args.chatId,
dayjs().subtract(4, 'weeks')
);
return !isScreenshotExpired;
logger.info('Has recent screenshot', { hasRecentScreenshot });
return !hasRecentScreenshot;
};

View File

@ -25,6 +25,8 @@ export const takeDashboardScreenshotHandlerTask: ReturnType<
isOnSaveEvent,
});
logger.info('Should take new screenshot', { shouldTakeNewScreenshot });
if (!shouldTakeNewScreenshot) {
return;
}
@ -54,10 +56,12 @@ const shouldTakenNewScreenshot = async ({
return true;
}
const isScreenshotExpired = await hasDashboardScreenshotBeenTakenWithin(
const hasRecentScreenshot = await hasDashboardScreenshotBeenTakenWithin(
dashboardId,
dayjs().subtract(24, 'hours')
);
return !isScreenshotExpired;
logger.info('Is screenshot expired', { hasRecentScreenshot });
return !hasRecentScreenshot;
};

View File

@ -46,10 +46,10 @@ export const takeReportScreenshotHandlerTask: ReturnType<
});
const shouldTakenNewScreenshot = async ({ reportId }: { reportId: string }) => {
const isScreenshotExpired = await hasReportScreenshotBeenTakenWithin(
const hasRecentScreenshot = await hasReportScreenshotBeenTakenWithin(
reportId,
dayjs().subtract(24, 'hours')
);
return !isScreenshotExpired;
return !hasRecentScreenshot;
};

View File

@ -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 {
ShareDeleteRequest,
ShareDeleteResponse,
@ -26,15 +31,8 @@ export const getDashboardById = async ({
id,
password,
version_number,
}: {
/** The unique identifier of the dashboard */
id: string;
/** Optional password for accessing protected dashboards */
password?: string;
/** The version number of the dashboard */
version_number?: number;
}) => {
return await mainApi
}: GetDashboardParams & GetDashboardQuery) => {
return await mainApiV2
.get<GetDashboardResponse>(`/dashboards/${id}`, {
params: { password, version_number },
})

View File

@ -4,5 +4,5 @@ export const DEFAULT_SCREENSHOT_CONFIG = {
width: 400 * multiplier,
height: 240 * multiplier,
type: 'webp' as const,
deviceScaleFactor: 1.6,
deviceScaleFactor: 1.62,
};