demarches-normaliennes/app/controllers/new_user/demarches_controller.rb
2018-09-13 16:27:46 +02:00

21 lines
566 B
Ruby

module NewUser
class DemarchesController < UserController
def index
@previous_demarches_still_active = current_user
.dossiers
.includes(:procedure)
.map(&:procedure)
.uniq
.select { |p| p.publiee? }
@popular_demarches = Procedure
.select("procedures.*, COUNT(*) AS procedures_count")
.joins(:dossiers)
.publiees
.where(dossiers: { created_at: 7.days.ago..Time.now })
.group("procedures.id")
.order("procedures_count DESC")
.limit(5)
end
end
end