2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-25 10:53:45 +01:00
|
|
|
module Users
|
2018-09-13 16:13:54 +02:00
|
|
|
class DemarchesController < UserController
|
|
|
|
def index
|
|
|
|
@previous_demarches_still_active = current_user
|
|
|
|
.dossiers
|
|
|
|
.includes(:procedure)
|
|
|
|
.map(&:procedure)
|
|
|
|
.uniq
|
2019-09-12 11:26:22 +02:00
|
|
|
.filter(&:publiee?)
|
2018-09-11 00:16:30 +02:00
|
|
|
|
|
|
|
@popular_demarches = Procedure
|
2018-09-18 10:39:47 +02:00
|
|
|
.includes(:service)
|
2018-09-11 00:16:30 +02:00
|
|
|
.select("procedures.*, COUNT(*) AS procedures_count")
|
|
|
|
.joins(:dossiers)
|
|
|
|
.publiees
|
2018-10-25 15:11:12 +02:00
|
|
|
.where(dossiers: { created_at: 7.days.ago..Time.zone.now })
|
2018-09-11 00:16:30 +02:00
|
|
|
.group("procedures.id")
|
|
|
|
.order("procedures_count DESC")
|
|
|
|
.limit(5)
|
2018-09-13 16:13:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|