From 4da7d92adec7dcaf09dd384184f11450bfdfa618 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:00:30 +0800 Subject: [PATCH 1/8] try --- app/models/program.rb | 47 +++++++++++++++++++++++++++++++ app/models/scrum_sprint_member.rb | 17 +++++++++++ 2 files changed, 64 insertions(+) create mode 100644 app/models/program.rb create mode 100644 app/models/scrum_sprint_member.rb diff --git a/app/models/program.rb b/app/models/program.rb new file mode 100644 index 0000000..75a05f2 --- /dev/null +++ b/app/models/program.rb @@ -0,0 +1,47 @@ +class Program < ActiveRecord::Base + acts_as_cached(:version => 3, :expires_in => 1.day) + attr_accessible :name, :description, :assignee_id, :author_id, :outsourced, :user_ids, :project_ids, + + validates :name, presence: true, length: { maximum: 191 } + + validate :validate_category + belongs_to :assignee, class_name: 'User' + + RESOURCES = %w(projects issues pull_requests members attach_files events milestones docs) + + STANDARD = 'standard' #常规项目 + SCRUM = 'scrum' # scrum项目 + CATEGORIES = [STANDARD, SCRUM] + + class << self + def fuzzy_search(keyword) + keyword.strip! + where('`programs`.name LIKE :name', name: "%#{keyword}%") + end + end + + def is_assignee?(user_id) + user_id == assignee_id + end + + def is_scrum? + SCRUM == category + end + + # 生成项目编号 + def generate_ident + ident = enterprise.enterprise_info.lastest_ident + end + + def kafka_topic_key + "#{self.class.name}-#{self.id}" + end + + protected + + def format_content + self.outsourced ||= 0 + self.status ||= 0 + end + +end diff --git a/app/models/scrum_sprint_member.rb b/app/models/scrum_sprint_member.rb new file mode 100644 index 0000000..360660d --- /dev/null +++ b/app/models/scrum_sprint_member.rb @@ -0,0 +1,17 @@ +class ScrumSprintMember < ActiveRecord::Base + MEMBER = 1 + ASSIGNEE = 2 + ROLE_LEVELS = [MEMBER, ASSIGNEE] + + validates_uniqueness_of :user_id, scope: :scrum_sprint_id + validate :validate_role_level + + private + + def validate_role_level + return unless role_level_changed? + return if ROLE_LEVELS.include?(role_level) + + errors.add(:role_level, :error) + end +end \ No newline at end of file -- Gitee From 2d7c8e508d44e21c4b7781db61b6b26cc259b54a Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:10:07 +0800 Subject: [PATCH 2/8] change update --- .workflow/check_run-pipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index 8e15c24..ca31f83 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -21,12 +21,13 @@ stages: - gem install base64 - gem install rubocop -v0.81.0 - gem install rubocop-performance + - gem install rugged -v1.1.0 - gem install pronto - gem install pronto-rubocop - Run Script: - git fetch https://gitee.com/${AGILE_MODULE_NAME}.git pull/${AGILE_PULL_ID}/head:pr_${AGILE_PULL_ID} - - git check pr_${AGILE_PULL_ID} + - git checkout pr_${AGILE_PULL_ID} - ruby "./script/rubocop_check.rb" ${AGILE_MODULE_NAME} ${AGILE_SOURCE_REVISION} ${AGILE_REVISION} ${AGILE_PULL_ID} ${ACCESS_TOKEN} triggers: pr: -- Gitee From 0ef99e3a8da9ad1bf0700eaec00ab1be3aa3feb1 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:16:18 +0800 Subject: [PATCH 3/8] install pkg-config --- .workflow/check_run-pipeline.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index ca31f83..7fb4b0c 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -14,6 +14,9 @@ stages: - Int: - echo `ruby -v` - echo `pwd` + - APT GET: + - sudo apt-get install cmake + - sudo apt-get install pkg-config - Install RubyENV: - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ - gem install rest-client @@ -21,7 +24,6 @@ stages: - gem install base64 - gem install rubocop -v0.81.0 - gem install rubocop-performance - - gem install rugged -v1.1.0 - gem install pronto - gem install pronto-rubocop -- Gitee From 4866396502402faafb3102397f2b5a764714b298 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:18:06 +0800 Subject: [PATCH 4/8] install pkg-config --- .workflow/check_run-pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index 7fb4b0c..ea47f29 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -15,8 +15,8 @@ stages: - echo `ruby -v` - echo `pwd` - APT GET: - - sudo apt-get install cmake - - sudo apt-get install pkg-config + - apt-get install cmake + - apt-get install pkg-config - Install RubyENV: - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ - gem install rest-client -- Gitee From fe61fcfbc695d3b7f4172c48c67580c18358b882 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:31:30 +0800 Subject: [PATCH 5/8] apt-get update --- .workflow/check_run-pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index ea47f29..e7047dc 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -15,6 +15,7 @@ stages: - echo `ruby -v` - echo `pwd` - APT GET: + - apt-get update - apt-get install cmake - apt-get install pkg-config - Install RubyENV: -- Gitee From 8228f6785b4dda5b263aefbdc25486fa27027b14 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:44:59 +0800 Subject: [PATCH 6/8] disable suggestions --- .pronto.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pronto.yml b/.pronto.yml index 5489915..08b1326 100644 --- a/.pronto.yml +++ b/.pronto.yml @@ -5,4 +5,4 @@ rubocop: fatal: error # Enable suggestions - suggestions: true \ No newline at end of file + suggestions: false \ No newline at end of file -- Gitee From f87d1b03213b920a66e8f81d54538d20213fb563 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:53:42 +0800 Subject: [PATCH 7/8] suggest --- .pronto.yml | 2 +- .workflow/check_run-pipeline.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pronto.yml b/.pronto.yml index 08b1326..5489915 100644 --- a/.pronto.yml +++ b/.pronto.yml @@ -5,4 +5,4 @@ rubocop: fatal: error # Enable suggestions - suggestions: false \ No newline at end of file + suggestions: true \ No newline at end of file diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index e7047dc..5302b06 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -25,8 +25,8 @@ stages: - gem install base64 - gem install rubocop -v0.81.0 - gem install rubocop-performance - - gem install pronto - - gem install pronto-rubocop + - gem install pronto -v0.11.0 + - gem install pronto-rubocop -v0.11.0 - Run Script: - git fetch https://gitee.com/${AGILE_MODULE_NAME}.git pull/${AGILE_PULL_ID}/head:pr_${AGILE_PULL_ID} -- Gitee From d5a4cd9ba225b21827b12e16719fc5578e4bd677 Mon Sep 17 00:00:00 2001 From: liwen8 Date: Tue, 23 Nov 2021 14:59:39 +0800 Subject: [PATCH 8/8] update --- script/rubocop_check.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/rubocop_check.rb b/script/rubocop_check.rb index 1bb2e7f..db4fb2b 100644 --- a/script/rubocop_check.rb +++ b/script/rubocop_check.rb @@ -116,8 +116,8 @@ class RubocopAnalysis body: body, access_token: @access_token, path: file.path, - # position: file.line.commit_line.position, - position: file.line.commit_line.position + 1, + position: file.line.commit_line.position, + # position: file.line.commit_line.position + 1, commit_id: file.commit_sha } if get_exists_suggestions.find{|s| s[:path] == file.path && file.msg.include?(s[:body][20..-1]) && s[:commit_id] == file.commit_sha && s[:new_line] == file.line.new_lineno}.nil? -- Gitee