fixed flawed metric screenshot logic

This commit is contained in:
Nate Kelley 2025-10-08 17:30:49 -06:00
parent 06cb498a46
commit cc9e269969
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 8 additions and 3 deletions

View File

@ -83,6 +83,7 @@ describe('POST /chats', () => {
workspace_sharing: 'full_access',
workspace_member_count: 0,
individual_permissions: [],
screenshot_taken_at: null,
};
beforeEach(() => {

View File

@ -64,12 +64,12 @@ const shouldTakenNewScreenshot = async ({
return true;
}
const isScreenshotExpired = await hasMetricScreenshotBeenTakenWithin(
const hasRecentScreenshot = await hasMetricScreenshotBeenTakenWithin(
metricId,
dayjs().subtract(6, 'hours')
);
logger.info('Is screenshot expired', { isScreenshotExpired });
logger.info('Has recent screenshot', { hasRecentScreenshot });
return isScreenshotExpired;
return !hasRecentScreenshot;
};

View File

@ -137,6 +137,7 @@ describe('ChatWithMessagesSchema', () => {
permission: 'owner',
workspace_sharing: 'full_access',
workspace_member_count: 0,
screenshot_taken_at: '2024-01-01T00:00:00Z',
};
const result = ChatWithMessagesSchema.safeParse(validChat);
@ -172,6 +173,7 @@ describe('ChatWithMessagesSchema', () => {
public_enabled_by: null,
public_password: null,
permission: 'owner',
screenshot_taken_at: null,
// Optional fields omitted
};
@ -210,6 +212,7 @@ describe('ChatWithMessagesSchema', () => {
permission: 'owner',
workspace_sharing: 'full_access',
workspace_member_count: 0,
screenshot_taken_at: null,
};
const result = ChatWithMessagesSchema.safeParse(chatWithInvalidPermissions);
@ -238,6 +241,7 @@ describe('ChatWithMessagesSchema', () => {
workspace_sharing: 'full_access',
workspace_member_count: 0,
individual_permissions: [],
screenshot_taken_at: null,
};
const result = ChatWithMessagesSchema.safeParse(chatWithValidDate);