Add search and sort functions to hashtag admin UI#11829
Add search and sort functions to hashtag admin UI#11829Gargron merged 4 commits intomastodon:masterfrom
Conversation
| scope = scope.reviewed.order(reviewed_at: :desc) if filter_params[:review] == 'reviewed' | ||
| scope = scope.pending_review.order(requested_review_at: :desc) if filter_params[:review] == 'pending_review' | ||
| scope.order(max_score: :desc) | ||
| scope = scope.matches_name(filter_params[:name].to_s.strip) unless filter_params[:name].nil? |
There was a problem hiding this comment.
Are there security concerns about the entered value?
| must_be_following: Block notifications from people you don't follow | ||
| must_be_following_dm: Block direct messages from people you don't follow | ||
| invite: | ||
| comment: Comment |
There was a problem hiding this comment.
This translation has nothing to do with this PR.
However, this is necessary for translating invitation link comments.
I would like to include this translation in this PR if possible.
|
|
||
| .actions | ||
| %button= t('admin.accounts.search') | ||
| = link_to t('admin.accounts.reset'), admin_tags_path, class: 'button negative' |
There was a problem hiding this comment.
These borrowed from existing translations.
Should I have these newly prepared?
There was a problem hiding this comment.
It's fine, we do that for other views with the same buttons.
ClearlyClaire
left a comment
There was a problem hiding this comment.
Looks fine to me overall, but other parts use a model to model the filters, e.g. the InstanceFilter model. Maybe it would be more consistent to do it that way too?
| scope = scope.reviewed.order(reviewed_at: :desc) if filter_params[:review] == 'reviewed' | ||
| scope = scope.pending_review.order(requested_review_at: :desc) if filter_params[:review] == 'pending_review' | ||
| scope.order(max_score: :desc) | ||
| scope = scope.matches_name(filter_params[:name].to_s.strip) unless filter_params[:name].nil? |
|
|
||
| .actions | ||
| %button= t('admin.accounts.search') | ||
| = link_to t('admin.accounts.reset'), admin_tags_path, class: 'button negative' |
There was a problem hiding this comment.
It's fine, we do that for other views with the same buttons.
Thank you very much! I will try to do that later. |
| when 'order' | ||
| scope_for_order(value) | ||
| when 'review' | ||
| scope_for_review(value) |
There was a problem hiding this comment.
I'm not sure if these method names are okay...
I'm also not sure if this is the best way to call these methods.
Is there a better idea?
| def scope_for(key, value) | ||
| case key.to_s | ||
| when 'context' | ||
| Tag.discoverable if value == 'directory' |
There was a problem hiding this comment.
What happens if scope.merge!(nil)?
There was a problem hiding this comment.
Oh… thank you, I will fix it.
* Add search and sort functions to hashtag admin UI * Move scope processing from tags_controller to tag_filter * Fix based on method naming conventions * Fixed not to get 500 errors for invalid requests
Add search and sort features to the hashtag page of the Admin UI.
In the "ORDER BY" field "MOST RECENT", "MOST POPULAR", and "LAST ACTIVE" do not know if this name is best.
Also, is this order appropriate?
They are sorted for the following reasons:
MOST RECENT
Sorted in order from the newly received hashtag by the server
MOST POPULAR
Sort in order from biggest "max_score"
LAST ACTIVE
Sorted in order from newest "last_status_at"
I think I should write a test too.
However, there are a lot of things I don't understand yet and I haven't built a test environment.