Skip to content
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 not_featured_by scope to Tag #28815

Merged
merged 2 commits into from Apr 17, 2024

Conversation

mjankowski
Copy link
Contributor

A few changes here:

  • Because of how FeaturedTag model sets the tag value (doing a lookup on name in a callback), setting the tag at all in the fabricator was making it hard to work with the fabricators. Setting this to nil and passing in a name works better.
  • There are two controller locations which are doing the same logic of "get tags which were used recently by this account and are not in their featured tags". They already had a scope for the first part, this adds a scope for the second part.
  • I think there's a bug fix in here as well -- the previous queries were doing something like "where tags.id not IN ?", but the source of that ? was coming from the id of a FeaturedTag association. I believe it should be coming from the tag_id of the featured tag association? The new scope does this. If this is not correct I may be misunderstanding how this works.

Possible future refactor here: I believe these two uses are the only uses of these two scopes. Usage could be shortened to like Tag.suggestions_for(account) or something, which would then call these two scopes internally.

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.07%. Comparing base (86500e3) to head (4e55a8a).
Report is 379 commits behind head on main.

❗ Current head 4e55a8a differs from pull request most recent head d38c5f5. Consider uploading reports for the commit d38c5f5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28815      +/-   ##
==========================================
+ Coverage   85.01%   85.07%   +0.05%     
==========================================
  Files        1059     1038      -21     
  Lines       28277    28128     -149     
  Branches     4538     4531       -7     
==========================================
- Hits        24040    23929     -111     
+ Misses       3074     3039      -35     
+ Partials     1163     1160       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@renchap renchap added refactoring Improving code quality ruby Pull requests that update Ruby code labels Feb 16, 2024
@mjankowski mjankowski force-pushed the tag-scope-not-featured branch 2 times, most recently from 174d8c7 to d38c5f5 Compare March 22, 2024 15:32
@mjankowski
Copy link
Contributor Author

Rebased this after #29597 (bug fix) merged. This PR is now just scope introduction to consolidate the previous logic into Tag class.

@mjankowski mjankowski requested a review from a team March 27, 2024 18:28
@ClearlyClaire ClearlyClaire added this pull request to the merge queue Apr 17, 2024
Merged via the queue into mastodon:main with commit 650c548 Apr 17, 2024
32 checks passed
@mjankowski mjankowski deleted the tag-scope-not-featured branch April 17, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improving code quality ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants