# Rails 5 helpers to fetch tasks with different filters

I moved a lot of the loading/logic from my view to my controller, and it's working great but after I did this I now have several very similar helper methods in my controller.

What is a more efficient way of doing this? Is there? I assume get_last_task_owed and get_first_task_owed I would be able to do in the view by finding the .first and .last of the record respectively.

  def get_projects_owed
current_user.projects.where('end_date > ?', Date.today).order(:start_date).pluck(:name, :start_date, :end_date)

end

def get_all_projects
current_user.projects.order(:start_date).pluck(:name, :start_date, :end_date)
end

end

end

end

helper_method :get_projects_owed
helper_method :get_all_projects
helper_method :get_clients_with_projects


One possible improvement is using scopes:

def get_projects_owed
current_user.projects.owed.recent_first.pluck(:name, :start_date, :end_date)
end

def get_all_projects
current_user.projects.recent_first.pluck(:name, :start_date, :end_date)
end

end

end

end