diff --git a/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.test.ts b/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.test.ts index 9768d840d..8f5bc51dc 100644 --- a/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.test.ts +++ b/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.test.ts @@ -170,8 +170,6 @@ describe('getDocumentLogsWithMetadata', () => { document: doc2, commit, }) - - const dateThatMatch = new Date('2024-12-10T23:00:01Z') const { documentLog: anotherWorkspaceLog } = await factories.createDocumentLog({ document: another.documents[0]!, @@ -182,9 +180,12 @@ describe('getDocumentLogsWithMetadata', () => { new Date('2024-12-10T22:59:59Z'), log1, ) - const log2Between = await updateLogCreatedAt(dateThatMatch, log3) + const log2Between = await updateLogCreatedAt( + new Date('2024-12-10T23:00:01Z'), + log2, + ) const anotherWorkspacelogBetween = await updateLogCreatedAt( - dateThatMatch, + new Date('2024-12-10T23:00:01Z'), anotherWorkspaceLog, ) const log3InAfter = await updateLogCreatedAt( @@ -192,18 +193,12 @@ describe('getDocumentLogsWithMetadata', () => { log3, ) - console.log('LOG_BEFORE.id', log1Before.id) - console.log('LOG_BETWEEN.createdAt', log2Between.createdAt) - console.log('LOG_BETWEEN.commitId', log2Between.commitId) - console.log('LOG_BETWEEN.source', log2Between.source) - console.log('WORSPACE_ID', project.workspaceId) - const createdAt = parseSafeCreatedAtRange( - '2024-12-11T00:00:00+01:00,2024-12-11T23:59:59+01:00', + '2024-12-11T00:00:00 01:00,2024-12-11T23:59:59 01:00', ) - console.log('CREATED_AT', createdAt) + const result = await computeDocumentLogsWithMetadataQuery({ - workspaceId: project.workspaceId, + workspaceId: workspace.id, filterOptions: { commitIds: [commit.id, commit2.id, another.commit.id], logSources: LOG_SOURCES, @@ -211,22 +206,6 @@ describe('getDocumentLogsWithMetadata', () => { }, }) - console.log("OTHER_WORKSPACE_LOGS", anotherWorkspacelogBetween.id) - const allLogs = await database.query.documentLogs.findMany({ - where: and( - /* gte(documentLogs.createdAt, new Date('2024-12-10T23:00:00Z')), */ - /* lte(documentLogs.createdAt, new Date('2024-12-11T23:59:59Z')), */ - gte(documentLogs.createdAt, createdAt.from!), - lte(documentLogs.createdAt, createdAt.to!), - ), - }) - - const allLogsCreatedAt = allLogs.map((l) => ({ - id: l.id, - createdAt: l.createdAt, - })) - console.log('ALL_LOGS_CREATED_AT', allLogsCreatedAt) - expect(result.length).toBe(1) expect(result.find((l) => l.uuid === log1Before.uuid)).toBeUndefined() expect(result.find((l) => l.uuid === log2Between.uuid)).toBeDefined() diff --git a/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.ts b/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.ts index 4ac618557..cad53cbd4 100644 --- a/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.ts +++ b/packages/core/src/services/documentLogs/computeDocumentLogsWithMetadata.ts @@ -40,14 +40,11 @@ export function computeDocumentLogsWithMetadataQuery( documentUuid ? eq(documentLogs.documentUuid, documentUuid) : undefined, filterOptions ? buildLogsFilterSQLConditions(filterOptions) : undefined, ].filter(Boolean) - const foo = repo.scope + return repo.scope .where(and(...conditions)) .orderBy(desc(documentLogs.createdAt)) .limit(parseInt(pageSize)) .offset(offset) - - /* console.log("SQL", foo.toSQL()) */ - return foo } export async function computeDocumentLogsWithMetadataCount(