Skip to content

Commit

Permalink
add start date and end date to projects filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Feb 21, 2024
1 parent 0279754 commit 815042d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class ProjectsController < ApplicationController
before_action :set_project, only: %i[show update destroy]

def index
active_only = filters_params[:active_only] == 'true'
@projects = Project.all.order(:name)
@projects = @projects.active_in_period(Time.zone.today, Time.zone.today) if active_only
start_date = filters_params[:start_date] || Time.zone.today
end_date = filters_params[:end_date] || Time.zone.today
@projects = Project.active_in_period(start_date, end_date).order(:name)
end

def show; end
Expand Down Expand Up @@ -45,6 +45,6 @@ def project_params
end

def filters_params
params.fetch(:filters, {}).permit(:active_only)
params.fetch(:filters, {}).permit(:start_date, :end_date)
end
end

0 comments on commit 815042d

Please sign in to comment.