Commit Graph

426 Commits

Author SHA1 Message Date
evazion
6dd331745a Rewrite related tags implementation.
Rewrite the implementation of related tags to be simpler, faster, and
more accurate:

* The related tags are now calculated by taking a random sample of 1000
  posts, finding the top 250 most frequent tags among those posts, then
  ordering those tags by cosine similarity.

* Related tags can generally be calculated in 50-300ms at these sample
  sizes. Very high sample sizes (25000+ posts) are still relatively fast
  (1-3 seconds), but generally they don't improve accuracy much.

* Related tags are now cached in redis rather than in the tags table.
  The related_tags column in the tags table is no longer used.

* Only the related tags in the search taglist are cached. The related
  tags returned by the 'Related tags' button are not cached.

* The cache lifetime is a fixed 4 hours.

* The 'Related tags' button now works with metatags.

* The /related_tag page now works with metatags and multitag searches.

Fixes #4134, #4146.
2019-08-30 20:03:36 -05:00
evazion
9a3e9747d8 users: replace scopes with associations. 2019-08-29 20:42:50 -05:00
evazion
d73895312e Avoid swallowing exceptions unnecessarily. 2019-08-29 00:51:52 -05:00
evazion
59b277ead1 users: drop id_to_name, name_to_id caching.
Changes:

* Drop Users.id_to_name.
* Don't cache Users.name_to_id.
* Replace calls to name_to_id with find_by_name when possible.
* Don't autodefine creator_name in belongs_to_creator.
* Don't autodefine updater_name in belongs_to_updater.
* Instead manually define creator_name / updater_name only on models that need
  to return these fields in the api.

id_to_name was cached to reduce the impact of N+1 query patterns in
certain places, especially in api responses that return creator_name /
updater_name fields. But it still meant we were doing N calls to
memcache. Using `includes` to prefetch users avoids this N+1 pattern.

name_to_id had no need be cached, it was never used in any performance-
sensitive contexts.

Avoiding caching also avoids the need to keep these caches consistent.
2019-08-18 11:24:42 -05:00
evazion
a64cd50be4 profiles: add account upgrade link. 2019-08-15 12:51:51 -05:00
evazion
bda69315ff search: optimize related tag calc in multi-tag searches (#4120).
In multi-tag searches, we calculated the tags in the sidebar by sampling
300 random posts from within the search and finding the most frequently
used tags. This meant we were effectively doing two searches on every
page load, one for the actual search and one for the sidebar. This is
not so bad for fast searches, but very bad for slow searches.

Instead, now we calculate the related tags from the current page of
results. This is much faster, at the cost of slightly lower accuracy and
the tag list changing slightly as you browse between pages.

We could use caching here, which would help when browsing between pages,
but we would still have to calculate the tags on the first page load,
which can be very slow in the worst case.
2019-08-12 13:38:45 -05:00
evazion
6d171f44c4 pools/show: remove unused related tags calculation. 2019-08-09 00:05:50 -05:00
evazion
692981e964 Fix #4111: Cache custom CSS. 2019-08-01 00:06:18 -05:00
Albert Yi
d8aabff77b remove post keeper references 2019-01-31 15:45:06 -08:00
evazion
7478c7a913 Fix #4034: Several keyboard shortcuts are missing an ID. 2019-01-03 17:19:16 -06:00
Albert Yi
0508b127fd continue refactoring savedsearch 2018-11-15 12:06:13 -08:00
Albert Yi
8515bf43b4 make popular tags for order:rank higher priority in list 2018-11-07 16:30:14 -08:00
evazion
bd0bb658b8 Fix #3974: Pool galleries: link thumbnails to pools instead of posts. 2018-11-06 14:33:04 -06:00
evazion
841104f09a post presenter: fixup typo in 26c1eadf. 2018-11-06 13:15:09 -06:00
evazion
26c1eadf6a modqueue: move score highlighting from js to presenter.
The 'post-has-children' class was dropped because it was unused
('post-status-has-children' is already added elsewhere).
2018-11-06 10:42:48 -06:00
Albert Yi
9ddb9cd434 use only 1 copyright tag by default in humanized essential tag string 2018-11-05 14:34:07 -08:00
Albert Yi
5d83864131 fix bug with post previews 2018-11-02 16:38:28 -07:00
Albert Yi
08da9e7104 show popular tags when showing order:rank 2018-11-02 16:18:53 -07:00
Albert Yi
1a41ccf7ba fix ids of post previews 2018-11-02 15:51:14 -07:00
Albert Yi
542641e3e2 refactor pool nav html 2018-11-01 17:42:49 -07:00
Albert Yi
e334c34836 fix image container html 2018-10-31 16:15:07 -07:00
evazion
39374a70d3 posts/show: rename tags params to q in various places.
Fixup for 011a6f1f7.
2018-10-30 11:32:07 -05:00
Albert Yi
011a6f1f7c move post preview presenter to partial 2018-10-29 17:46:45 -07:00
evazion
0966a290e4 Fix #3941: Add ability to search users by inviter. 2018-10-04 12:44:59 -05:00
evazion
0c5452cdc3 Fix #3937: Blank lines in tagbox if certain taggroups are absent 2018-10-01 19:47:39 -05:00
evazion
88a177e1d5 TagSetPresenter: refactor humanized_essential_tag_string.
Move Post#humanized_essential_tag_string to TagSetPresenter#humanized_essential_tag_string.

This allows humanized_essential_tag_string to reuse the same set of tags
already fetched by the tag set presenter for the sidebar.

This avoids fetching the tag categories from memcache again (via
Post#typed_tags) when we're already fetched the tags once before.

This also means it's no longer necessary to cache humanized_essential_tag_string
itself in memcache, since it can be generated as quickly as the sidebar taglist.
2018-09-30 21:52:24 -05:00
evazion
739bb1270c TagSetPresenter: refactor tag string for post edit form.
Move PostPresenter#categorized_tag_groups to TagSetPresenter#split_tag_list_text.

This allows split_tag_list_text to reuse the same set of tags already
fetched by the tag set presenter for the sidebar.

This avoids a memcache call to get the tag categories when rendering the
tag string for the post edit form.
2018-09-30 21:52:24 -05:00
evazion
b1f2096d72 TagSetPresenter: refactor *_tag_list_html to avoid memcache calls.
Refactor the tag set presenter to get both the tag categories and the
tag counts in the same call to the database, instead of getting the
counts from the db and the categories from memcache.
2018-09-30 21:52:24 -05:00
evazion
99632d5e8a TagSetPresenter: refactor to pass options explicitly.
Refactor tag_list_html, split_tag_list_html, and inline_tag_list_html to
take the `show_extra_links` and `current_query` options explicitly,
rather than implicitly relying on CurrentUser or taking `params[:tags]`
from the template.
2018-09-30 21:52:24 -05:00
evazion
03abbd0683 Fix #2894: Use [[:space:]] instead of \s in regexes. 2018-09-20 19:24:38 -05:00
evazion
29cdaddd86 PostSetPresenters::Post#related_posts: clean up metatag parsing (#2894).
* Fix `#related_tags` to use `Tag.has_metatag?`.
* Fix Tag::SUBQUERY_METATAGS and Tag::METATAGS to be arrays instead of regexes.
2018-09-20 19:23:47 -05:00
evazion
bbb233b93f css: remove unused or redundant rules. 2018-09-14 13:31:59 -05:00
evazion
22c27f8910 post previews: fix css for captioned post previews.
Captioned post previews (previews with the pool name, similarity, or
size beneath) need to have `height: auto` set, otherwise they'll default
to `height: 154px` (just enough for the image) and the caption won't be visible.
2018-09-06 20:44:47 -05:00
evazion
bbaadda1e3 Convert keyboard shortcuts to use data-shortcut. 2018-08-12 12:09:58 -05:00
Albert Yi
b56681a609 refactor solution for #3804 2018-08-07 13:31:45 -07:00
Albert Yi
80e0ae6a3c hide detailed exception info in upload status (#3804) 2018-08-07 13:05:06 -07:00
Albert Yi
718e641f51 remove similar users report 2018-08-03 17:40:00 -07:00
Albert Yi
76342582b2 add fallback for older previews 2018-07-18 13:02:05 -07:00
Albert Yi
a610111658 switch post previews to use flexbox, add better styling for cropped thumbnails 2018-07-18 11:38:00 -07:00
Albert Yi
4d4f36c2c8 make image cropping optional 2018-07-09 10:07:51 -07:00
Albert Yi
56b40a0255 add iqdb preview 2018-06-22 16:41:13 -07:00
Albert Yi
64446d49e1 add image cropping support 2018-06-22 14:41:57 -07:00
Albert Yi
72f319ccf3 rename lambda references to use shorthand syntax 2018-05-10 11:18:02 -07:00
evazion
a6499b5169 post tooltips: add disable option (#3689).
* Add "disable post tooltips" account setting.
* Add back title attribute for when fancy tooltips are disabled.
2018-04-28 23:50:51 -05:00
Albert Yi
9aafc344fa Merge pull request #3666 from evazion/fix-3664
Fix #3664: Highlight non-gentags in post tooltip
2018-04-26 11:40:59 -07:00
Albert Yi
4b6019d6ad fixes #3668 2018-04-26 10:25:24 -07:00
evazion
e772de40a7 posts: add /posts/{id}.html?variant=tooltip template. 2018-04-25 22:12:26 -05:00
evazion
f2998585e9 tag_set_presenter: refactor inline_tag_list_html.
* Sort tags by category in inline tag lists (on /comments page, /uploads page, and modqueue).
* Move tags css to common/erb/tags.scss.erb.
2018-04-25 22:12:10 -05:00
evazion
442964b0eb tag_set_presenter: refactor split_tag_list_html.
* Make category headers optional.
* Make category order configurable.
* Clean up code.
2018-04-25 22:12:10 -05:00
Albert Yi
f3e62f43ba Merge pull request #3658 from evazion/fix-3657
Fix #3657: Add improvements to the uploads interface
2018-04-20 16:03:39 -07:00