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 sorting users by last login date #14947

Closed
wants to merge 2 commits into from
Closed

Conversation

noerw
Copy link
Member

@noerw noerw commented Mar 10, 2021

On the admin user listing, sorting users by last login date was actually sorting by last_updated_unix.

As the orgs listing doesn't have a last login column, I dropped the broken sorter there (thinking about adding more sort options in a followup).

fixes #14942

@noerw noerw added the type/bug label Mar 10, 2021
SearchOrderByForksReverse SearchOrderBy = "num_forks DESC"
// user
SearchOrderByRecentLogin SearchOrderBy = "last_login_unix ASC"
SearchOrderByRecentLoginReverse SearchOrderBy = "last_login_unix DESC"
Copy link
Member Author

Choose a reason for hiding this comment

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

should these be here or in models/user.go? I think it's neat to have them all grouped together

Copy link
Contributor

Choose a reason for hiding this comment

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

I already refactored them. So no worry now.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 10, 2021
@@ -12,6 +12,8 @@
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
<a class="{{if eq .SortType "recentupdate"}}active{{end}} item" href="{{$.Link}}?sort=recentupdate&q={{$.Keyword}}">{{.i18n.Tr "repo.issues.filter_sort.recentupdate"}}</a>
<a class="{{if eq .SortType "leastupdate"}}active{{end}} item" href="{{$.Link}}?sort=leastupdate&q={{$.Keyword}}">{{.i18n.Tr "repo.issues.filter_sort.leastupdate"}}</a>
<a class="{{if eq .SortType "recentlogin"}}active{{end}} item" href="{{$.Link}}?sort=recentlogin&q={{$.Keyword}}">{{.i18n.Tr "repo.issues.filter_sort.recentlogin"}}</a>
<a class="{{if eq .SortType "recentloginreverse"}}active{{end}} item" href="{{$.Link}}?sort=recentloginreverse&q={{$.Keyword}}">{{.i18n.Tr "repo.issues.filter_sort.recentloginreverse"}}</a>
Copy link
Member Author

@noerw noerw Mar 10, 2021

Choose a reason for hiding this comment

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

Not sure if we should add specific sorters like this to the dropdown, it is used for orgs listing as well where it doesn't apply.
In general it's a bit weird, that this template is shared by user & org listing, while an almost identical search template explore/search.tmpl exists, that actually would benefit from being shared between admin & explore listing..
Opinions?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please share templates if possible, we need to reduce duplication. What you could do is something like we already do for issue lists:

{{template "shared/issuelist" mergeinto . "listType" "dashboard"}}

This would merge a additional listType=dashboard property into the root context ., making it available to the sub-template. Keep note that mergeinto does clone the context once, so it'll induce a tiny performance hit, thought that should be okay for one-time rendered things like these lists.

Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need the shared templates anymore. See the latest code.

And shared templates bring more problems than they resolve.

@noerw noerw added the pr/wip This PR is not ready for review label Mar 12, 2021
@noerw noerw marked this pull request as draft March 17, 2021 22:05
@wxiaoguang
Copy link
Contributor

I think this problem can be easily fixed based on the recent code base.

ps: do we need database index for last_login_unix?

@wxiaoguang
Copy link
Contributor

It's inactive for more than one year, it could be replaced by #22081

@lunny lunny closed this Dec 9, 2022
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. pr/wip This PR is not ready for review type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin user listing: sort by last sign-in broken
5 participants