28e6af88aa
If we don't call #to_a, we're relying on the members already being loaded from elsewhere. Otherwise we'll do a separate query for each user: [1] pry(main)> Project.first.team.members.include?(User.first) Project Load (0.7ms) SELECT "projects".* FROM "projects" ORDER BY "projects"."id" ASC LIMIT 1 ↳ (pry):3 User Load (1.8ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 ↳ (pry):3 User Exists (0.6ms) SELECT 1 AS one FROM "users" INNER JOIN "project_authorizations" ON "users"."id" = "project_authorizations"."user_id" WHERE "project_authorizations"."project_id" = $1 AND "users"."id" = $2 LIMIT 1 [["project_id", 1], ["id", 1]] ↳ (pry):3 => true [2] pry(main)> Project.first.team.members.to_a.include?(User.first) Project Load (12.8ms) SELECT "projects".* FROM "projects" ORDER BY "projects"."id" ASC LIMIT 1 ↳ (pry):1 User Load (9.6ms) SELECT "users".* FROM "users" INNER JOIN "project_authorizations" ON "users"."id" = "project_authorizations"."user_id" WHERE "project_authorizations"."project_id" = $1 [["project_id", 1]] ↳ (pry):1 User Load (0.6ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 ↳ (pry):1 => true |
||
---|---|---|
.. | ||
application_settings | ||
applications | ||
auth | ||
boards | ||
chat_names | ||
ci | ||
clusters | ||
commits | ||
deploy_keys | ||
deploy_tokens | ||
discussions | ||
emails | ||
events | ||
files | ||
gpg_keys | ||
groups | ||
issuable | ||
issues | ||
keys | ||
labels | ||
lfs | ||
members | ||
merge_requests | ||
milestones | ||
notes | ||
projects | ||
prometheus | ||
protected_branches | ||
protected_tags | ||
quick_actions | ||
resource_events | ||
search | ||
tags | ||
test_hooks | ||
todos/destroy | ||
users | ||
wiki_pages | ||
wikis | ||
access_token_validation_service_spec.rb | ||
after_branch_delete_service_spec.rb | ||
base_count_service_spec.rb | ||
cohorts_service_spec.rb | ||
compare_service_spec.rb | ||
create_branch_service_spec.rb | ||
create_deployment_service_spec.rb | ||
create_release_service_spec.rb | ||
create_snippet_service_spec.rb | ||
delete_branch_service_spec.rb | ||
delete_merged_branches_service_spec.rb | ||
event_create_service_spec.rb | ||
git_push_service_spec.rb | ||
git_tag_push_service_spec.rb | ||
gravatar_service_spec.rb | ||
import_export_clean_up_service_spec.rb | ||
note_summary_spec.rb | ||
notification_recipient_service_spec.rb | ||
notification_service_spec.rb | ||
preview_markdown_service_spec.rb | ||
push_event_payload_service_spec.rb | ||
repair_ldap_blocked_user_service_spec.rb | ||
repository_archive_clean_up_service_spec.rb | ||
reset_project_cache_service_spec.rb | ||
search_service_spec.rb | ||
spam_service_spec.rb | ||
submit_usage_ping_service_spec.rb | ||
system_hooks_service_spec.rb | ||
system_note_service_spec.rb | ||
todo_service_spec.rb | ||
update_merge_request_metrics_service_spec.rb | ||
update_release_service_spec.rb | ||
update_snippet_service_spec.rb | ||
upload_service_spec.rb | ||
user_project_access_changed_service_spec.rb | ||
verify_pages_domain_service_spec.rb | ||
web_hook_service_spec.rb |