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

Fix duplicate offense messages in RuboCop::Cop::Isucon::Mysql2::ManyJoinTable #189

Open
sue445 opened this issue Jul 6, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@sue445
Copy link
Owner

sue445 commented Jul 6, 2022

expect_offense(<<~RUBY)
totals = db.xquery(
^^^^^^^^^^ Avoid SQL with lots of JOINs
^^^^^^^^^^ Avoid SQL with lots of JOINs
"SELECT IFNULL(SUM(`submissions`.`score`), 0) AS `total_score`" \\
" FROM `users`" \\
" JOIN `registrations` ON `users`.`id` = `registrations`.`user_id`" \\
" JOIN `courses` ON `registrations`.`course_id` = `courses`.`id`" \\
" LEFT JOIN `classes` ON `courses`.`id` = `classes`.`course_id`" \\
" LEFT JOIN `submissions` ON `users`.`id` = `submissions`.`user_id` AND `submissions`.`class_id` = `classes`.`id`" \\
" WHERE `courses`.`id` = ?" \\
" GROUP BY `users`.`id`",
course[:id]
).map { |_| _[:total_score] }
RUBY

@sue445 sue445 added the bug Something isn't working label Jul 6, 2022
@sue445 sue445 self-assigned this Jul 6, 2022
@sue445 sue445 changed the title Fix duplicate offense messages in RuboCop::Cop::Isucon::Mysql2:: ManyJoinTable Fix duplicate offense messages in RuboCop::Cop::Isucon::Mysql2::ManyJoinTable Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant