Skip to content
Snippets Groups Projects
Unverified Commit 3e137d0b authored by Magdalena Frankiewicz's avatar Magdalena Frankiewicz
Browse files

Add filters by milestone, author, and assignee to task by type

The task by type internal API endpoints, used to produce the "Type of
work" chart, can now filter by author, by assignees, and by milestone.
This makes it consistent with the other charts on the same page.

Using the same convention as the other charts, the filters are specified
with the following URL parameters:

  - `milestone_title` - a string with the milestone title to filter for
  - `author_username` - the username of the author to filter for
  - `assignee_username` - it accepts a single username or multiple
    usernames (like
`assignee_username[]=username1&assignee_username[]=username2`) of
assignees to filter for.

Changelog: changed
EE: true
parent 24761832
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -27,7 +27,10 @@ def tasks_by_type
label_ids: Array(params[:label_ids]),
project_ids: Array(params[:project_ids]),
created_after: @created_after.to_time.utc.beginning_of_day,
created_before: @created_before.to_time.utc.end_of_day
created_before: @created_before.to_time.utc.end_of_day,
author_username: params[:author_username],
assignee_username: params[:assignee_username],
milestone_id: params[:milestone_id]
})
end
 
Loading
Loading
Loading
Loading
@@ -55,7 +55,10 @@ def format_result(result)
end
 
def finder_params
{ include_subgroups: true, group_id: group.id }.merge(params.slice(:created_after, :created_before))
{
include_subgroups: true,
group_id: group.id
}.merge(params.slice(:created_after, :created_before, :author_username, :milestone_title, :assignee_username))
end
 
# rubocop: disable CodeReuse/ActiveRecord
Loading
Loading
Loading
Loading
@@ -13,6 +13,8 @@
let_it_be(:label_for_subgroup) { create(:group_label, group: group) }
let_it_be(:other_label) { create(:group_label, group: other_group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:assignee) { create(:user) }
let_it_be(:milestone) { create(:milestone, group: group) }
 
let(:params) do
{
Loading
Loading
@@ -32,6 +34,7 @@
 
before do
group.add_reporter(user)
group.add_developer(assignee)
end
 
shared_examples '#counts_by_labels' do
Loading
Loading
@@ -39,6 +42,8 @@
create(factory_name, {
:created_at => 3.days.ago,
:labels => [label],
:assignees => [assignee],
:milestone => milestone,
project_attribute_name => project
})
end
Loading
Loading
@@ -118,6 +123,30 @@ def label_count_for(label, result)
 
it { expect(label_count_for(label, subject)).to eq(1) }
end
context 'when filtering by `author_username`' do
before do
params[:params][:author_username] = with_label.author.username
end
it { expect(label_count_for(label, subject)).to eq(1) }
end
context 'when filtering by `assignee_username`' do
before do
params[:params][:assignee_username] = [assignee.username]
end
it { expect(label_count_for(label, subject)).to eq(1) }
end
context 'when filtering by `milestone_title`' do
before do
params[:params][:milestone_title] = milestone.title
end
it { expect(label_count_for(label, subject)).to eq(1) }
end
end
 
shared_examples '#top_labels' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment