Skip to content

Added language as a filter to explore/repo_search #24212

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

Closed
wants to merge 0 commits into from

Conversation

snematoda
Copy link

@snematoda snematoda commented Apr 19, 2023

mobile landscape

Added a new language filter beside the existing sort for repos in explore

@silverwind silverwind added type/feature Completely new functionality. Can only be merged if feature freeze is not active. topic/ui Change the appearance of the Gitea UI labels Apr 19, 2023
@silverwind silverwind added this to the 1.20.0 milestone Apr 19, 2023
Copy link
Contributor

@JakobDev JakobDev left a comment

Choose a reason for hiding this comment

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

I was already working on this and almost finished, but you were faster. I have left a few comments with the toughs I was facing during developing this.

@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 20, 2023
@silverwind
Copy link
Member

Any screenshot?

@snematoda
Copy link
Author

Any screenshot?

Sure!
Just updated the PR message

@lunny
Copy link
Member

lunny commented Apr 23, 2023

I will send my LGTM now. But a further step is to use async menus with a search box because the programming languages may be very big on public websites.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 23, 2023
@JakobDev
Copy link
Contributor

But a further step is to use async menus with a search box because the programming languages may be very big on public websites

I think this should be done, before this is merged.

@snematoda
Copy link
Author

snematoda commented Apr 24, 2023

But a further step is to use async menus with a search box because the programming languages may be very big on public websites

I think this should be done, before this is merged.

Just added search

@silverwind
Copy link
Member

silverwind commented Apr 24, 2023

I will send my LGTM now. But a further step is to use async menus with a search box because the programming languages may be very big on public websites.

Please define "big". The number after which to go async depends on the dropdown performance. I have other UIs where I don't consider pagination until 10k items. Test first how many items the dropdown can render performantly, and then decide whether pagination is worth it. How big can the language list get? Maybe 200?

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 24, 2023
@silverwind silverwind added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Apr 24, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 24, 2023
@silverwind silverwind added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Apr 24, 2023
@snematoda
Copy link
Author

Test first how many items the dropdown can render performantly, and then decide whether pagination is worth it.

Well, I don't think I have the resources to test on even a moderately sized instance.

However initially, rendering .LanguagesColor (~500 items) directly from enry (without db calls) seemed fine

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 24, 2023
@silverwind
Copy link
Member

@JakobDev looking good?

@JakobDev
Copy link
Contributor

The API needs a little bit of improvement. If you want to get all languages for a User you need o load all Repos of that User and pass the IDs to /repos/languages. I think we should also add /user/{username}/languages and /org/{orgs}/languages to get the languages for a User/Org.

We need also tests for the API to make sure it keeps working as expected. If you don't know how to write tests, I can do that for you.

func GetPrimaryRepoLanguageList(ctx context.Context, repos RepositoryList) (LanguageStatList, error) {
languageList := make(LanguageStatList, 0)

q := db.GetEngine(ctx).
Copy link
Member

@lafriks lafriks Aug 21, 2023

Choose a reason for hiding this comment

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

I don't think this will perform well in large instances.

Copy link
Author

Choose a reason for hiding this comment

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

Discussed at #24212 (comment)

Unsure what the ideal alternative would be

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a new table to store the languages and counts

Copy link
Author

Choose a reason for hiding this comment

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

Maybe add a new table to store the languages and counts

Hmm, might work for the global list but unsure how to filter them by the repo owner since a few databases do not support storing primitive types as an array. Might be possible to create yet another table containing a the list of owners but tbf I wonder if the benefits would be worth it at that point

@snematoda
Copy link
Author

The API needs a little bit of improvement. If you want to get all languages for a User you need o load all Repos of that User and pass the IDs to /repos/languages. I think we should also add /user/{username}/languages and /org/{orgs}/languages to get the languages for a User/Org.

@JakobDev I have added a query param for the ownerId (ignored when repo ids are provided fn) ... felt it was easier than adding multiple api routes :P

We need also tests for the API to make sure it keeps working as expected. If you don't know how to write tests, I can do that for you.

Thank you! I have added in a minimal test fn

@JakobDev
Copy link
Contributor

You should really add the routes I mentioned instead of using a query param. that would match the behaviour of the other routes together with a test for each. That's mostly copy and paste.

Thank you! I have added in a minimal test fn

You should also check if the values are correct to make sure this doesn't break in the future.

@lunny lunny modified the milestones: 1.21.0, 1.22.0 Sep 21, 2023
@github-actions github-actions bot added modifies/translation modifies/api This PR adds API routes or modifies them modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/frontend modifies/docs modifies/migrations modifies/internal labels Jan 25, 2024
@lunny lunny closed this Jan 25, 2024
@GiteaBot GiteaBot removed this from the 1.22.0 milestone Jan 25, 2024
@lunny
Copy link
Member

lunny commented Jan 25, 2024

@snematoda Can you send the PR again? I want to resolve the conflicts but made the PR broken.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/docs modifies/internal modifies/migrations modifies/translation topic/ui Change the appearance of the Gitea UI type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants