Skip to content

Add search and sort functions to hashtag admin UI#11829

Merged
Gargron merged 4 commits intomastodon:masterfrom
mayaeh:feature_hashtag-admin-ui-searchable
Sep 16, 2019
Merged

Add search and sort functions to hashtag admin UI#11829
Gargron merged 4 commits intomastodon:masterfrom
mayaeh:feature_hashtag-admin-ui-searchable

Conversation

@mayaeh
Copy link
Copy Markdown
Contributor

@mayaeh mayaeh commented Sep 13, 2019

Add search and sort features to the hashtag page of the Admin UI.

2019-09-13 21 17 02

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.

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?
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Are there security concerns about the entered value?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine to me.

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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These borrowed from existing translations.
Should I have these newly prepared?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's fine, we do that for other views with the same buttons.

Copy link
Copy Markdown
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

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

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?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine to me.


.actions
%button= t('admin.accounts.search')
= link_to t('admin.accounts.reset'), admin_tags_path, class: 'button negative'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's fine, we do that for other views with the same buttons.

@mayaeh
Copy link
Copy Markdown
Contributor Author

mayaeh commented Sep 13, 2019

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?

Thank you very much! I will try to do that later.

Comment thread app/models/tag_filter.rb Outdated
when 'order'
scope_for_order(value)
when 'review'
scope_for_review(value)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems OK.

Comment thread app/models/tag_filter.rb Outdated
def scope_for(key, value)
case key.to_s
when 'context'
Tag.discoverable if value == 'directory'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What happens if scope.merge!(nil)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh… thank you, I will fix it.

@mayaeh mayaeh changed the title Add search and sort functions to hashtag admin UI [WIP]Add search and sort functions to hashtag admin UI Sep 15, 2019
@mayaeh mayaeh changed the title [WIP]Add search and sort functions to hashtag admin UI Add search and sort functions to hashtag admin UI Sep 16, 2019
@Gargron Gargron merged commit ef0d22f into mastodon:master Sep 16, 2019
@mayaeh mayaeh deleted the feature_hashtag-admin-ui-searchable branch September 17, 2019 00:42
Gargron added a commit that referenced this pull request Sep 20, 2019
Gargron added a commit that referenced this pull request Sep 26, 2019
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* 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
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants