Skip to content

Conversation

@mfts
Copy link
Owner

@mfts mfts commented Aug 26, 2025

Summary by CodeRabbit

  • Improvements
    • “Last updated” on dataroom pages now considers the dataroom’s creation time, providing a more accurate baseline even when no documents exist.
  • Bug Fixes
    • Fixed cases where “Last updated” could appear as 0 or be missing by ensuring it’s at least the dataroom creation time across dataroom link views and domain-based routes.

@vercel
Copy link

vercel bot commented Aug 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
papermark Ready Ready Preview Comment Aug 26, 2025 11:11am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Added dataroom.createdAt to dataroom link data retrieval and updated two view pages to seed lastUpdatedAt calculations with the dataroom creation timestamp instead of 0. No control-flow or API signature changes.

Changes

Cohort / File(s) Summary
Dataroom link data selection
lib/api/links/link-data.ts
Include createdAt in fetchDataroomLinkData selection so linkData.dataroom contains the dataroom creation timestamp.
lastUpdatedAt baseline uses dataroom.createdAt
pages/view/[linkId]/index.tsx, pages/view/domains/[domain]/[slug]/index.tsx
In DATAROOM_LINK getStaticProps, change reduction seed from 0 to new Date(link.dataroom.createdAt).getTime(), making lastUpdatedAt at least the dataroom creation time.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/dub

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
lib/api/links/link-data.ts (1)

108-116: Add missing createdAt (and allowBulkDownload) to the LinkWithDataroom type

The fetchDataroomLinkData calls in your API routes are now selecting both allowBulkDownload and createdAt, but the TypeScript interface for LinkWithDataroom hasn’t been updated to reflect these fields. You’ll get a type mismatch whenever you try to access them at runtime.

Please update lib/types.ts—around line 125—to include both new properties on the dataroom object:

 export interface LinkWithDataroom extends Link {
   dataroom: {
     id: string;
     name: string;
     teamId: string;
+    allowBulkDownload: boolean;   // <- add this
+    createdAt: string;            // <- add this
     documents: {
       // …
     };
   };
 }

This ensures that consumers of link.dataroom.createdAt (and allowBulkDownload) will type‐check correctly.

pages/view/domains/[domain]/[slug]/index.tsx (1)

170-176: Use the computed documents array for lastUpdatedAt (ensures doc.updatedAt is considered)

You correctly seed with createdAt. However, the reduction currently reads from link.dataroom.documents, which ignores your per-document merged updatedAt (max of dataroomDocument.updatedAt and version.updatedAt). Reduce over the computed documents to avoid underreporting lastUpdatedAt.

-      const lastUpdatedAt = link.dataroom.documents.reduce((max, doc) => {
-        return Math.max(
-          max,
-          new Date(doc.document.versions[0].updatedAt).getTime(),
-        );
-      }, new Date(link.dataroom.createdAt).getTime());
+      const baseCreatedAt = new Date(link.dataroom.createdAt as any).getTime();
+      const lastUpdatedAt = documents.reduce((max, doc) => {
+        return Math.max(
+          max,
+          new Date(doc.versions[0].updatedAt as any).getTime(),
+        );
+      }, Number.isFinite(baseCreatedAt) ? baseCreatedAt : 0);
pages/view/[linkId]/index.tsx (1)

188-194: Use the computed documents array for lastUpdatedAt (keeps logic consistent with merged per-doc timestamps)

Same rationale as the domain page: read from documents, not link.dataroom.documents, so lastUpdatedAt reflects the max of (dataroomDocument.updatedAt vs version.updatedAt) per file.

-      const lastUpdatedAt = link.dataroom.documents.reduce((max, doc) => {
-        return Math.max(
-          max,
-          new Date(doc.document.versions[0].updatedAt).getTime(),
-        );
-      }, new Date(link.dataroom.createdAt).getTime());
+      const baseCreatedAt = new Date(link.dataroom.createdAt as any).getTime();
+      const lastUpdatedAt = documents.reduce((max, doc) => {
+        return Math.max(
+          max,
+          new Date(doc.versions[0].updatedAt as any).getTime(),
+        );
+      }, Number.isFinite(baseCreatedAt) ? baseCreatedAt : 0);
🧹 Nitpick comments (5)
lib/api/links/link-data.ts (1)

108-116: Consider also selecting dataroom.updatedAt for a more accurate “last updated” baseline

If dataroom metadata (branding, settings, folder structure) updates should influence lastUpdatedAt, exposing updatedAt here will let the UI compute max(createdAt, updatedAt, doc updates).

       dataroom: {
         select: {
           id: true,
           name: true,
           teamId: true,
           allowBulkDownload: true,
+          updatedAt: true,
           createdAt: true,
pages/view/domains/[domain]/[slug]/index.tsx (2)

175-175: Add a defensive fallback if createdAt is missing or invalid

If createdAt were ever absent (older payloads, partial fetch), new Date(undefined).getTime() yields NaN and poisons the reduction. The above diff guards this; alternatively:

-      }, new Date(link.dataroom.createdAt).getTime());
+      }, Date.parse(String(link.dataroom.createdAt)) || 0);

146-166: Deduplicate shared compute logic between domain and ID views

Both pages build documents the same way and compute lastUpdatedAt similarly. Extract a small helper (e.g., lib/view/compute-last-updated.ts) to DRY and reduce divergence risk.

// lib/view/compute-last-updated.ts
export function computeLastUpdatedAt(
  createdAt: string | Date,
  docs: Array<{ versions: Array<{ updatedAt: string | Date }> }>
) {
  const base = Date.parse(String(createdAt)) || 0;
  return docs.reduce((m, d) => Math.max(m, Date.parse(String(d.versions[0].updatedAt)) || 0), base);
}

Then use:

- const lastUpdatedAt = /* reduction inline */
+ const lastUpdatedAt = computeLastUpdatedAt(link.dataroom.createdAt, documents);

Also applies to: 170-176

pages/view/[linkId]/index.tsx (2)

193-193: Defensive default for createdAt parsing

Mirror the same guard here to avoid NaN in case of unexpected payloads.

-      }, new Date(link.dataroom.createdAt).getTime());
+      }, Date.parse(String(link.dataroom.createdAt)) || 0);

164-184: Optional: centralize shared logic

Both pages share the documents mapping and lastUpdatedAt calculation. Consider extracting a shared helper as suggested in the domain view comment to reduce duplication.

Also applies to: 188-194

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ce0c834 and 0e40c89.

📒 Files selected for processing (3)
  • lib/api/links/link-data.ts (1 hunks)
  • pages/view/[linkId]/index.tsx (1 hunks)
  • pages/view/domains/[domain]/[slug]/index.tsx (1 hunks)

@mfts mfts merged commit d39a267 into main Aug 26, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants