Skip to content
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

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

Activity filters #1207

wants to merge 18 commits into from

Conversation

skliask
Copy link
Contributor

@skliask skliask commented Nov 29, 2023

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

  • Added a CHANGELOG entry

CHANGELOG Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
app/views/activities/_filters.html.erb Outdated Show resolved Hide resolved
@skliask skliask force-pushed the activity_filters branch 5 times, most recently from e31cbcd to 065f478 Compare December 6, 2023 16:57
app/models/activity.rb Outdated Show resolved Hide resolved
app/models/activity.rb Outdated Show resolved Hide resolved
@skliask skliask force-pushed the activity_filters branch 5 times, most recently from 48108ee to 023b765 Compare December 12, 2023 16:00
@skliask skliask force-pushed the activity_filters branch 2 times, most recently from e760489 to bfedcb5 Compare December 14, 2023 12:48
CHANGELOG Outdated Show resolved Hide resolved
@skliask skliask force-pushed the activity_filters branch 3 times, most recently from 22928f0 to 1edc807 Compare December 14, 2023 15:03
@@ -1,6 +1,5 @@
[v#.#.#] ([month] [YYYY])
- [entity]:
- [future tense verb] [feature]
- Activity: Filter activities by user, type, and date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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)
Copy link
Contributor

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?

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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' %>
Copy link
Contributor

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' } %>
Copy link
Contributor

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' } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<%= 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' } %>
Copy link
Contributor

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 %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<%= 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
Copy link
Contributor

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' } %>
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants