From f842fe1e875f92285e256dab8cb1f7f6790ff492 Mon Sep 17 00:00:00 2001 From: Kaio Magalhaes Date: Tue, 14 May 2024 13:47:14 -0300 Subject: [PATCH] add sprint to issues --- Gemfile | 2 +- app/models/issue.rb | 1 + app/services/issues_creator.rb | 2 +- app/utils/clients/tts/azure/issue.rb | 13 ++++++++--- .../azure/parsers/ministry_brands_parser.rb | 4 ++++ ...te_active_storage_tables.active_storage.rb | 23 +++++++++++-------- ...8_create_action_text_tables.action_text.rb | 19 ++++++++------- .../20240513143928_add_sprint_to_issues.rb | 7 ++++++ db/schema.rb | 3 ++- spec/factories/issues.rb | 1 + spec/models/issue_spec.rb | 1 + 11 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 db/migrate/20240513143928_add_sprint_to_issues.rb diff --git a/Gemfile b/Gemfile index 8ebf657..23f26b8 100644 --- a/Gemfile +++ b/Gemfile @@ -37,7 +37,7 @@ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] gem 'bootsnap', require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] -gem "image_processing", "~> 1.2" +gem 'image_processing', '~> 1.2' # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible gem 'rack-cors' diff --git a/app/models/issue.rb b/app/models/issue.rb index c00ad9e..dc9bb08 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -11,6 +11,7 @@ # effort :float # issue_type :string # reported_at :datetime +# sprint :string # state :string # title :string # created_at :datetime not null diff --git a/app/services/issues_creator.rb b/app/services/issues_creator.rb index aafb33d..469295c 100644 --- a/app/services/issues_creator.rb +++ b/app/services/issues_creator.rb @@ -17,7 +17,7 @@ def call Issue.create!(project: @project, effort: issue.effort, user: issue.user, state: issue.state, closed_date: issue.closed_date, title: issue.title, issue_type: issue.issue_type, reported_at: issue.reported_at, tts_id: issue.tts_id, bug: issue.bug?, - parent_tts_id: issue.parent_tts_id, board_column: issue.board_column) + parent_tts_id: issue.parent_tts_id, board_column: issue.board_column, sprint: issue.sprint) end.compact end rescue StandardError => e diff --git a/app/utils/clients/tts/azure/issue.rb b/app/utils/clients/tts/azure/issue.rb index 928ff75..cc15dcc 100644 --- a/app/utils/clients/tts/azure/issue.rb +++ b/app/utils/clients/tts/azure/issue.rb @@ -41,9 +41,16 @@ def url def body(area_path) { - 'query' => 'SELECT [System.Id], [System.Title], [System.WorkItemType], [System.BoardColumn] ' \ - 'FROM workitems ' \ - "WHERE [System.TeamProject] = '#{project_name}' AND [System.AreaPath] = '#{area_path}'" + 'query' => "SELECT + [System.Id], + [System.Title], + [System.WorkItemType], + [System.BoardColumn], + [System.IterationPath] + FROM workitems + WHERE + [System.TeamProject] = '#{project_name}' AND + [System.AreaPath] = '#{area_path}'" } end diff --git a/app/utils/clients/tts/azure/parsers/ministry_brands_parser.rb b/app/utils/clients/tts/azure/parsers/ministry_brands_parser.rb index ad24b2d..f7f0d06 100644 --- a/app/utils/clients/tts/azure/parsers/ministry_brands_parser.rb +++ b/app/utils/clients/tts/azure/parsers/ministry_brands_parser.rb @@ -62,6 +62,10 @@ def parent_tts_id def board_column json.dig('fields', 'System.BoardColumn') end + + def sprint + json.dig('fields', 'System.IterationPath') + end end end end diff --git a/db/migrate/20240411203957_create_active_storage_tables.active_storage.rb b/db/migrate/20240411203957_create_active_storage_tables.active_storage.rb index 8a7bfe1..414a228 100644 --- a/db/migrate/20240411203957_create_active_storage_tables.active_storage.rb +++ b/db/migrate/20240411203957_create_active_storage_tables.active_storage.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from active_storage (originally 20170806125915) class CreateActiveStorageTables < ActiveRecord::Migration[5.2] def change @@ -19,7 +21,7 @@ def change t.datetime :created_at, null: false end - t.index [ :key ], unique: true + t.index [:key], unique: true end create_table :active_storage_attachments, id: primary_key_type do |t| @@ -33,7 +35,7 @@ def change t.datetime :created_at, null: false end - t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true + t.index %i[record_type record_id name blob_id], name: :index_active_storage_attachments_uniqueness, unique: true t.foreign_key :active_storage_blobs, column: :blob_id end @@ -41,17 +43,18 @@ def change t.belongs_to :blob, null: false, index: false, type: foreign_key_type t.string :variation_digest, null: false - t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true + t.index %i[blob_id variation_digest], name: :index_active_storage_variant_records_uniqueness, unique: true t.foreign_key :active_storage_blobs, column: :blob_id end end private - def primary_and_foreign_key_types - config = Rails.configuration.generators - setting = config.options[config.orm][:primary_key_type] - primary_key_type = setting || :primary_key - foreign_key_type = setting || :bigint - [primary_key_type, foreign_key_type] - end + + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [primary_key_type, foreign_key_type] + end end diff --git a/db/migrate/20240411203958_create_action_text_tables.action_text.rb b/db/migrate/20240411203958_create_action_text_tables.action_text.rb index 1be48d7..cd9ea68 100644 --- a/db/migrate/20240411203958_create_action_text_tables.action_text.rb +++ b/db/migrate/20240411203958_create_action_text_tables.action_text.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from action_text (originally 20180528164100) class CreateActionTextTables < ActiveRecord::Migration[6.0] def change @@ -11,16 +13,17 @@ def change t.timestamps - t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true + t.index %i[record_type record_id name], name: 'index_action_text_rich_texts_uniqueness', unique: true end end private - def primary_and_foreign_key_types - config = Rails.configuration.generators - setting = config.options[config.orm][:primary_key_type] - primary_key_type = setting || :primary_key - foreign_key_type = setting || :bigint - [primary_key_type, foreign_key_type] - end + + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [primary_key_type, foreign_key_type] + end end diff --git a/db/migrate/20240513143928_add_sprint_to_issues.rb b/db/migrate/20240513143928_add_sprint_to_issues.rb new file mode 100644 index 0000000..6973648 --- /dev/null +++ b/db/migrate/20240513143928_add_sprint_to_issues.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSprintToIssues < ActiveRecord::Migration[7.0] + def change + add_column :issues, :sprint, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 843f627..1f8f25b 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[7.0].define(version: 2024_04_11_203958) do +ActiveRecord::Schema[7.0].define(version: 2024_05_13_143928) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -130,6 +130,7 @@ t.boolean "bug", default: false, null: false t.string "parent_tts_id" t.string "board_column" + t.string "sprint" t.index ["project_id"], name: "index_issues_on_project_id" end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index 76467c0..070dcbf 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -11,6 +11,7 @@ # effort :float # issue_type :string # reported_at :datetime +# sprint :string # state :string # title :string # created_at :datetime not null diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 0b976a3..6d392e6 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -11,6 +11,7 @@ # effort :float # issue_type :string # reported_at :datetime +# sprint :string # state :string # title :string # created_at :datetime not null