demarches-normaliennes/app/controllers/new_user/demarches_controller.rb
2018-10-03 12:15:48 +02:00

22 lines
587 B
Ruby

module NewUser
class DemarchesController < UserController
def index
@previous_demarches_still_active = current_user
.dossiers
.includes(:procedure)
.map(&:procedure)
.uniq
.select(&:publiee?)
@popular_demarches = Procedure
.includes(:service)
.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