* Refactoring cached_followed_tags
This refactor consolidates two queries and a loop into a single query.
One thing that is unclear is if we're ever really clearing the cache of
the user by id?
What follows is un-related to the refactor but appears to be related to #14937.
> First, I see we set a cache here:
>
> ebdaaaf15b/app/decorators/user_decorator.rb (L23-L34)
>
> But when I look at what busts the user cache, it doesn’t look like we’re busting it for the above cached location:
>
> ebdaaaf15b/app/services/edge_cache/bust_user.rb (L3-L22)
>
> What if anything am I missing in regards to cache busting?
* Adding some deprecated methods
* Updating documentation
* Bump for travis
* Bump for travis
* Updating comments to fix confusion
NOTE: I might be introducing more confusion, but at least
I'm addressing the prior confusion.
* Bump for travis
* Updating so we don't cache ActiveRecord objects
* Selecting only applicable attributes for caching
* Apply suggestions from code review
Co-authored-by: Michael Kohl <citizen428@forem.com>
* Adjusting code based on feedback
* Bump for travis
* Bump for travis
* Update app/decorators/user_decorator.rb
Co-authored-by: Michael Kohl <citizen428@forem.com>
Co-authored-by: Michael Kohl <citizen428@forem.com>
The fix might be a bit of a work-around for a more general approach, but
we're fighting against the magic of the points vs. explicit_points
tension as defined in the [Follows::UpdatePointsWorker][1].
That is to say, it's possible (and happens) where I have assigned an
`explicit_points` of 1 for a tag, but the calculated `points` are less
than 1. The calculated `points` are what we send forward in the
[AsyncInfoController][1] (by way of the
[UserDecorator#cached_followed_tags][3] method).
In DEV, I ran the following queries:
**User assigned points `>= 1` but calculated `< 1`**
985,352 records
```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
AND points < 1
AND explicit_points >= 1;
```
**User assigned points `>= 1` but calculated `>= 1`**
5,366,478 records
```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
AND points >= 1
AND explicit_points >= 1;
```
**User assigned points `>= 1` but calculated `>= 0`**
0 records.
```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
AND points <= 0
AND explicit_points >= 1;
```
**User assigned points `<= 0` but calculated `> 0`**
1,146 records
```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
AND points > 0
AND explicit_points <= 0;
```
Synthesizing that, almost 1 million tag follows of the total 6.3 million
are not showing up in the user's left navigation. And 5.3 million are
roughly correct.
In adjusting the logic, we're now going to have more tags showing up in
the left. And just over 1,000 might now show up that would be unexpected.
Closes#14937.
[1]:c63e0b629e/app/workers/follows/update_points_worker.rb
[2]:c63e0b629e/app/controllers/async_info_controller.rb (L40-L65)
[3]:c63e0b629e/app/decorators/user_decorator.rb (L23-L34)
* Separate followed and "anti-followed" tags
* Minor code change
* Indicate "anti-followed" tags in sidebar
* Fix UpdatePointsWorker spec
* Cries in Arel
* Use antifollow scope more selectively
* Add spec for not_cached_tagged_with_any scope
* Add explanatory comment
* Remove unused route
* Update comment
* Remove unrelated change, figure out why > 1 later
* Need more ☕
* Avoid false positives in spec
* Change handling of ingored tags in sidebar
* Add explanatory comment
* enable debug for warnings in dev env
* remove preact/devtools call no longer needed
* fix majority of proptype errors on home page
* sweep up proptype errors from listings page
* fix article form error
* Fix tag display bug and crayonsify
* Fix some specs
* Remove unused tag js
* Adjust to remove crayons card bg
* Adjust padding
* add spacing below nav
* drop unnecessary classname
* cleanup headers
* links
* Finalize style and add hint to eliminate div jump
Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>
* de-emphasizing right sidebar: mostly colors & spacing
* adding a bit more love to typography in sidebar
* changing language on LISTINGS widget header
* hiding profile widget from left sidebar
* cards shadow now looks like a bit less random and annoying
* actually doing the same with all shadows! YOLO
* some spacing cleanups around sidebars
* this time some typography love
* im committing but not really sure what exactly
* adding a bit more love to feed card
* looks like i broke some other views.. time to fix em all
* cleaning up typography a bit more
* .
* separating empty search results styling
* created a card styling mixing to reduce some code.. also moved cheese around a bit
* several more cleanups
* improving responsiveness
* i fixed what i broke
* more cleanups
* org badge
* .
* ...
* responsiveness
* .
* some adjustments
* bring back profile card
* tiny logo adjustment
* bunch of further refainments
* typography
* a bit more refainments
* whoops
* bringing back CTAs styling to loggedout sidebar
* fixes to left tags in left sidebar after merge
* buttons fix
* fixing border-color
* Update app/assets/stylesheets/articles.scss
Typo!
Co-Authored-By: Nick Taylor <nick@iamdeveloper.com>
* .
* css cleanup + double border on article page
* removing unnecessary comments
* get rid of loading glitch
* static vs fixed header
* Update system specs
* Update client test snapshots
* Further modify homepage specs
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
* SASS formatting in action.
* Unnested .sidebar-nav-element in SASS
* Created the <TagsFollowed /> component.
* Mini refactor.
* Left side bar uses <TagsFollowed /> component now.
* Accomodating InstantClick
* Small refactor and added some comments.
* The homepage webpacker pack only needs to be loaded once.
* Added tests for the <TagsFollowed /> component.
* Modified the receive InstantClick callback as per their docs.
* Reverted the data-no-instant on he homepage bundle. It seems to cause issues in certain scenarios.
* Just some tweaks to <TagsFollowed /> component.
* Removed CSS for general img tag in context of sidebar as it does not appear to be used.
* Fixed copy paste error from JSX to HTML.
* Fixed <img /> styles for arbitrary sponsorship widget.
* Fixed a regression that a Capybara test caught.
* Fixed user followed tags on home page tests.
* Fixed logic for loading user data on homepage.