From bd58f4dee313314b76ef7cd9930ecc8f901960fd Mon Sep 17 00:00:00 2001 From: Matheus Bernardo Date: Wed, 13 Dec 2017 21:24:27 -0200 Subject: [PATCH 1/2] Filtering issues to not get pull requests --- app/controllers/issues_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 8e0b9f8..1452edd 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -124,11 +124,11 @@ def convert_form_params(issue) if issue.kind_of?(Array) @issues.each do |issue| assignees = assingnee_counter(issue) - @form_params[:issues_infos].push(name: issue.title, number: issue.number, body: issue.body, issue_id: issue.id, assignees: assignees) + @form_params[:issues_infos].push(name: issue.title, number: issue.number, body: issue.body, issue_id: issue.id, assignees: assignees) unless issue.pull_request end else assignees = assingnee_counter(issue) - @form_params[:issues_infos].push(name: issue.title, number: issue.number, body: issue.body, issue_id: issue.id, assignees: assignees) + @form_params[:issues_infos].push(name: issue.title, number: issue.number, body: issue.body, issue_id: issue.id, assignees: assignees) unless issue.pull_request end @form_params end From 09ee2e16b88b9ce8852c40be12d68fed7e728d6e Mon Sep 17 00:00:00 2001 From: ThalissonMelo Date: Wed, 13 Dec 2017 21:44:59 -0200 Subject: [PATCH 2/2] Extracting methods to reduce the complexity --- app/controllers/issues_controller.rb | 13 ++++++++----- db/schema.rb | 13 ++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 1452edd..6ac4422 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -123,17 +123,15 @@ def convert_form_params(issue) @form_params = { issues_infos: [] } if issue.kind_of?(Array) @issues.each do |issue| - assignees = assingnee_counter(issue) - @form_params[:issues_infos].push(name: issue.title, number: issue.number, body: issue.body, issue_id: issue.id, assignees: assignees) unless issue.pull_request + make_form_params(issue) end else - assignees = assingnee_counter(issue) - @form_params[:issues_infos].push(name: issue.title, number: issue.number, body: issue.body, issue_id: issue.id, assignees: assignees) unless issue.pull_request + make_form_params(issue) end @form_params end - def assingnee_counter(issue) + def assignee_counter(issue) assignees = [] if issue.assignees.count > 0 issue.assignees.each do |assignee| @@ -143,6 +141,11 @@ def assingnee_counter(issue) assignees end + def make_form_params(issue) + assignees = assignee_counter(issue) + @form_params[:issues_infos].push(name: issue.title, number: issue.number, body: issue.body, issue_id: issue.id, assignees: assignees) unless issue.pull_request + end + def issue_params params.require(:issue).permit(:name, :body, :number) end diff --git a/db/schema.rb b/db/schema.rb index 1f0d0bd..d555bd3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,21 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171212131724) do +ActiveRecord::Schema.define(version: 20171213000135) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "grades", force: :cascade do |t| + t.float "weight_burndown" + t.float "weight_velocity" + t.float "weight_debts" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "project_id" + t.index ["project_id"], name: "index_grades_on_project_id" + end + create_table "issues", force: :cascade do |t| t.string "title" t.text "body" @@ -106,6 +116,7 @@ t.string "access_token" end + add_foreign_key "grades", "projects" add_foreign_key "projects", "users" add_foreign_key "releases", "projects" add_foreign_key "retrospectives", "sprints"