From ade03c5e2facf3e164c043630b2106fac881378a Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Feb 2023 16:55:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Aissue=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue.rb | 3 +++ app/models/issue_participant.rb | 9 +++++++++ app/models/user.rb | 2 ++ .../20230208023811_create_issue_participants.rb | 11 +++++++++++ 4 files changed, 25 insertions(+) create mode 100644 app/models/issue_participant.rb create mode 100644 db/migrate/20230208023811_create_issue_participants.rb diff --git a/app/models/issue.rb b/app/models/issue.rb index 069fae40a..11375f4b9 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -70,6 +70,8 @@ class Issue < ApplicationRecord has_many :issue_depends, dependent: :destroy has_many :issue_assigners has_many :assigners, through: :issue_assigners + has_many :issue_participants + has_many :participants, through: :issue_participants scope :issue_includes, ->{includes(:user)} scope :issue_many_includes, ->{includes(journals: :user)} @@ -77,6 +79,7 @@ class Issue < ApplicationRecord scope :issue_pull_request, ->{where(issue_classify: "pull_request")} scope :issue_index_includes, ->{includes(:tracker, :priority, :version, :issue_status, :journals,:issue_tags,user: :user_extension)} scope :closed, ->{where(status_id: 5)} + scope :opened, ->{where.not(status_id: 5)} after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic after_save :change_versions_count, :send_update_message_to_notice_system after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic diff --git a/app/models/issue_participant.rb b/app/models/issue_participant.rb new file mode 100644 index 000000000..fa7be6980 --- /dev/null +++ b/app/models/issue_participant.rb @@ -0,0 +1,9 @@ +class IssueParticipant < ApplicationRecord + + belongs_to :issue + belongs_to :participant, class_name: "User" + + enum participant_type: {"authored": 0, "assigned": 1, "commented": 2, "edited": 3, "atme": 4} + + +end diff --git a/app/models/user.rb b/app/models/user.rb index 9162702fc..cb39e42e7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,6 +177,8 @@ class User < Owner has_many :feedbacks, dependent: :destroy has_many :issue_assigners, foreign_key: :assigner_id has_many :assigned_issues, through: :issue_assigners, source: :issue + has_many :issue_participants, foreign_key: :participant_id + has_many :participant_issues, through: :issue_participants, source: :issue # Groups and active users scope :active, lambda { where(status: STATUS_ACTIVE) } scope :like, lambda { |keywords| diff --git a/db/migrate/20230208023811_create_issue_participants.rb b/db/migrate/20230208023811_create_issue_participants.rb new file mode 100644 index 000000000..834061053 --- /dev/null +++ b/db/migrate/20230208023811_create_issue_participants.rb @@ -0,0 +1,11 @@ +class CreateIssueParticipants < ActiveRecord::Migration[5.2] + def change + create_table :issue_participants do |t| + t.references :issue + t.references :participant, references: :user + t.integer :participant_type, default: 0 + + t.timestamps + end + end +end