From c35156e487918de10b57e0d53228ae53c2500cf7 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Tue, 28 Apr 2020 10:41:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=88=9B=E5=BB=BA=E7=9A=84=E4=B8=BA=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 ++ Gemfile.lock | 37 +++++++++++++++++++++ app/controllers/issue_depends_controller.rb | 4 +-- app/controllers/issue_times_controller.rb | 6 ++-- app/controllers/issues_controller.rb | 8 ++--- app/controllers/pull_requests_controller.rb | 8 ++--- app/models/issue.rb | 8 ++--- 7 files changed, 56 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 98e980ff9..3c1341bb2 100644 --- a/Gemfile +++ b/Gemfile @@ -60,6 +60,8 @@ group :development, :test do end group :development do + gem 'rubocop', '~> 0.52.0' + gem 'solargraph', '~> 0.38.0' gem 'awesome_print' gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' diff --git a/Gemfile.lock b/Gemfile.lock index a8a00fc30..15118348d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,7 @@ GEM archive-zip (0.12.0) io-like (~> 0.3.0) arel (9.0.0) + ast (2.4.0) autoprefixer-rails (9.7.4) execjs awesome_print (1.8.0) @@ -75,6 +76,8 @@ GEM axlsx_rails (0.5.2) actionpack (>= 3.1) axlsx (>= 2.0.1) + backport (1.1.2) + benchmark (0.1.0) bindex (0.8.1) bootsnap (1.4.6) msgpack (~> 1.0) @@ -107,6 +110,7 @@ GEM activerecord (>= 3.1.0, < 7) diff-lcs (1.3) diffy (3.3.0) + e2mmap (0.1.0) elasticsearch (7.5.0) elasticsearch-api (= 7.5.0) elasticsearch-transport (= 7.5.0) @@ -140,6 +144,7 @@ GEM i18n (1.8.2) concurrent-ruby (~> 1.0) io-like (0.3.1) + jaro_winkler (1.5.4) jbuilder (2.10.0) activesupport (>= 5.0.0) jquery-rails (4.3.5) @@ -170,6 +175,7 @@ GEM mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) + maruku (0.7.3) method_source (0.9.2) mime-types (3.3.1) mime-types-data (~> 3.2015) @@ -205,8 +211,11 @@ GEM oauth2 (~> 1.1) omniauth (~> 1.9) parallel (1.19.1) + parser (2.7.1.1) + ast (~> 2.4.0) pdfkit (0.8.4.1) popper_js (1.16.0) + powerpack (0.1.2) public_suffix (4.0.3) puma (3.12.2) rack (2.0.9) @@ -243,6 +252,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) + rainbow (3.0.0) rake (13.0.1) rb-fsevent (0.10.3) rb-inotify (0.10.1) @@ -269,6 +279,8 @@ GEM regexp_parser (1.7.0) request_store (1.5.0) rack (>= 1.4) + reverse_markdown (1.4.0) + nokogiri roo (2.8.3) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) @@ -298,7 +310,15 @@ GEM rspec-mocks (~> 3.9.0) rspec-support (~> 3.9.0) rspec-support (3.9.2) + rubocop (0.52.1) + parallel (~> 1.10) + parser (>= 2.4.0.2, < 3.0) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) ruby-ole (1.2.12.2) + ruby-progressbar (1.10.1) ruby2_keywords (0.0.2) ruby_dep (1.5.0) rubyzip (1.3.0) @@ -344,6 +364,20 @@ GEM rack (~> 2.0) rack-protection (= 2.0.8.1) tilt (~> 2.0) + solargraph (0.38.6) + backport (~> 1.1) + benchmark + bundler (>= 1.17.2) + e2mmap + jaro_winkler (~> 1.5) + maruku (~> 0.7, >= 0.7.3) + nokogiri (~> 1.9, >= 1.9.1) + parser (~> 2.3) + reverse_markdown (~> 1.0, >= 1.0.5) + rubocop (~> 0.52) + thor (~> 1.0) + tilt (~> 2.0) + yard (~> 0.9) spreadsheet (1.2.6) ruby-ole (>= 1.0) spring (2.0.2) @@ -382,6 +416,7 @@ GEM wkhtmltopdf-binary (0.12.5.4) xpath (3.2.0) nokogiri (~> 1.8) + yard (0.9.24) PLATFORMS ruby @@ -434,6 +469,7 @@ DEPENDENCIES rqrcode (~> 0.10.1) rqrcode_png rspec-rails (~> 3.8) + rubocop (~> 0.52.0) ruby-ole rubyzip sass-rails (~> 5.0) @@ -443,6 +479,7 @@ DEPENDENCIES simple_form simple_xlsx_reader sinatra + solargraph (~> 0.38.0) spreadsheet spring spring-watcher-listen (~> 2.0.0) diff --git a/app/controllers/issue_depends_controller.rb b/app/controllers/issue_depends_controller.rb index 1a194fbb9..d07675aab 100644 --- a/app/controllers/issue_depends_controller.rb +++ b/app/controllers/issue_depends_controller.rb @@ -11,7 +11,7 @@ class IssueDependsController < ApplicationController } save_issue_depend = IssueDepend.new(issue_depend) if save_issue_depend.save - @issue.custom_journal_detail("issue_depend","", @issue.id) + @issue.custom_journal_detail("issue_depend","", @issue.id, current_user&.id) normal_status(0, "添加依赖成功") else normal_status(0, "添加依赖失败") @@ -23,7 +23,7 @@ class IssueDependsController < ApplicationController depend_issue_params = params[:id] depend_issue = IssueDepend.find(depend_issue_params) if depend_issue&.destroy - @issue.custom_journal_detail("destroy_issue_depend","", @issue.id) + @issue.custom_journal_detail("destroy_issue_depend","", @issue.id, current_user&.id) normal_status(0, "删除依赖成功") else normal_status(-1, "删除依赖失败") diff --git a/app/controllers/issue_times_controller.rb b/app/controllers/issue_times_controller.rb index 9574f4ad3..7b6dadfe7 100644 --- a/app/controllers/issue_times_controller.rb +++ b/app/controllers/issue_times_controller.rb @@ -11,7 +11,7 @@ class IssueTimesController < ApplicationController } save_issue_time = IssueTime.new(issue_time) if save_issue_time.save - @issue.custom_journal_detail("work_time",save_issue_time.id, "开始工作") + @issue.custom_journal_detail("work_time",save_issue_time.id, "开始工作", current_user&.id) normal_status(0, "开始成功") else normal_status(0, "开始失败") @@ -27,10 +27,10 @@ class IssueTimesController < ApplicationController if last_work_time.update_all(end_time: end_work_time) if end_type == 0 message = "取消时间跟踪" - @issue.custom_journal_detail("cancel_time",last_work_time&.first.try(:id), "取消时间跟踪") + @issue.custom_journal_detail("cancel_time",last_work_time&.first.try(:id), "取消时间跟踪", current_user&.id) else message = "停止工作" - @issue.custom_journal_detail("end_time",last_work_time&.first.try(:id), "停止工作") + @issue.custom_journal_detail("end_time",last_work_time&.first.try(:id), "停止工作", current_user&.id) end normal_status(0, message) else diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e972ef7e9..966043136 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -268,7 +268,7 @@ class IssuesController < ApplicationController @issue.issue_times.update_all(end_time: Time.now) end - @issue.create_journal_detail(change_files, issue_files, issue_file_ids) + @issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id) normal_status(0, "更新成功") else normal_status(-1, "更新失败") @@ -338,7 +338,7 @@ class IssuesController < ApplicationController else close_message = "close_pr" end - @issue.custom_journal_detail(close_message,old_message, "#{message}") + @issue.custom_journal_detail(close_message,old_message, "#{message}", current_user&.id) normal_status(0, message) else @@ -351,9 +351,9 @@ class IssuesController < ApplicationController type = (params[:lock_type].to_i == 1) if @issue.update_attribute(:is_lock, type) if type - @issue.custom_journal_detail("lock_issue","", "因为#{params[:lock_reason].present? ? params[:lock_reason].to_s : "某种原因"}而锁定,并将对话限制为协作者") + @issue.custom_journal_detail("lock_issue","", "因为#{params[:lock_reason].present? ? params[:lock_reason].to_s : "某种原因"}而锁定,并将对话限制为协作者", current_user&.id) else - @issue.custom_journal_detail("unlock_issue","", "解除锁定") + @issue.custom_journal_detail("unlock_issue","", "解除锁定", current_user&.id) end normal_status(0, "操作成功") else diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 6288d49ee..4ef15e205 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -138,7 +138,7 @@ class PullRequestsController < ApplicationController end local_requests.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create") if params[:title].to_s.include?("WIP:") - pull_issue.custom_journal_detail("WIP", "", "这个合并请求被标记为尚未完成的工作。完成后请从标题中移除WIP:前缀。") + pull_issue.custom_journal_detail("WIP", "", "这个合并请求被标记为尚未完成的工作。完成后请从标题中移除WIP:前缀。", current_user&.id) end normal_status(0, "PullRequest创建成功") else @@ -224,7 +224,7 @@ class PullRequestsController < ApplicationController if params[:status_id].to_i == 5 @issue.issue_times.update_all(end_time: Time.now) end - @issue.create_journal_detail(change_files, issue_files, issue_file_ids) + @issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id) normal_status(0, "PullRequest更新成功") else normal_status(-1, "PullRequest更新失败") @@ -306,7 +306,7 @@ class PullRequestsController < ApplicationController # @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge") @pull_request&.project_trends&.update_all(action_type: "close") - @issue&.custom_journal_detail("merge", "", "该合并请求已被合并") + @issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id) normal_status(1, "合并成功") else normal_status(-1, "合并失败") @@ -357,7 +357,7 @@ class PullRequestsController < ApplicationController if merge_pr @pull_request&.project_trends&.update_all(action_type: "close") # @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge") - @issue.custom_journal_detail("merge", "", "该合并请求已被合并") + @issue.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id) normal_status(1, "评审成功") else normal_status(-1, "评审失败") diff --git a/app/models/issue.rb b/app/models/issue.rb index 3d222a31d..d05caa70e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -30,9 +30,9 @@ class Issue < ApplicationRecord User.select(:login, :lastname,:firstname, :nickname)&.find_by_id(self.assigned_to_id) end - def create_journal_detail(change_files, issue_files, issue_file_ids) + def create_journal_detail(change_files, issue_files, issue_file_ids, user_id) journal_params = { - journalized_id: self.id, journalized_type: "Issue", user_id: self.author_id + journalized_id: self.id, journalized_type: "Issue", user_id: user_id } journal = Journal.new journal_params @@ -51,9 +51,9 @@ class Issue < ApplicationRecord end end - def custom_journal_detail(prop_key, old_value, value) + def custom_journal_detail(prop_key, old_value, value, user_id) journal_params = { - journalized_id: self.id, journalized_type: "Issue", user_id: self.author_id + journalized_id: self.id, journalized_type: "Issue", user_id: user_id } journal = Journal.new journal_params if journal.save