Skip to content

Remove duplicate db query in dashboard snippets

Qingyu Zhao requested to merge remove-duplicate-db-query-dashboard-snippets into master

What does this MR do?

While looking at the issue #211780 (closed), I happen to see there is duplicate condition check if current_user.snippets.exists? in file app/views/dashboard/snippets/index.html.haml. This will also lead to an extra DB query:

[237] pry(main)> current_user.snippets.exists?
  Snippet Exists? (0.4ms)  SELECT 1 AS one FROM "snippets" WHERE "snippets"."author_id" = $1 LIMIT $2  [["author_id", 1], ["LIMIT", 1]]
=> true

Conformity

Edited by Qingyu Zhao

Merge request reports