Skip to content

feat: allow searching and sorting templates #7318

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
matifali opened this issue Apr 27, 2023 · 17 comments
Open

feat: allow searching and sorting templates #7318

matifali opened this issue Apr 27, 2023 · 17 comments
Labels
customer-requested Features requested by enterprise customers. Only humans may set this. site Area: frontend dashboard

Comments

@matifali
Copy link
Member

matifali commented Apr 27, 2023

We should support Searching and Sorting on the Templates page.

  1. Searching: Search for templates by name
  2. Sorting: Sort the default order by any Column
  3. Filtering: Filtering does not make much sense here as Templates are not scoped to any users, etc.

Currently, the templates are sorted in a decreasing order by the Used by column.

Allow sorting by increasing or decreasing order by any of the columns, i.e., Name, Build time, Last updated etc.

@matifali
Copy link
Member Author

matifali commented Aug 4, 2023

We can now filter workspaces as was requested in #6037 but we are still missing sorting the templates and workspaces.
cc: @BrunoQuaresma @bpmct

@aslilac
Copy link
Member

aslilac commented Aug 18, 2023

wait, do we have workspace sorting, or just filtering? two very different things, and I can only find any evidence of filtering being in the app

sorting would also totally be a cool thing to add, just trying to get clarification on what the priority is

@matifali
Copy link
Member Author

matifali commented Aug 19, 2023

@aslilac you are right. I choose the wrong wording. We do not have sorting. But here I am requesting sorting and not filtering.

I have updated the issue to request, Searching, Sorting, and Filtering.

@BrunoQuaresma
Copy link
Collaborator

Yeah, we would need some BE work first.

@Emyrk
Copy link
Member

Emyrk commented Aug 21, 2023

Unfortunately we cannot do dynamic order by in SQLc (ASC, DESC). So to do this, and assuming you want to sort both ways, we need to solve that problem.

Which is a whole can of worms...

I talked to the SQLc authors about this, and they do acknowledge this as a problem, and are discussing solutions. But who knows when that will happen.

@aslilac
Copy link
Member

aslilac commented Aug 21, 2023

so it can sort on different columns, but the sort direction is fixed?

I think that'd be fine for now, if we're limited by sqlc. hopefully it'd be easy to add later once they figure things out on their end.

@aslilac
Copy link
Member

aslilac commented Aug 21, 2023

just spoke with @sreya about this, sounds like interest in pursuing this is currently low.

@bpmct bpmct changed the title feat: allow sorting templates by any of the columns feat: allow sorting and searching templates by any of the columns Nov 21, 2023
@bpmct
Copy link
Member

bpmct commented Nov 21, 2023

A customer also requested a search. I suggest we do both :)

I'm strongly in favor of moving to an index or view or something to make sorting more approachable. Custom table sorting and custom direction is quite common in other software and many of ourusers customers are unhappy with the default sort which is # of devs

@Emyrk
Copy link
Member

Emyrk commented Nov 22, 2023

It's annoying that this isn't easy for us. We'd need to duplicate our queries since SQLc doesn't support dynamic queries. Or we need to inject some dynamic element like we do for RBAC.

Either way, it is frustrating it is not trivial 😢

@matifali
Copy link
Member Author

Does upgrading to the latest sqlc help here?

@Emyrk
Copy link
Member

Emyrk commented Nov 22, 2023

Does upgrading to the latest sqlc help here?

It does not unfortunately. I am consistently talking with the SQLc guys though about solving some of these issues.

@matifali matifali changed the title feat: allow sorting and searching templates by any of the columns feat: allow searching and sorting templates by any of the columns Jan 3, 2024
@matifali matifali changed the title feat: allow searching and sorting templates by any of the columns feat: allow searching, filtering and sorting templates by any of the columns Jan 3, 2024
@matifali matifali changed the title feat: allow searching, filtering and sorting templates by any of the columns feat: allow searching and sorting templates by any of the columns Jan 3, 2024
@matifali matifali changed the title feat: allow searching and sorting templates by any of the columns feat: allow searching and sorting templates Jan 3, 2024
@glenn2wang
Copy link

what i want is search the template
if the template count big than 10 , it is a hard to find the template which is me need

@matifali matifali added the customer-requested Features requested by enterprise customers. Only humans may set this. label Jan 31, 2024
@ssncoder
Copy link
Contributor

Customer wants, search bar, want the templates to be sorted alphabetically instead of used by. Additionally wants a last used metric, for admin insights to maintain the templates

@ssncoder
Copy link
Contributor

Another customer is asking, "The main table of available templates, please allow sorting other than by number of devs ... I have 43 templates, and they always "jump" around..."

@Emyrk
Copy link
Member

Emyrk commented Aug 21, 2024

TIL this is a valid way to handle dynamic ordering with a static query:

SELECT id, name, updated_at from templates
 ORDER BY
  CASE WHEN false THEN id END asc,
  CASE WHEN false THEN id END desc,
  CASE WHEN false THEN name END asc,
  CASE WHEN false THEN name END desc,
  CASE WHEN false THEN updated_at END asc,
  CASE WHEN true THEN updated_at END desc
 LIMIT 10 ;

CASE WHEN defaults to null, so you ORDER BY null (which cannot be done explicitly).

OpenAI states: (I cannot find docs to support this)

In SQL, when sorting by NULL, it effectively means that the sorting is non-deterministic because all values are the same (i.e., NULL).

You can do this to order by null:

SELECT id, name, updated_at from templates
ORDER BY
	CASE WHEN true THEN null END asc
LIMIT 10 

In my limited testing, I think this will work 🤔

A proposed production-like query

SELECT id, name, updated_at from templates
 ORDER BY
  CASE WHEN @id_asc::bool THEN id END asc,
  CASE WHEN @id_desc::bool THEN id END desc,
  CASE WHEN @name_asc::bool THEN name END asc,
  CASE WHEN @name_desc:bool THEN name END desc,
  CASE WHEN @updated_at_asc::bool THEN updated_at END asc,
  CASE WHEN @updated_at_desc::bool THEN updated_at END desc
 LIMIT 10 

@aslilac
Copy link
Member

aslilac commented Aug 22, 2024

oh weird. what does CASE WHEN false THEN x END evaluate to?

@Emyrk
Copy link
Member

Emyrk commented Aug 22, 2024

@aslilac it evals to null

@matifali matifali removed the feature label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-requested Features requested by enterprise customers. Only humans may set this. site Area: frontend dashboard
Projects
None yet
Development

No branches or pull requests

7 participants