mirror of https://github.com/buster-so/buster.git
fixed flawed metric screenshot logic
This commit is contained in:
parent
06cb498a46
commit
cc9e269969
|
@ -83,6 +83,7 @@ describe('POST /chats', () => {
|
|||
workspace_sharing: 'full_access',
|
||||
workspace_member_count: 0,
|
||||
individual_permissions: [],
|
||||
screenshot_taken_at: null,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue