-
Notifications
You must be signed in to change notification settings - Fork 191
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
Activity filters #1207
base: develop
Are you sure you want to change the base?
Activity filters #1207
Conversation
e31cbcd
to
065f478
Compare
48108ee
to
023b765
Compare
e760489
to
bfedcb5
Compare
22928f0
to
1edc807
Compare
45d57ad
to
cc678cd
Compare
@@ -1,6 +1,5 @@ | |||
[v#.#.#] ([month] [YYYY]) | |||
- [entity]: | |||
- [future tense verb] [feature] | |||
- Activity: Filter activities by user, type, and date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Activity: Filter activities by user, type, and date | |
- Activities: Filter activities by user, type, and date |
@@ -6,11 +6,11 @@ class ActivitiesController < AuthenticatedController | |||
|
|||
def index | |||
@page = params[:page].present? ? params[:page].to_i : 1 | |||
@users_for_select = current_project.activities.map(&:user).union(current_project.authors.enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to include users that have no activities?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the first part of this query we're also including users who have activities in the project even if they're no longer on the project. Do we want to include these?
end | ||
|
||
def valid_date?(date_string) | ||
Date.parse(date_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will allow dates in the future. Do we want to prevent this?
|
||
def filter_activities(activities) | ||
if params[:since].present? && valid_date?(params[:since]) | ||
activities = activities.since(DateTime.parse(params[:since]).beginning_of_day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need beginning_of_day
since DateTime.parse on a date like 2024-08-01
will return beginning of day: Thu, 01 Aug 2024 00:00:00 +0000
<%= f.select :user_id, options_from_collection_for_select(@users_for_select, :id, :name, params[:user_id]), { include_blank: 'All users' }, { class: 'form-select' } %> | ||
</div> | ||
<div class="w-100"> | ||
<%= f.label :trackable_type, class: 'form-label' %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we label this something more user-friendly?
</div> | ||
<div class="w-100"> | ||
<%= f.label :trackable_type, class: 'form-label' %> | ||
<%= f.select :trackable_type, options_from_collection_for_select(current_project.activities.pluck(:trackable_type).uniq, :to_s, :demodulize, params[:trackable_type] ), { include_blank: 'All types', selected: params[:type] }, { class: 'form-select' } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get the collection of trackable types in the controller?
</div> | ||
<div class="w-100"> | ||
<%= f.label :trackable_type, class: 'form-label' %> | ||
<%= f.select :trackable_type, options_from_collection_for_select(current_project.activities.pluck(:trackable_type).uniq, :to_s, :demodulize, params[:trackable_type] ), { include_blank: 'All types', selected: params[:type] }, { class: 'form-select' } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<%= f.select :trackable_type, options_from_collection_for_select(current_project.activities.pluck(:trackable_type).uniq, :to_s, :demodulize, params[:trackable_type] ), { include_blank: 'All types', selected: params[:type] }, { class: 'form-select' } %> | |
<%= f.select :trackable_type, options_from_collection_for_select(current_project.activities.pluck(:trackable_type).uniq, :to_s, :demodulize, params[:trackable_type] ), { include_blank: 'All types' }, { class: 'form-select' } %> |
<span class="form-label mb-2 d-block">Date range</span> | ||
<div class="d-flex flex-column flex-sm-row gap-3 w-100"> | ||
<div class="input-group"> | ||
<%= f.date_field :since, max: params[:before] || Date.today, min: "01-01-2016", placeholder: 'From date', value: params[:since], class: 'form-control', data: { behavior: 'since' } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for the min date choice?
<%= f.date_field :before, max: Date.today, min: params[:since], placeholder: 'To date', value: params[:before] || Date.today, class: 'form-control' %> | ||
</div> | ||
|
||
<%= link_to project_activities_path(current_project.id), class: 'text-error-hover text-nowrap d-flex align-items-center' do %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<%= link_to project_activities_path(current_project.id), class: 'text-error-hover text-nowrap d-flex align-items-center' do %> | |
<%= link_to project_activities_path(current_project), class: 'text-error-hover text-nowrap d-flex align-items-center' do %> |
|
||
private | ||
|
||
def filtering_params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're not using this anywhere but probably a good idea
</div> | ||
<div class="w-100"> | ||
<%= f.label :trackable_type, class: 'form-label' %> | ||
<%= f.select :trackable_type, options_from_collection_for_select(current_project.activities.pluck(:trackable_type).uniq, :to_s, :demodulize, params[:trackable_type] ), { include_blank: 'All types', selected: params[:type] }, { class: 'form-select' } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split this across multiple lines? ditto for the other fields
Spec
Problem
Dradis has an activity feed on the Dashboard, with a link to view all activities in the project. With the current implementation, users don’t have a way to narrow down the activities that are listed in the all activities view.
Solution
We can implement a set of filters that will allow users to narrow down the activities by date range, type (Issue, Evidence, etc), and user.
The result should allow users to easily determine which activities:
were performed by a specific user
were performed during a certain date range
were performed on a certain date
are related to Issues, Evidence, Notes, Nodes, etc
Check List