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

Add search and sort functions to hashtag admin UI #11829

Merged
merged 4 commits into from
Sep 16, 2019

Conversation

mayaeh
Copy link
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.

@@ -78,11 +74,14 @@ def filtered_tags
scope = scope.unreviewed if filter_params[:review] == 'unreviewed'
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
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
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.

@@ -131,6 +131,8 @@ en:
must_be_follower: Block notifications from non-followers
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
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
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
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
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?

@@ -78,11 +74,14 @@ def filtered_tags
scope = scope.unreviewed if filter_params[:review] == 'unreviewed'
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
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
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
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.

when 'order'
scope_for_order(value)
when 'review'
scope_for_review(value)
Copy link
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
Member

Choose a reason for hiding this comment

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

This seems OK.

def scope_for(key, value)
case key.to_s
when 'context'
Tag.discoverable if value == 'directory'
Copy link
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
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.

None yet

3 participants