-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
332 additions
and
181 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
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,2 +1,2 @@ | ||
class TypesDeChamp::CheckboxTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::CheckboxTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::CiviliteTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::CiviliteTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::DateTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::DateTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::DatetimeTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::DatetimeTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::DossierLinkTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::DossierLinkTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::DropDownListTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::DropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::HeaderSectionTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::HeaderSectionTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
end |
4 changes: 3 additions & 1 deletion
4
app/models/types_de_champ/linked_drop_down_list_type_de_champ.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
2 changes: 1 addition & 1 deletion
2
app/models/types_de_champ/multiple_drop_down_list_type_de_champ.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::MultipleDropDownListTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::MultipleDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::NumberTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::NumberTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::PieceJustificativeTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::PieceJustificativeTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::SiretTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::SiretTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
class TypesDeChamp::TextTypeDeChamp < TypeDeChamp | ||
class TypesDeChamp::TextTypeDeChamp < TypesDeChamp::TypeDeChampBase | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class TypesDeChamp::TypeDeChampBase | ||
def initialize(type_de_champ) | ||
@type_de_champ = type_de_champ | ||
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class DropEntreprises < ActiveRecord::Migration[5.2] | ||
def change | ||
drop_table :entreprises | ||
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
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
51 changes: 51 additions & 0 deletions
51
lib/tasks/2018_09_20_procedure_presentation_entreprise.rake
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,51 @@ | ||
namespace :'2018_09_20_procedure_presentation_entreprise' do | ||
task run: :environment do | ||
Class.new do | ||
def run | ||
fix_displayed_fields | ||
fix_sort | ||
fix_filters | ||
end | ||
|
||
def fix_displayed_fields | ||
ProcedurePresentation.where(%q`displayed_fields @> '[{"table": "entreprise"}]'`).each do |procedure_presentation| | ||
procedure_presentation.displayed_fields.each { |field| entreprise_to_etablissement(field) } | ||
|
||
procedure_presentation.save | ||
end | ||
end | ||
|
||
def fix_sort | ||
ProcedurePresentation.where(%q`sort @> '{"table": "entreprise"}'`).each do |procedure_presentation| | ||
entreprise_to_etablissement(procedure_presentation['sort']) | ||
|
||
procedure_presentation.save | ||
end | ||
end | ||
|
||
def fix_filters | ||
ProcedurePresentation.find_by_sql( | ||
<<~SQL | ||
SELECT procedure_presentations.*, array_agg(key) as keys | ||
FROM procedure_presentations, LATERAL jsonb_each(filters) | ||
WHERE value @> '[{"table": "entreprise"}]' | ||
GROUP BY id; | ||
SQL | ||
).each do |procedure_presentation| | ||
procedure_presentation.keys.each do |key| | ||
procedure_presentation.filters[key].each { |filter| entreprise_to_etablissement(filter) } | ||
end | ||
|
||
procedure_presentation.save | ||
end | ||
end | ||
|
||
def entreprise_to_etablissement(field) | ||
if field['table'] == 'entreprise' | ||
field['table'] = 'etablissement' | ||
field['column'] = "entreprise_#{field['column']}" | ||
end | ||
end | ||
end.new.run | ||
end | ||
end |
Oops, something went wrong.