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 hashtag filter to profiles #9755

Merged
merged 5 commits into from Feb 4, 2019

Conversation

Projects
None yet
3 participants
@Gargron
Copy link
Member

Gargron commented Jan 8, 2019

screenshot_2019-02-03 admin admin localhost 3000

Allow browsing a profile by a specific hashtag. Useful for artists.

Public profile change: GET /@:username/tagged/:hashtag
REST API change: GET /api/v1/accounts/:id/statuses?tagged=:hashtag


TODO:

  • Public profile page route
  • REST API
  • List of browserable hashtags in sidebar on public profile

@Gargron Gargron force-pushed the feature-profile-hashtags branch from 8d1c9d1 to 062b2c9 Jan 8, 2019

@MirceaKitsune

This comment has been minimized.

Copy link

MirceaKitsune commented Jan 11, 2019

Will this also work for the search bar? For instance you could use #sometag@username@domain to only list posts containing that tag from the user in cause. Additionally just #sometag@domain would be a very welcome syntax, allowing you to search for a tag on a specific instance only.

@Gargron Gargron force-pushed the feature-profile-hashtags branch from 062b2c9 to 8fe2c37 Feb 3, 2019

@Gargron Gargron added the ui label Feb 3, 2019

Gargron added some commits Jan 8, 2019

Add hashtag filter to profiles
GET /@:username/tagged/:hashtag
GET /api/v1/accounts/:id/statuses?tagged=:hashtag

@Gargron Gargron force-pushed the feature-profile-hashtags branch 3 times, most recently from 2b72637 to eb6672e Feb 4, 2019

@Gargron Gargron force-pushed the feature-profile-hashtags branch from eb6672e to 425a876 Feb 4, 2019

@@ -78,12 +79,15 @@ def no_replies_scope
Status.without_replies
end

def hashtag_scope
Status.tagged_with(Tag.find_by(name: params[:tag].downcase)&.id)

This comment has been minimized.

@krainboltgreene

krainboltgreene Feb 4, 2019

Member

Not sure what the project's preference is, but I've been seeing a lot of people move from #[] to #fetch() since it tells the reader a lot more about the intent. For example, in this method we EXPECT :tag to be a key, thus params.fetch(:tag), but if we didn't params.fetch(:tag, nil) and of course we get all the niceness of #fetch's other default api: fetch(:key) {dynamicvalue}.

Either way, seems like what you want here could also be expressed as: Status.tagged_with(Tag.where(name: params[:tag]).pluck(:id).first), though if tagged_with allows an array you can just drop .first.

Gargron added some commits Feb 4, 2019

@Gargron Gargron merged commit 364f2ff into master Feb 4, 2019

11 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: check-i18n Your tests passed on CircleCI!
Details
ci/circleci: install Your tests passed on CircleCI!
Details
ci/circleci: install-ruby2.4 Your tests passed on CircleCI!
Details
ci/circleci: install-ruby2.5 Your tests passed on CircleCI!
Details
ci/circleci: install-ruby2.6 Your tests passed on CircleCI!
Details
ci/circleci: test-ruby2.4 Your tests passed on CircleCI!
Details
ci/circleci: test-ruby2.5 Your tests passed on CircleCI!
Details
ci/circleci: test-ruby2.6 Your tests passed on CircleCI!
Details
ci/circleci: test-webui Your tests passed on CircleCI!
Details
codeclimate All good!
Details

@Gargron Gargron deleted the feature-profile-hashtags branch Feb 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment