Skip to content
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

fix: list projects with all archived toggles #3020

Merged
merged 2 commits into from
Jan 30, 2023

Conversation

gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Jan 30, 2023

About the changes

While trying to count only features that are not archived to display the amount of features of a project, accidentally we filtered out projects with all features archived (they should show up in the list but with count of features zero)

Improves: #2923

@gastonfournier gastonfournier self-assigned this Jan 30, 2023
@vercel
Copy link

vercel bot commented Jan 30, 2023

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

2 Ignored Deployments
Name Status Preview Comments Updated
unleash-docs ⬜️ Ignored (Inspect) Jan 30, 2023 at 1:27PM (UTC)
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Jan 30, 2023 at 1:27PM (UTC)

Copy link
Member

@ivarconr ivarconr left a comment

Choose a reason for hiding this comment

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

Nice fix, it feels so obvious why mine did not work when the solution is in front of me.

.orderBy('projects.name', 'asc');
if (query) {
projects = projects.where(query);
}
let selectColumns = [
this.db.raw(
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, count(features.name) AS number_of_features',
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, count(features.name) FILTER (WHERE features.archived_at is null) AS number_of_features',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Docs about filter on aggregate functions: https://www.postgresql.org/docs/current/sql-expressions.html

@gastonfournier gastonfournier enabled auto-merge (squash) January 30, 2023 13:28
@gastonfournier gastonfournier merged commit 8126049 into main Jan 30, 2023
@gastonfournier gastonfournier deleted the fix-projects-not-listed branch January 30, 2023 13:32
gastonfournier pushed a commit that referenced this pull request Jan 30, 2023
While trying to count only features that are not archived to display the
amount of features of a project, accidentally we filtered out projects
with all features archived (they should show up in the list but with
count of features zero)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants