Skip to content

fix: use only time as cursos#3055

Merged
chronark merged 1 commit intomainfrom
audit-log-cursor
Mar 31, 2025
Merged

fix: use only time as cursos#3055
chronark merged 1 commit intomainfrom
audit-log-cursor

Conversation

@chronark
Copy link
Collaborator

@chronark chronark commented Mar 31, 2025

Summary by CodeRabbit

  • Style

    • Refined the presentation of legal link elements in the authentication view. The links for terms and privacy display as before without affecting functionality.
  • Refactor

    • Streamlined audit log pagination and ordering for a more intuitive, chronologically aligned log display.

@vercel
Copy link

vercel bot commented Mar 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 2:37pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 2:37pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 2:37pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 2:37pm

@changeset-bot
Copy link

changeset-bot bot commented Mar 31, 2025

⚠️ No Changeset found

Latest commit: 52a52a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 31, 2025

📝 Walkthrough

Walkthrough

This pull request includes formatting changes and logic updates in two areas. In the authenticated layout, JSX <Link> components have been reformatted so that their attributes appear on separate lines, without altering functionality. In the audit log functionality, the pagination logic has been simplified by updating the AuditLogsResponse schema to represent nextCursor as an optional number, modifying the fetchAuditLog and queryAuditLogs functions to use a cursor based solely on time, and changing the log ordering from id to time.

Changes

File(s) Change Summary
apps/.../auth/layout.tsx Reformatted JSX <Link> components by placing attributes (className, href, target, rel) on separate lines; no change to the semantic functionality.
apps/.../audit/fetch.ts Updated AuditLogsResponse to use an optional number for nextCursor; revised fetchAuditLog and queryAuditLogs to simplify cursor handling and order logs by time.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AuditRouter
    participant Database

    Client->>AuditRouter: Request audit logs (with optional cursorTime)
    AuditRouter->>Database: Query logs ordered by time (filter: time > cursorTime)
    Database-->>AuditRouter: Return matching logs
    AuditRouter->>Client: Respond with logs and nextCursor (last log's time if more logs available)
Loading

Possibly related PRs

  • Fix URLs for terms #3053: Updates URLs and attributes in the <Link> components of the authenticated layout, directly related to the formatting modifications in this PR.

Suggested labels

Bug, Good first issue, 🕹️ oss.gg, :joystick: 150 points

Suggested reviewers

  • mcstepp
  • perkinsjr
  • ogzhanolguncu
  • MichaelUnkey

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d0f00d and 52a52a3.

📒 Files selected for processing (2)
  • apps/dashboard/app/auth/layout.tsx (1 hunks)
  • apps/dashboard/lib/trpc/routers/audit/fetch.ts (4 hunks)
🔇 Additional comments (7)
apps/dashboard/app/auth/layout.tsx (2)

112-117: Code formatting improvement

The formatting change to place each Link attribute on its own line enhances readability while maintaining the same functionality.


121-126: Code formatting improvement

Similar to the previous Link element, this formatting change improves code readability by placing each attribute on its own line.

apps/dashboard/lib/trpc/routers/audit/fetch.ts (5)

13-13: Schema simplification

Good change simplifying the nextCursor type from an object to an optional number. This aligns with the PR goal of using only time as cursor.


68-68: Simplified cursor logic

The implementation properly aligns with the schema change by returning only the timestamp as the cursor value instead of a composite object.


81-81: Simplified cursor structure

This change properly handles the cursor input parameter, creating a simpler cursor object with only the time parameter.


99-99: Improved filtering logic

The filtering logic has been updated to only use time for pagination, which is more efficient and consistent with the simplified cursor approach.


104-104:

Details

✅ Verification successful

Updated ordering criteria

Changing the ordering from id to time ensures consistency with the cursor-based pagination that now uses only time.


🏁 Script executed:

#!/bin/bash
# Check if there are other parts of the code that might still be relying on id-based ordering
rg --type ts "orderBy.*id" --glob "**/*.ts" -A 2 -B 2

Length of output: 2959


Approval: Ordering criteria updated for audit fetch is consistent with new pagination logic.

The change in apps/dashboard/lib/trpc/routers/audit/fetch.ts to order by time (line 104) is correct and aligns with the cursor-based pagination, which now only supports time-based ordering. We verified that while other parts of the codebase (e.g., in migration scripts and API route handlers) still use ordering by id, these instances appear to serve distinct purposes and aren’t affected by the pagination update.

  • apps/dashboard/lib/trpc/routers/audit/fetch.ts: Correctly updated ordering to use time to ensure pagination consistency.
  • Other files retaining id ordering (as shown in the grep results) seem intended for their specific use cases.

Overall, the change is appropriate and no further modifications are needed in this context.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@vercel vercel bot temporarily deployed to Preview – play March 31, 2025 14:34 Inactive
@vercel vercel bot temporarily deployed to Preview – engineering March 31, 2025 14:34 Inactive
@vercel vercel bot temporarily deployed to Preview – www March 31, 2025 14:35 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard March 31, 2025 14:37 Inactive
@chronark chronark merged commit 343b1e4 into main Mar 31, 2025
35 of 37 checks passed
@chronark chronark deleted the audit-log-cursor branch March 31, 2025 14:45
@github-actions
Copy link
Contributor

github-actions bot commented Mar 31, 2025

Thank you for following the naming conventions for pull request titles! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant