From 42d2b51f7f2df6788119d2c3489dcdd8c5ab4947 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 16 Jun 2022 13:42:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=95=8F=E6=84=9F=E8=AF=8D=E5=88=A4=E5=AE=9A=E5=8F=AA=E5=9C=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=88=96=E8=80=85=E6=9B=B4=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 2 +- app/models/project_unit.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 9c77685f7..edaa00eb5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -141,7 +141,7 @@ class Project < ApplicationRecord delegate :content, to: :project_detail, allow_nil: true delegate :name, to: :license, prefix: true, allow_nil: true - validate :validate_sensitive_string + validate :validate_sensitive_string, on: [:create, :update] def self.all_visible(user_id=nil) user_projects_sql = Project.joins(:owner).where(users: {type: 'User'}).to_sql diff --git a/app/models/project_unit.rb b/app/models/project_unit.rb index cc35a6b28..01f6c6670 100644 --- a/app/models/project_unit.rb +++ b/app/models/project_unit.rb @@ -14,6 +14,8 @@ # class ProjectUnit < ApplicationRecord + + default_scope {where(unit_type: ProjectUnit.unit_types.keys)} belongs_to :project enum unit_type: {code: 1, issues: 2, pulls: 3, wiki:4, devops: 5, versions: 6, resources: 7} From 3d0e32380145aac8574ee1773e0762978369f8fb Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 17 Jun 2022 14:07:33 +0800 Subject: [PATCH 2/3] fix --- app/models/project_unit.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/project_unit.rb b/app/models/project_unit.rb index 01f6c6670..c3810ff8c 100644 --- a/app/models/project_unit.rb +++ b/app/models/project_unit.rb @@ -15,7 +15,6 @@ class ProjectUnit < ApplicationRecord - default_scope {where(unit_type: ProjectUnit.unit_types.keys)} belongs_to :project enum unit_type: {code: 1, issues: 2, pulls: 3, wiki:4, devops: 5, versions: 6, resources: 7} From 5b4e6f490279752352740e5fd4503a7bc06f75ac Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 17 Jun 2022 14:19:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=95=8F=E6=84=9F=E8=AF=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?forked=E6=95=B0=E9=87=8F=E4=BD=BF=E7=94=A8update=5Fcolumn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index edaa00eb5..444a0ec87 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -187,7 +187,7 @@ class Project < ApplicationRecord forked_project = self.forked_from_project if forked_project.present? forked_project.decrement(:forked_count, 1) - forked_project.save + forked_project.update_column(:forked_count, forked_project.forked_count) end end