fix: audit log not showing folder downloads#2121
fix: audit log not showing folder downloads#2121shubsolos19 wants to merge 1 commit intomfts:mainfrom
Conversation
|
@shubsolos19 is attempting to deploy a commit to the mftsio Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughModified the dataroom views query to include DOCUMENT_VIEW records (filtered by downloadType "FOLDER" and "BULK") alongside DATAROOM_VIEW records, with adjusted pause-time constraints applied consistently across both view types in both the main query and hidden views count. Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use oxc to improve the quality of JavaScript and TypeScript code reviews.Add a configuration file to your project to customize how CodeRabbit runs oxc. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pages/api/teams/[teamId]/datarooms/[id]/views/index.ts (1)
57-75: Refactor duplicated view filters to prevent future query drift.The same inclusion logic is now repeated in both the main list query and the hidden-count query. Extracting shared predicates into helpers/constants will reduce regression risk.
♻️ Suggested refactor sketch
+const includedViewTypes = [ + { viewType: "DATAROOM_VIEW" as const }, + { + viewType: "DOCUMENT_VIEW" as const, + downloadType: { in: ["FOLDER", "BULK"] as const }, + }, +]; + +const beforePause = team.pauseStartsAt + ? { viewedAt: { lt: team.pauseStartsAt } } + : {}; + +const afterPause = team.pauseStartsAt + ? { viewedAt: { gte: team.pauseStartsAt } } + : {}; ... -where: { OR: [ ...duplicated conditions... ] } +where: { + OR: includedViewTypes.map((v) => ({ ...v, ...beforePause })), +} ... -where: { - dataroomId: dataroomId, - OR: [ ...duplicated conditions... ], - viewedAt: { gte: team.pauseStartsAt }, -} +where: { + dataroomId, + ...afterPause, + OR: includedViewTypes, +}Also applies to: 118-126
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pages/api/teams/`[teamId]/datarooms/[id]/views/index.ts around lines 57 - 75, The query repeats the same view predicates in the views selection (the OR with viewType "DATAROOM_VIEW" and "DOCUMENT_VIEW" plus the optional viewedAt filter using team.pauseStartsAt) and again in the hidden-count query; extract these shared predicates into a single reusable helper (e.g., a function or constant like buildDataroomViewFilter or dataroomViewPredicates) and use it in both places (the views query and the hidden-count query) so both the DATAROOM_VIEW/DOCUMENT_VIEW conditions, dataroomId inclusion and the conditional viewedAt: { lt: team.pauseStartsAt } logic are defined once and reused.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pages/api/teams/`[teamId]/datarooms/[id]/views/index.ts:
- Around line 57-75: The query repeats the same view predicates in the views
selection (the OR with viewType "DATAROOM_VIEW" and "DOCUMENT_VIEW" plus the
optional viewedAt filter using team.pauseStartsAt) and again in the hidden-count
query; extract these shared predicates into a single reusable helper (e.g., a
function or constant like buildDataroomViewFilter or dataroomViewPredicates) and
use it in both places (the views query and the hidden-count query) so both the
DATAROOM_VIEW/DOCUMENT_VIEW conditions, dataroomId inclusion and the conditional
viewedAt: { lt: team.pauseStartsAt } logic are defined once and reused.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 721e43fc-c27d-4e05-995a-801d92ad844f
📒 Files selected for processing (1)
pages/api/teams/[teamId]/datarooms/[id]/views/index.ts
Fixes #1910
Problem
Folder downloads were not appearing in the dataroom audit log.
Root Cause
dataroom-folder.tscorrectly createsViewrecords withviewType: "DOCUMENT_VIEW"anddownloadType: "FOLDER",but the audit log API (
views/index.ts) only queried forviewType: "DATAROOM_VIEW", so folder downloads weresilently excluded from the audit log.
Fix
Updated the Prisma query in
views/index.tsto use anORcondition that includes
DOCUMENT_VIEWrecords wheredownloadTypeisFOLDERorBULK.No schema changes required —
DownloadType.FOLDERalreadyexists in the Prisma schema.
Summary by CodeRabbit
Release Notes