-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2671 from betagouv/dev
MEP 2018-09-24-03
- Loading branch information
Showing
8 changed files
with
36 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
class ProcedurePresentation < ApplicationRecord | ||
belongs_to :assign_to | ||
|
||
def displayed_fields | ||
read_attribute(:displayed_fields).map do |field| | ||
field = JSON.parse(field) | ||
end | ||
end | ||
|
||
def sort | ||
JSON.parse(read_attribute(:sort)) | ||
end | ||
|
||
def filters | ||
JSON.parse(read_attribute(:filters)) | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20180919084403_change_procedure_presentation_fields_to_jsonb.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class ChangeProcedurePresentationFieldsToJsonb < ActiveRecord::Migration[5.2] | ||
def change | ||
change_table(:procedure_presentations) do |t| | ||
t.rename :displayed_fields, :old_displayed_fields | ||
t.column :displayed_fields, :jsonb, null: false, default: [{ label: "Demandeur", table: "user", column: "email" }] | ||
t.change :sort, :jsonb, default: { table: "notifications", column: "notifications", order: "desc" } | ||
t.change :filters, :jsonb, default: { "a-suivre": [], suivis: [], traites: [], tous: [], archives: [] } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace :'2018_09_20_procedure_presentation_jsonb' do | ||
task run: :environment do | ||
ProcedurePresentation.update_all( | ||
<<~SQL | ||
displayed_fields = ('[' || ARRAY_TO_STRING(old_displayed_fields, ',') || ']')::JSONB, | ||
sort = (sort #>> '{}')::jsonb, | ||
filters = (filters #>> '{}')::jsonb | ||
SQL | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters