publish only some opendata procedures for datagouv

- only published or closed procedures
- only procedures with flag opendata
- only procedures with 4 or more dossiers
- only procedures without word "mail" in lien_site_web
- only procedures without word "intra" in lien_site_web
This commit is contained in:
Christophe Robillard 2023-02-28 16:25:53 +01:00
parent 7e13d58db2
commit 9ff88db48c
5 changed files with 45 additions and 3 deletions

View file

@ -19,7 +19,7 @@ module Types
field :demarches_publiques, DemarcheDescriptorType.connection_type, null: false, internal: true
def demarches_publiques
Procedure.publiees_ou_closes.opendata.includes(draft_revision: :procedure, published_revision: :procedure)
Procedure.publiques.includes(draft_revision: :procedure, published_revision: :procedure)
end
def demarche_descriptor(demarche:)

View file

@ -219,6 +219,15 @@ class Procedure < ApplicationRecord
scope :closes, -> { where(aasm_state: [:close, :depubliee]) }
scope :opendata, -> { where(opendata: true) }
scope :publiees_ou_closes, -> { where(aasm_state: [:publiee, :close, :depubliee]) }
scope :publiques, -> do
publiees_ou_closes
.opendata
.where('estimated_dossiers_count >= ?', 4)
.where.not('lien_site_web LIKE ?', '%mail%')
.where.not('lien_site_web LIKE ?', '%intra%')
end
scope :by_libelle, -> { order(libelle: :asc) }
scope :created_during, -> (range) { where(created_at: range) }
scope :cloned_from_library, -> { where(cloned_from_library: true) }