Commit Graph

15 Commits

Author SHA1 Message Date
evazion
a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00
evazion
f1b5c34b4d posts: show length of videos and animations in thumbnails.
Show the length of videos and animated posts in the thumbnail. The
length is shown the top left corner in MM:SS format. This replaces the
play button icon.

Show a speaker icon instead of a music note icon for posts with sound.

Doing this requires doing `.includes(:media_asset)` in a bunch of
places to avoid N+1 queries when we access the post's duration.
2021-10-25 02:56:55 -05:00
evazion
f78378cc69 recommendations: reduce cache lifetime to 5 minutes.
These calls aren't actually slow and don't need to be cached for long
periods of time.
2021-10-21 00:46:47 -05:00
evazion
00ca7526bb docs: add remaining docs for classes in app/logical. 2021-06-24 01:31:41 -05:00
evazion
07e23204b6 rubocop: fix various Rubocop warnings. 2021-06-17 04:17:53 -05:00
evazion
054ac51d47 policies: remove current request from context.
This refactors Pundit policies to only rely on the current user, not on
the current user and the current HTTP request. In retrospect, it was a
bad idea to include the current request in the Pundit context. It bleeds
out everywhere and there are many contexts (in tests and models) where
we only have the current user, not the current request. The previous
commit got rid of the only two places where we used it.
2021-01-17 00:57:59 -06:00
evazion
f38c38f26e search: split tag_match into user_tag_match / system_tag_match.
When doing a tag search, we have to be careful about which user we're
running the search as because the results depend on the current user.
Specifically, things like private favorites, private favorite groups,
post votes, saved searches, and flagger names depend on the user's
permissions, and whether non-safe or deleted posts are filtered out
depend on whether the user has safe mode on or the hide deleted posts
setting enabled.

* Refactor internal searches to explicitly state whether they're
  running as the system user (DanbooruBot) or as the current user.
* Explicitly pass in the current user to PostQueryBuilder instead of
  implicitly relying on the CurrentUser global.
* Get rid of CurrentUser.admin_mode? (used to ignore the hide deleted
  post setting) and CurrentUser.without_safe_mode (used to ignore safe
  mode).
* Change the /counts/posts.json endpoint to ignore safe mode and the
  hide deleted posts settings when counting posts.
* Fix searches not correctly overriding the hide deleted posts setting
  when multiple status: metatags were used (e.g. `status:banned status:active`)
* Fix fast_count not respecting the hide deleted posts setting when the
  status:banned metatag was used.
2020-05-07 03:29:44 -05:00
evazion
2445e8b82f favorites: convert user.hide_favorites? to pundit. 2020-03-21 23:06:42 -05:00
evazion
eddd43c21f recommender: fix typo in recommend_for_user. 2019-12-17 02:24:44 -06:00
evazion
0adec60259 recommender: replace HttpartyCache with Danbooru::Http. 2019-12-15 15:48:38 -06:00
evazion
27a1a90cf3 recommendations: allow filtering recs by tags. 2019-12-02 03:08:01 -06:00
evazion
efda9f37e1 recommendations: add search form, allow searching by username. 2019-12-02 02:26:21 -06:00
evazion
ae46f7a665 recommendations: hide recommendations for users with private favorites.
Don't allow users to view recommendations for users who have private
favorites.
2019-12-01 19:07:55 -06:00
evazion
fa985f08ab recommendations: filter out own uploads and favorites.
Filter out the user's own uploads and favorites from their
recommendations.

Note that in most cases a user's top-N recommendations will be things
they've already favorited. If a user has 10,000 favorites, most of their
top 10,000 recommendations will be their own favorites, so we have to
generate a little more than 10,000 recommendations to be sure they won't
all be filtered out.

In other words, the more favorites a user has, the more recommendations
we have to generate. The upper bound is clamped to 50,000 for
performance reasons. If a user has more favorites than this we may not
be able to find any recommendations for them.
2019-12-01 19:03:26 -06:00
evazion
41b30fc64c recommendations: open user recommendations to all users.
* Open recommendations to all users (not just gold).
* Show recommendations on all posts (not just posts after 2017).
* Allow users to browse recommendations for other users.
* Increase number of recommended posts returned.
* Change endpoints to /recommended_posts?user_id=1234 and
  /recommended_posts?post_id=1234 and add json/xml support.
2019-12-01 00:44:04 -06:00