diff --git a/app/models/animal.rb b/app/models/animal.rb index 703bff1ccc..adb9ccdbd5 100644 --- a/app/models/animal.rb +++ b/app/models/animal.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/animal_group.rb b/app/models/animal_group.rb index 8f0c0ec99e..ad82d7848e 100644 --- a/app/models/animal_group.rb +++ b/app/models/animal_group.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/bioproduct.rb b/app/models/bioproduct.rb index 721939edd0..503b33df1f 100644 --- a/app/models/bioproduct.rb +++ b/app/models/bioproduct.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/building.rb b/app/models/building.rb index 3bf19aefae..2cf3b7925d 100644 --- a/app/models/building.rb +++ b/app/models/building.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/building_division.rb b/app/models/building_division.rb index 85cafa1174..2dd80a3d90 100644 --- a/app/models/building_division.rb +++ b/app/models/building_division.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/easement.rb b/app/models/easement.rb index 4a560cfa38..9d461b92d8 100644 --- a/app/models/easement.rb +++ b/app/models/easement.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/equipment.rb b/app/models/equipment.rb index ba45bab057..41e99bfdce 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/equipment_fleet.rb b/app/models/equipment_fleet.rb index 5e608907db..4947511cd5 100644 --- a/app/models/equipment_fleet.rb +++ b/app/models/equipment_fleet.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/fungus.rb b/app/models/fungus.rb index 4f6f07f536..2d0a85d2e8 100644 --- a/app/models/fungus.rb +++ b/app/models/fungus.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/intervention.rb b/app/models/intervention.rb index 154b9e69ba..23315c142f 100644 --- a/app/models/intervention.rb +++ b/app/models/intervention.rb @@ -22,33 +22,34 @@ # # == Table: interventions # -# accounted_at :datetime -# actions :string -# created_at :datetime not null -# creator_id :integer -# currency :string -# custom_fields :jsonb -# description :text -# event_id :integer -# id :integer not null, primary key -# issue_id :integer -# journal_entry_id :integer -# lock_version :integer default(0), not null -# nature :string not null -# number :string -# prescription_id :integer -# procedure_name :string not null -# request_compliant :boolean -# request_intervention_id :integer -# started_at :datetime not null -# state :string not null -# stopped_at :datetime not null -# trouble_description :text -# trouble_encountered :boolean default(FALSE), not null -# updated_at :datetime not null -# updater_id :integer -# whole_duration :integer not null -# working_duration :integer not null +# accounted_at :datetime +# actions :string +# auto_calculate_working_periods :boolean default(FALSE) +# created_at :datetime not null +# creator_id :integer +# currency :string +# custom_fields :jsonb +# description :text +# event_id :integer +# id :integer not null, primary key +# issue_id :integer +# journal_entry_id :integer +# lock_version :integer default(0), not null +# nature :string not null +# number :string +# prescription_id :integer +# procedure_name :string not null +# request_compliant :boolean +# request_intervention_id :integer +# started_at :datetime not null +# state :string not null +# stopped_at :datetime not null +# trouble_description :text +# trouble_encountered :boolean default(FALSE), not null +# updated_at :datetime not null +# updater_id :integer +# whole_duration :integer not null +# working_duration :integer not null # class Intervention < Ekylibre::Record::Base @@ -90,9 +91,9 @@ class Intervention < Ekylibre::Record::Base # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`. validates :accounted_at, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } }, allow_blank: true validates :actions, :number, length: { maximum: 500 }, allow_blank: true + validates :auto_calculate_working_periods, :request_compliant, inclusion: { in: [true, false] }, allow_blank: true validates :description, :trouble_description, length: { maximum: 500_000 }, allow_blank: true validates :nature, :procedure_name, :state, presence: true - validates :request_compliant, inclusion: { in: [true, false] }, allow_blank: true validates :started_at, presence: true, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } } validates :stopped_at, presence: true, timeliness: { on_or_after: ->(intervention) { intervention.started_at || Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } } validates :trouble_encountered, inclusion: { in: [true, false] } diff --git a/app/models/land_parcel.rb b/app/models/land_parcel.rb index df0fbbd58f..068abfb92c 100644 --- a/app/models/land_parcel.rb +++ b/app/models/land_parcel.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/matter.rb b/app/models/matter.rb index 9bbc558a2e..7fe14c2f12 100644 --- a/app/models/matter.rb +++ b/app/models/matter.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/plant.rb b/app/models/plant.rb index 199e5a43f8..b808a12367 100644 --- a/app/models/plant.rb +++ b/app/models/plant.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/product.rb b/app/models/product.rb index 3008a32e7a..8c2116ea84 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/product_group.rb b/app/models/product_group.rb index 6c8ab58e47..db7c84ec94 100644 --- a/app/models/product_group.rb +++ b/app/models/product_group.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/settlement.rb b/app/models/settlement.rb index dae3ef037e..ae87dd7fcc 100644 --- a/app/models/settlement.rb +++ b/app/models/settlement.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/sub_zone.rb b/app/models/sub_zone.rb index 20124f04ab..fc415d0782 100644 --- a/app/models/sub_zone.rb +++ b/app/models/sub_zone.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/worker.rb b/app/models/worker.rb index f7ef17599d..9b89c194ed 100644 --- a/app/models/worker.rb +++ b/app/models/worker.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/app/models/zone.rb b/app/models/zone.rb index 0d2f35c0d7..d465a93154 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/config/locales/eng/models.yml b/config/locales/eng/models.yml index 211cf5d2ad..42295c83c4 100644 --- a/config/locales/eng/models.yml +++ b/config/locales/eng/models.yml @@ -472,6 +472,7 @@ eng: authentication_token: "Authentication token" author: "Author" authorized_payments_count: "Authorized payments count" + # auto_calculate_working_periods: "Auto calculate working periods" auto_updateable_addresses: "Auto updateable addresses" average_value: "Average value" balance: "Balance" @@ -1288,7 +1289,7 @@ eng: query: "Query" rank_number: "Rank number" read_at: "Read at" - reading_cache: "Reading cache" + reading_cache: "Reading cache" #? reading_tasks: "Reading tasks" #? readings: "Readings" real_balance: "Real balance" diff --git a/db/structure.sql b/db/structure.sql index eaf11b8285..1e127eeb18 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.3 --- Dumped by pg_dump version 9.6.3 +-- Dumped from database version 9.6.4 +-- Dumped by pg_dump version 9.6.4 SET statement_timeout = 0; SET lock_timeout = 0; diff --git a/db/tables.yml b/db/tables.yml index ed5417a9e2..6bf93a9e93 100644 --- a/db/tables.yml +++ b/db/tables.yml @@ -3567,6 +3567,9 @@ interventions: type: datetime actions: type: string + auto_calculate_working_periods: + type: boolean + default: false created_at: type: datetime required: true @@ -6385,8 +6388,6 @@ products: type: integer picture_updated_at: type: datetime - reading_cache: - type: jsonb team_id: type: integer references: team diff --git a/test/fixtures/interventions.yml b/test/fixtures/interventions.yml index 0618ecf98c..c04455c9ea 100644 --- a/test/fixtures/interventions.yml +++ b/test/fixtures/interventions.yml @@ -22,33 +22,34 @@ # # == Table: interventions # -# accounted_at :datetime -# actions :string -# created_at :datetime not null -# creator_id :integer -# currency :string -# custom_fields :jsonb -# description :text -# event_id :integer -# id :integer not null, primary key -# issue_id :integer -# journal_entry_id :integer -# lock_version :integer default(0), not null -# nature :string not null -# number :string -# prescription_id :integer -# procedure_name :string not null -# request_compliant :boolean -# request_intervention_id :integer -# started_at :datetime not null -# state :string not null -# stopped_at :datetime not null -# trouble_description :text -# trouble_encountered :boolean default(FALSE), not null -# updated_at :datetime not null -# updater_id :integer -# whole_duration :integer not null -# working_duration :integer not null +# accounted_at :datetime +# actions :string +# auto_calculate_working_periods :boolean default(FALSE) +# created_at :datetime not null +# creator_id :integer +# currency :string +# custom_fields :jsonb +# description :text +# event_id :integer +# id :integer not null, primary key +# issue_id :integer +# journal_entry_id :integer +# lock_version :integer default(0), not null +# nature :string not null +# number :string +# prescription_id :integer +# procedure_name :string not null +# request_compliant :boolean +# request_intervention_id :integer +# started_at :datetime not null +# state :string not null +# stopped_at :datetime not null +# trouble_description :text +# trouble_encountered :boolean default(FALSE), not null +# updated_at :datetime not null +# updater_id :integer +# whole_duration :integer not null +# working_duration :integer not null # --- interventions_001: diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 3b932b959a..a2c40fa16c 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/animal_group_test.rb b/test/models/animal_group_test.rb index e9e4fe26d7..7f6ae4dac3 100644 --- a/test/models/animal_group_test.rb +++ b/test/models/animal_group_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/animal_test.rb b/test/models/animal_test.rb index 14c7d80571..360815cde5 100644 --- a/test/models/animal_test.rb +++ b/test/models/animal_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/bioproduct_test.rb b/test/models/bioproduct_test.rb index 607017f7d1..1a81394319 100644 --- a/test/models/bioproduct_test.rb +++ b/test/models/bioproduct_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/building_division_test.rb b/test/models/building_division_test.rb index 2eab324a06..c333b3b806 100644 --- a/test/models/building_division_test.rb +++ b/test/models/building_division_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/building_test.rb b/test/models/building_test.rb index 76f88b7d63..b86912db1c 100644 --- a/test/models/building_test.rb +++ b/test/models/building_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/easement_test.rb b/test/models/easement_test.rb index 5b858aba4f..7d376c18ec 100644 --- a/test/models/easement_test.rb +++ b/test/models/easement_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/equipment_fleet_test.rb b/test/models/equipment_fleet_test.rb index 44142948ce..2656991345 100644 --- a/test/models/equipment_fleet_test.rb +++ b/test/models/equipment_fleet_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/equipment_test.rb b/test/models/equipment_test.rb index 6e819b3ae2..a11010d8f2 100644 --- a/test/models/equipment_test.rb +++ b/test/models/equipment_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/fungus_test.rb b/test/models/fungus_test.rb index 4aae6f76be..d064b3a1eb 100644 --- a/test/models/fungus_test.rb +++ b/test/models/fungus_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/intervention_test.rb b/test/models/intervention_test.rb index 46626410ce..7ea7e2f1fb 100644 --- a/test/models/intervention_test.rb +++ b/test/models/intervention_test.rb @@ -22,33 +22,34 @@ # # == Table: interventions # -# accounted_at :datetime -# actions :string -# created_at :datetime not null -# creator_id :integer -# currency :string -# custom_fields :jsonb -# description :text -# event_id :integer -# id :integer not null, primary key -# issue_id :integer -# journal_entry_id :integer -# lock_version :integer default(0), not null -# nature :string not null -# number :string -# prescription_id :integer -# procedure_name :string not null -# request_compliant :boolean -# request_intervention_id :integer -# started_at :datetime not null -# state :string not null -# stopped_at :datetime not null -# trouble_description :text -# trouble_encountered :boolean default(FALSE), not null -# updated_at :datetime not null -# updater_id :integer -# whole_duration :integer not null -# working_duration :integer not null +# accounted_at :datetime +# actions :string +# auto_calculate_working_periods :boolean default(FALSE) +# created_at :datetime not null +# creator_id :integer +# currency :string +# custom_fields :jsonb +# description :text +# event_id :integer +# id :integer not null, primary key +# issue_id :integer +# journal_entry_id :integer +# lock_version :integer default(0), not null +# nature :string not null +# number :string +# prescription_id :integer +# procedure_name :string not null +# request_compliant :boolean +# request_intervention_id :integer +# started_at :datetime not null +# state :string not null +# stopped_at :datetime not null +# trouble_description :text +# trouble_encountered :boolean default(FALSE), not null +# updated_at :datetime not null +# updater_id :integer +# whole_duration :integer not null +# working_duration :integer not null # require 'test_helper' diff --git a/test/models/land_parcel_test.rb b/test/models/land_parcel_test.rb index 2d2505ae6f..7e04c316f1 100644 --- a/test/models/land_parcel_test.rb +++ b/test/models/land_parcel_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/matter_test.rb b/test/models/matter_test.rb index 22a31b227c..76e85d8b74 100644 --- a/test/models/matter_test.rb +++ b/test/models/matter_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/plant_test.rb b/test/models/plant_test.rb index 86a24fbd40..44ef3b6091 100644 --- a/test/models/plant_test.rb +++ b/test/models/plant_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/product_group_test.rb b/test/models/product_group_test.rb index 81bafdbcb0..58880783f5 100644 --- a/test/models/product_group_test.rb +++ b/test/models/product_group_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/product_test.rb b/test/models/product_test.rb index 5e3ac3d526..739e5c085c 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/settlement_test.rb b/test/models/settlement_test.rb index 27225dc5d5..443f7be6f8 100644 --- a/test/models/settlement_test.rb +++ b/test/models/settlement_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/sub_zone_test.rb b/test/models/sub_zone_test.rb index d1e204d858..3df231162d 100644 --- a/test/models/sub_zone_test.rb +++ b/test/models/sub_zone_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/worker_test.rb b/test/models/worker_test.rb index e19ab54fcc..3620dc819a 100644 --- a/test/models/worker_test.rb +++ b/test/models/worker_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string diff --git a/test/models/zone_test.rb b/test/models/zone_test.rb index bcf7218b29..c551b585e1 100644 --- a/test/models/zone_test.rb +++ b/test/models/zone_test.rb @@ -73,7 +73,6 @@ # picture_file_name :string # picture_file_size :integer # picture_updated_at :datetime -# reading_cache :jsonb default("{}") # team_id :integer # tracking_id :integer # type :string