-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Extract AccountFollowable
concern for Account.followable_by
scope
#26179
Extract AccountFollowable
concern for Account.followable_by
scope
#26179
Conversation
This pull request has merge conflicts that must be resolved before it can be merged. |
a72fc5f
to
ab33311
Compare
This pull request has resolved merge conflicts and is ready for review. |
This pull request has merge conflicts that must be resolved before it can be merged. |
ab33311
to
bb9fc35
Compare
This pull request has resolved merge conflicts and is ready for review. |
This pull request has merge conflicts that must be resolved before it can be merged. |
bb9fc35
to
c84e615
Compare
This pull request has resolved merge conflicts and is ready for review. |
c84e615
to
875a8cd
Compare
Updated this to move the whole query generation to a new class, and remove the scope from The suggestions classes, and maybe the new query class could probably be further simplified. I suspect that at least part of the query generation does not need the full low level arel treatment it's currently using, but haven't verified in detail. |
92ec066
to
b938826
Compare
b938826
to
286b679
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #26179 +/- ##
==========================================
+ Coverage 84.83% 84.84% +0.01%
==========================================
Files 1038 1039 +1
Lines 28142 28161 +19
Branches 4536 4536
==========================================
+ Hits 23874 23893 +19
Misses 3103 3103
Partials 1165 1165 ☔ View full report in Codecov by Sentry. |
286b679
to
bd2b858
Compare
Rebased and moved to |
bd2b858
to
6c54c9e
Compare
6c54c9e
to
6e85032
Compare
6e85032
to
82fd844
Compare
Rebased this again after the introduction of spec coverage in #28689 Current version of this is pull out the scope creation to a concern module, building two smaller scopes with the conditions, and then combining them. I think this is a net-improvement as-is, but would like feedback. If this is not good to go, the other idea I have is to move (and expand) the coverage to be directly on |
Taking a step back from this query, it heavily uses Given that this query is only ever used in Something like: def followable_by(account)
Account.where.not('EXISTS (SELECT 1 FROM follows f WHERE f.target_account_id = accounts.id AND f.account_id = :id)', id: account.id)
.where.not('EXISTS (SELECT 1 FROM follow_requests f WHERE f.target_account_id = accounts.id AND f.account_id = :id)', id: account.id)
end |
Great. I'll move the coversage over to account suggesstion spec, expand it a bit, and then explore something along those lines. |
Closing this, goal accomplished by linked PR. |
Pulled out from #26093
This scope was sort of complicated and hard to follow and parse visually.
This change pulls the whole thing out into a concern which does nothing but build the scope back up from better-named private methods. From my local testing, a) the generated sql hasn't changed, b) the specs which exercise this method seem fine with the change.