Add links to the most popular demarches

This commit is contained in:
gregoirenovel 2018-09-11 00:16:30 +02:00
parent 523fdb5d45
commit aba0c1dcd6
2 changed files with 16 additions and 0 deletions

View file

@ -7,6 +7,15 @@ module NewUser
.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

View file

@ -10,5 +10,12 @@
%li
= link_to(demarche.libelle, commencer_url(procedure_path: demarche.path), class: "demarche-link")
- if @popular_demarches.present?
%h2.list-header LES PLUS POPULAIRES
%ul.demarche-links
- @popular_demarches.each do |demarche|
%li
= link_to(demarche.libelle, commencer_url(procedure_path: demarche.path), class: "demarche-link")
%h2.list-header TOUTES LES DÉMARCHES
= link_to("Voir l'intégralité des démarches disponibles", LISTE_DES_DEMARCHES_URL, class: "button")