Commit 1a2e11c891ef4a2a87b84f2b0b36316bb809ff14
1 parent
f6a4e563
Exists in
spb-stable
and in
3 other branches
Fix per-project counters for Dashboard filters
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
4 changed files
with
9 additions
and
15 deletions
Show diff stats
app/helpers/dashboard_helper.rb
@@ -14,17 +14,11 @@ module DashboardHelper | @@ -14,17 +14,11 @@ module DashboardHelper | ||
14 | end | 14 | end |
15 | 15 | ||
16 | def entities_per_project(project, entity) | 16 | def entities_per_project(project, entity) |
17 | - items = project.items_for(entity) | ||
18 | - | ||
19 | - items = case params[:status] | ||
20 | - when 'closed' | ||
21 | - items.closed | ||
22 | - when 'all' | ||
23 | - items | ||
24 | - else | ||
25 | - items.opened | ||
26 | - end | ||
27 | - | ||
28 | - items.cared(current_user).count | 17 | + case entity.to_sym |
18 | + when :issue then @issues.where(project_id: project.id) | ||
19 | + when :merge_request then @merge_requests.where(target_project_id: project.id) | ||
20 | + else | ||
21 | + [] | ||
22 | + end.count | ||
29 | end | 23 | end |
30 | end | 24 | end |
app/views/shared/_filter.html.haml
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | Assigned to me | 6 | Assigned to me |
7 | %li{class: ("active" if params[:scope] == 'authored')} | 7 | %li{class: ("active" if params[:scope] == 'authored')} |
8 | = link_to filter_path(entity, scope: 'authored') do | 8 | = link_to filter_path(entity, scope: 'authored') do |
9 | - Authored by me | 9 | + Created by me |
10 | %li{class: ("active" if params[:scope] == 'all')} | 10 | %li{class: ("active" if params[:scope] == 'all')} |
11 | = link_to filter_path(entity, scope: 'all') do | 11 | = link_to filter_path(entity, scope: 'all') do |
12 | All | 12 | All |
features/steps/dashboard/dashboard_issues.rb
@@ -34,7 +34,7 @@ class DashboardIssues < Spinach::FeatureSteps | @@ -34,7 +34,7 @@ class DashboardIssues < Spinach::FeatureSteps | ||
34 | 34 | ||
35 | step 'I click "Authored by me" link' do | 35 | step 'I click "Authored by me" link' do |
36 | within ".scope-filter" do | 36 | within ".scope-filter" do |
37 | - click_link 'Authored by me' | 37 | + click_link 'Created by me' |
38 | end | 38 | end |
39 | end | 39 | end |
40 | 40 |
features/steps/dashboard/dashboard_merge_requests.rb
@@ -34,7 +34,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps | @@ -34,7 +34,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps | ||
34 | 34 | ||
35 | step 'I click "Authored by me" link' do | 35 | step 'I click "Authored by me" link' do |
36 | within ".scope-filter" do | 36 | within ".scope-filter" do |
37 | - click_link 'Authored by me' | 37 | + click_link 'Created by me' |
38 | end | 38 | end |
39 | end | 39 | end |
40 | 40 |