From cc31f00a7017679dde77a1d6bb1557b021e7aa40 Mon Sep 17 00:00:00 2001 From: amparostevens Date: Wed, 11 Jan 2023 12:50:56 -0300 Subject: [PATCH 1/3] chore: add duration to ignored columns on task --- app/models/task.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/task.rb b/app/models/task.rb index 4e24db7..feea036 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1,4 +1,7 @@ class Task < ApplicationRecord default_scope ->{ order(priority: :desc) } belongs_to :person + + self.ignored_columns = [:duration] + end From 734f2dde90978a075489828566dc0c526e2676fa Mon Sep 17 00:00:00 2001 From: amparostevens Date: Wed, 11 Jan 2023 12:59:57 -0300 Subject: [PATCH 2/3] chore: add new column duration to tasks --- db/migrate/20230111154617_add_duration_to_task.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230111154617_add_duration_to_task.rb diff --git a/db/migrate/20230111154617_add_duration_to_task.rb b/db/migrate/20230111154617_add_duration_to_task.rb new file mode 100644 index 0000000..23eb384 --- /dev/null +++ b/db/migrate/20230111154617_add_duration_to_task.rb @@ -0,0 +1,5 @@ +class AddDurationToTask < ActiveRecord::Migration[6.1] + def change + add_column :tasks, :duration, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 2518478..ec19a35 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_01_11_142035) do +ActiveRecord::Schema.define(version: 2023_01_11_154617) do create_table "people", force: :cascade do |t| t.string "first_name" @@ -28,6 +28,7 @@ t.integer "person_id", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.integer "duration" t.index ["person_id"], name: "index_tasks_on_person_id" end From bd4634119bac8a94f2532afc0a3a49524e470063 Mon Sep 17 00:00:00 2001 From: amparostevens Date: Wed, 11 Jan 2023 13:10:42 -0300 Subject: [PATCH 3/3] feat: add duration field to task --- app/controllers/people_controller.rb | 2 +- app/models/task.rb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index d03d7a0..c5daa34 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -15,7 +15,7 @@ def json_attributes methods: [:full_name], include: { tasks: { - only: [:name, :priority], + only: [:name, :priority, :duration], } }, } diff --git a/app/models/task.rb b/app/models/task.rb index feea036..4e24db7 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1,7 +1,4 @@ class Task < ApplicationRecord default_scope ->{ order(priority: :desc) } belongs_to :person - - self.ignored_columns = [:duration] - end