-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Conversation
8d1c9d1
to
062b2c9
Compare
Will this also work for the search bar? For instance you could use |
062b2c9
to
8fe2c37
Compare
GET /@:username/tagged/:hashtag GET /api/v1/accounts/:id/statuses?tagged=:hashtag
2b72637
to
eb6672e
Compare
eb6672e
to
425a876
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
* Add hashtag filter to profiles GET /@:username/tagged/:hashtag GET /api/v1/accounts/:id/statuses?tagged=:hashtag * Display featured hashtags on public profile * Use separate model for featured tags * Update featured hashtag counters on-write * Limit featured tags to 10
* Add hashtag filter to profiles GET /@:username/tagged/:hashtag GET /api/v1/accounts/:id/statuses?tagged=:hashtag * Display featured hashtags on public profile * Use separate model for featured tags * Update featured hashtag counters on-write * Limit featured tags to 10
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: