fix: list workspaces should exclude deleted workspaces#328
fix: list workspaces should exclude deleted workspaces#328think-in-universe merged 1 commit intomainfrom
Conversation
Summary of ChangesHello @think-in-universe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial fix to the workspace listing mechanism. Previously, the system might have returned both active and inactive workspaces, leading to potentially irrelevant data being displayed. The change ensures that all workspace listings are accurately filtered to only include currently active workspaces, thereby improving data integrity and user experience by presenting only relevant information. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Code ReviewThis is a small but important fix that ensures only active workspaces are returned when listing workspaces for an organization. ✅ No Critical Issues FoundThe change correctly adds the Minor ObservationThe fix is consistent with the existing pattern in the codebase. I verified that the Production Safety
Overall Assessment: ✅ APPROVED The change is correct, minimal, and follows existing patterns in the codebase. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the list_by_organization_paginated method was returning all workspaces (both active and inactive) instead of only active ones. The fix adds the AND is_active = true filter to the SQL query to match the behavior of other workspace listing methods.
Key Changes
- Added
AND is_active = truefilter to the paginated workspace listing query to ensure only active workspaces are returned
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an issue where listing workspaces with pagination would include inactive workspaces. The change adds an AND is_active = true filter to the SQL query, making it consistent with other workspace-listing functions. I've included one suggestion to improve maintainability by replacing SELECT * with an explicit column list. This is a good practice that could be applied to other queries in this file for consistency.
| client | ||
| .query( | ||
| &format!("SELECT * FROM workspaces WHERE organization_id = $1 ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"), | ||
| &format!("SELECT * FROM workspaces WHERE organization_id = $1 AND is_active = true ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"), |
There was a problem hiding this comment.
For better maintainability and to avoid fetching unnecessary data, it's a good practice to specify columns explicitly instead of using SELECT *. This makes the query's dependencies on the table schema clear and can prevent issues if the table is altered (e.g., adding large columns that would be fetched unnecessarily).
| &format!("SELECT * FROM workspaces WHERE organization_id = $1 AND is_active = true ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"), | |
| &format("SELECT id, name, display_name, description, organization_id, created_by_user_id, created_at, updated_at, is_active, settings FROM workspaces WHERE organization_id = $1 AND is_active = true ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"), |
|
This has been temporarily fixed in frontend in this PR: https://github.com/nearai/nearai-cloud-ui/pull/149 |
Fixes https://github.com/nearai/nearai-cloud-ui/issues/139