Skip to content

Remove unnecessary query from labels dropdown

Felipe Artur requested to merge issue_37143_2 into master

closes #37143 (closed)

  finder.labels.select(:title).uniq

Looks like we can remove that statement from labels dropdown, since we don't rely on label ids to check if they exists(also i only see that being called from dashboard filter).

After testing on staging i realized that the timeout was happening because we try to check if label exist for all visible projects to the user when filtering by label on dashboard:

irb(main):001:0> finder = IssuesFinder.new(User.find(426128), { sort: "created_date", state: "opened", label_name: ["SP1"], non_archived: true})
=> #<IssuesFinder:0x00007fc09c616fe8 @current_user=#<User id:426128 @felipe_artur>, @params={:sort=>"created_date", :state=>"opened", :label_name=>["SP1"], :non_archived=>true}>
irb(main):002:0> finder.projects.count
=> 328035

This also was not necessary because we only show labels that belongs to projects/groups that user has authorization in the dropdown.

It seems that the only downside of this is if user passes a label name that does not exists as a parameter it will still be show in the dropdown after the filtering. But anyway i think this is a fair trade.

I did not provide any Sherlock data because it is not relevant on my localhost since i don't have 328035 projects.

Edited by Felipe Artur

Merge request reports