Skip to content

Add sorting options for Users list beyond "Signed Up At" #699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

gitstart-opensource
Copy link

@gitstart-opensource gitstart-opensource commented May 31, 2025


Important

Adds sorting options for Users list by 'display_name', 'primary_email', and 'last_active_at', with backend and frontend support.

  • Backend:
    • In crud.tsx, updated order_by to include 'display_name', 'primary_email', and 'last_active_at'.
    • Implemented custom sorting logic for 'primary_email' and 'last_active_at' fields.
  • Frontend:
    • In user-table.tsx, enabled sorting for 'displayName', 'primaryEmail', and 'lastActiveAt' columns.
    • Updated orderMap in UserTable to map new sorting options to backend fields.

This description was created by Ellipsis for 35ac05f. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented May 31, 2025

@gitstart is attempting to deploy a commit to the Stack Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

recurseml bot commented May 31, 2025

✨ No issues found! Your code is sparkling clean! ✨

🗒️ View all ignored comments in this repo
  • The constraint 'TokenStoreType extends string' is too restrictive. It should likely be 'TokenStoreType extends string | object' to match the condition check in line 113 where TokenStoreType is checked against {}
  • Return type mismatch - the interface declares useUsers() returning ServerUser[] but the Team interface that this extends declares useUsers() returning TeamUser[]
  • There is a syntax error in the super constructor call due to the ellipsis operator used incorrectly. Objects aren't being merged correctly. This syntax usage can lead to runtime errors when trying to pass the merged object to 'super()'. Verify that the intended alterations to the object occur before or outside of the super() call if needed.
  • Throwing an error when no active span is found is too aggressive. The log function should gracefully fallback to console.log or another logging mechanism when there's no active span, since not all execution contexts will have an active span. This makes the code less resilient and could break functionality in non-traced environments.

📚 Relevant Docs

  • Function sets backendContext with a new configuration but doesn't pass 'defaultProjectKeys'. Since defaultProjectKeys is required in the type definition and cannot be updated (throws error if tried to set), this will cause a type error.
  • The schema is using array syntax for pick() which is incorrect for Yup schemas. The pick() method in Yup expects individual arguments, not an array. Should be changed to: emailConfigSchema.pick('type', 'host', 'port', 'username', 'sender_name', 'sender_email')

📚 Relevant Docs

  • Creating a refresh token with current timestamp as expiration means it expires immediately. Should set a future date for token expiration.
  • The 'tools' object is initialized as an empty object, even though 'tools' is presumably expected to contain tool definitions. This could cause the server capabilities to lack necessary tool configurations, thus potentially impacting functionalities that depend on certain tool setups.

📚 Relevant Docs

  • 'STACK_SECRET_SERVER_KEY' is potentially being included in every request header without checking its existence again here. Although it's checked during initialization, this could lead to security issues as it's exposed in all communications where the header is logged or captured.

📚 Relevant Docs

  • When adding 'use client' directive at the beginning, it doesn't check if file.text already contains the 'use client' directive. This could lead to duplicate 'use client' directives if the file already has one.

📚 Relevant Docs

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added sorting capabilities to the Users list by implementing sortable columns for Display Name, Primary Email, and Last Active timestamps.

  • Added sorting functionality in apps/dashboard/src/components/data-table/user-table.tsx for Display Name, Primary Email, and Last Active columns
  • Implemented backend sorting logic in apps/backend/src/app/api/latest/users/crud.tsx with specialized handling for computed fields
  • Added order mapping in crud.tsx to translate frontend column IDs to backend field names
  • Implemented in-memory sorting for primary_email and last_active_at fields with cursor-based pagination
  • Potential performance consideration: In-memory sorting approach may impact performance with large datasets

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@gitstart-opensource
Copy link
Author

@greptileai

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added performance optimization for sorting large user lists by implementing database-level sorting instead of in-memory operations.

  • Replaced in-memory sorting with SQL ORDER BY clauses in apps/backend/src/app/api/latest/users/crud.tsx for better scalability
  • Added database indexes on display_name, primary_email, and last_active_at columns to optimize sort performance
  • Updated query construction to handle NULL values appropriately in sort operations
  • Maintained existing cursor-based pagination while leveraging database sorting

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@gitstart-opensource
Copy link
Author

Current Feature
prod-stackauth-1-filtering.mp4
stackauth-1-filtering.mp4

Copy link
Contributor

@N2D4 N2D4 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Please sign the CLA

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.

4 participants