feat(dossier): add preview flag
This commit is contained in:
parent
e152e453c3
commit
27f9a820cc
4 changed files with 27 additions and 2 deletions
|
@ -26,6 +26,7 @@
|
||||||
# last_commentaire_updated_at :datetime
|
# last_commentaire_updated_at :datetime
|
||||||
# motivation :text
|
# motivation :text
|
||||||
# private_search_terms :text
|
# private_search_terms :text
|
||||||
|
# for_procedure_preview :boolean
|
||||||
# processed_at :datetime
|
# processed_at :datetime
|
||||||
# search_terms :text
|
# search_terms :text
|
||||||
# state :string
|
# state :string
|
||||||
|
@ -205,13 +206,14 @@ class Dossier < ApplicationRecord
|
||||||
scope :not_archived, -> { where(archived: false) }
|
scope :not_archived, -> { where(archived: false) }
|
||||||
scope :hidden_by_user, -> { where.not(hidden_by_user_at: nil) }
|
scope :hidden_by_user, -> { where.not(hidden_by_user_at: nil) }
|
||||||
scope :hidden_by_administration, -> { where.not(hidden_by_administration_at: nil) }
|
scope :hidden_by_administration, -> { where.not(hidden_by_administration_at: nil) }
|
||||||
scope :visible_by_user, -> { where(hidden_by_user_at: nil) }
|
scope :visible_by_user, -> { where(for_procedure_preview: false).or(where(for_procedure_preview: nil)).where(hidden_by_user_at: nil) }
|
||||||
scope :visible_by_administration, -> {
|
scope :visible_by_administration, -> {
|
||||||
state_not_brouillon
|
state_not_brouillon
|
||||||
.where(hidden_by_administration_at: nil)
|
.where(hidden_by_administration_at: nil)
|
||||||
.merge(visible_by_user.or(state_not_en_construction))
|
.merge(visible_by_user.or(state_not_en_construction))
|
||||||
}
|
}
|
||||||
scope :visible_by_user_or_administration, -> { visible_by_user.or(visible_by_administration) }
|
scope :visible_by_user_or_administration, -> { visible_by_user.or(visible_by_administration) }
|
||||||
|
scope :for_procedure_preview, -> { where(for_procedure_preview: true) }
|
||||||
|
|
||||||
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
|
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
|
||||||
scope :order_by_created_at, -> (order = :asc) { order(depose_at: order, created_at: order, id: order) }
|
scope :order_by_created_at, -> (order = :asc) { order(depose_at: order, created_at: order, id: order) }
|
||||||
|
|
6
db/migrate/20220315124100_add_preview_to_dossiers.rb
Normal file
6
db/migrate/20220315124100_add_preview_to_dossiers.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class AddPreviewToDossiers < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :dossiers, :for_procedure_preview, :boolean
|
||||||
|
change_column_default :dossiers, :for_procedure_preview, false
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2022_04_25_140107) do
|
ActiveRecord::Schema.define(version: 2022_04_26_140107) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -314,6 +314,7 @@ ActiveRecord::Schema.define(version: 2022_04_25_140107) do
|
||||||
t.datetime "en_construction_close_to_expiration_notice_sent_at"
|
t.datetime "en_construction_close_to_expiration_notice_sent_at"
|
||||||
t.interval "en_construction_conservation_extension", default: "PT0S"
|
t.interval "en_construction_conservation_extension", default: "PT0S"
|
||||||
t.datetime "en_instruction_at"
|
t.datetime "en_instruction_at"
|
||||||
|
t.boolean "for_procedure_preview", default: false
|
||||||
t.bigint "groupe_instructeur_id"
|
t.bigint "groupe_instructeur_id"
|
||||||
t.datetime "groupe_instructeur_updated_at"
|
t.datetime "groupe_instructeur_updated_at"
|
||||||
t.datetime "hidden_at"
|
t.datetime "hidden_at"
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
namespace :after_party do
|
||||||
|
desc 'Deployment task: set_default_for_procedure_preview_on_dossiers'
|
||||||
|
task set_default_for_procedure_preview_on_dossiers: :environment do
|
||||||
|
puts "Running deploy task 'set_default_for_procedure_preview_on_dossiers'"
|
||||||
|
|
||||||
|
Dossier
|
||||||
|
.where(for_procedure_preview: nil)
|
||||||
|
.in_batches(of: 5_000)
|
||||||
|
.update_all(for_procedure_preview: false)
|
||||||
|
|
||||||
|
# Update task as completed. If you remove the line below, the task will
|
||||||
|
# run with every deploy (or every time you call after_party:run).
|
||||||
|
AfterParty::TaskRecord
|
||||||
|
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue