| @@ -1,5 +1,23 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: applied_messages | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # applied_id :integer | |||
| # applied_type :string(255) | |||
| # viewed :integer default("0") | |||
| # status :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # name :string(255) | |||
| # applied_user_id :integer | |||
| # role :integer | |||
| # project_id :integer | |||
| # | |||
| class AppliedMessage < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :applied, polymorphic: true | |||
| end | |||
| end | |||
| @@ -1,3 +1,14 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: applied_projects | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_id :integer not null | |||
| # user_id :integer not null | |||
| # role :integer default("0") | |||
| # status :integer default("0") | |||
| # | |||
| class AppliedProject < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :project | |||
| @@ -1,3 +1,26 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: apply_actions | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # reason :string(255) | |||
| # container_id :integer | |||
| # container_type :string(255) | |||
| # dealer_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # status :integer default("0") | |||
| # apply_reason :text(65535) | |||
| # noticed :boolean default("0") | |||
| # ip_addr :string(255) | |||
| # reject_description :string(255) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_apply_actions_on_user_id (user_id) | |||
| # | |||
| # 申请消息 | |||
| class ApplyAction < ApplicationRecord | |||
| belongs_to :user | |||
| @@ -27,4 +50,4 @@ class ApplyAction < ApplicationRecord | |||
| belong_container_id: container_id, belong_container_type: belong_container_type) | |||
| end | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,23 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: apply_user_authentications | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # status :integer | |||
| # auth_type :integer | |||
| # remarks :string(255) | |||
| # dealer :integer | |||
| # deal_time :datetime | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # is_delete :boolean default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_apply_user_authentications_on_user_id (user_id) | |||
| # | |||
| # status:0 审核中 1 同意 2 拒绝 3 撤销 | |||
| # auth_type:1 实名认证, 2 职业认证 | |||
| class ApplyUserAuthentication < ApplicationRecord | |||
| @@ -1,3 +1,36 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: attachments | |||
| # | |||
| # id :integer not null, primary key | |||
| # container_id :integer | |||
| # container_type :string(30) | |||
| # filename :string(255) default(""), not null | |||
| # disk_filename :string(255) default(""), not null | |||
| # filesize :integer default("0"), not null | |||
| # content_type :string(255) default("") | |||
| # digest :string(40) default(""), not null | |||
| # downloads :integer default("0"), not null | |||
| # author_id :integer default("0"), not null | |||
| # created_on :datetime | |||
| # description :text(65535) | |||
| # disk_directory :string(255) | |||
| # attachtype :integer default("1") | |||
| # is_public :integer default("1") | |||
| # copy_from :integer | |||
| # quotes :integer | |||
| # is_publish :integer default("1") | |||
| # publish_time :datetime | |||
| # memo_image :boolean default("0") | |||
| # extra_type :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_attachments_on_author_id (author_id) | |||
| # index_attachments_on_container_id_and_container_type (container_id,container_type) | |||
| # index_attachments_on_created_on (created_on) | |||
| # | |||
| class Attachment < ApplicationRecord | |||
| include BaseModel | |||
| include Publicable | |||
| @@ -1,3 +1,22 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: attachment_group_settings | |||
| # | |||
| # id :integer not null, primary key | |||
| # attachment_id :integer | |||
| # course_group_id :integer | |||
| # course_id :integer | |||
| # publish_time :datetime | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_attachment_group_settings_on_attachment_id (attachment_id) | |||
| # index_attachment_group_settings_on_course_group_id (course_group_id) | |||
| # index_attachment_group_settings_on_course_id (course_id) | |||
| # | |||
| class AttachmentGroupSetting < ActiveRecord::Base | |||
| belongs_to :attachment | |||
| # belongs_to :course_group | |||
| @@ -1,3 +1,31 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: attachment_histories | |||
| # | |||
| # id :integer not null, primary key | |||
| # container_id :integer | |||
| # container_type :string(255) | |||
| # filename :string(255) default("") | |||
| # disk_filename :string(255) default("") | |||
| # filesize :integer default("0") | |||
| # content_type :string(255) default("") | |||
| # digest :string(60) default("") | |||
| # downloads :integer default("0") | |||
| # author_id :integer | |||
| # created_on :datetime | |||
| # description :text(65535) | |||
| # disk_directory :string(255) | |||
| # attachtype :integer | |||
| # is_public :integer | |||
| # copy_from :integer | |||
| # quotes :integer | |||
| # version :integer | |||
| # attachment_id :integer | |||
| # is_publish :integer default("1") | |||
| # publish_time :date | |||
| # cloud_url :string(255) default("") | |||
| # | |||
| class AttachmentHistory < ApplicationRecord | |||
| include Publishable | |||
| include Publicable | |||
| @@ -1,3 +1,20 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: bidding_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_package_id :integer | |||
| # user_id :integer | |||
| # status :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_bidding_users_on_project_package_id (project_package_id) | |||
| # index_bidding_users_on_user_id (user_id) | |||
| # | |||
| class BiddingUser < ApplicationRecord | |||
| include AASM | |||
| @@ -21,4 +38,4 @@ class BiddingUser < ApplicationRecord | |||
| def status_text | |||
| I18n.t("bidding_user.status.#{status}") | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: ci_cloud_accounts | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer not null | |||
| # ip_num :integer | |||
| # account :string(255) | |||
| # secret :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # ci_user_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # dev_ops_cloud_accounts_p_u_ip (user_id,ip_num) | |||
| # | |||
| class Ci::CloudAccount < Ci::LocalBase | |||
| belongs_to :user | |||
| belongs_to :ci_user, class_name: 'Ci::User', foreign_key: :ci_user_id, optional: true | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: ci_languages | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) not null | |||
| # content :text(65535) not null | |||
| # usage_amount :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # cover_id :integer | |||
| # | |||
| class Ci::Language < Ci::LocalBase | |||
| # before_save :encode_content | |||
| @@ -1,3 +1,67 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: users | |||
| # | |||
| # id :integer not null | |||
| # login :string(255) default(""), not null | |||
| # hashed_password :string(40) default(""), not null | |||
| # firstname :string(30) default(""), not null | |||
| # lastname :string(255) default(""), not null | |||
| # mail :string(60) | |||
| # admin :boolean default("0"), not null | |||
| # status :integer default("1"), not null | |||
| # last_login_on :datetime | |||
| # language :string(5) default("") | |||
| # auth_source_id :integer | |||
| # created_on :datetime | |||
| # updated_on :datetime | |||
| # type :string(255) | |||
| # identity_url :string(255) | |||
| # mail_notification :string(255) default(""), not null | |||
| # salt :string(64) | |||
| # gid :integer | |||
| # visits :integer default("0") | |||
| # excellent_teacher :integer default("0") | |||
| # excellent_student :integer default("0") | |||
| # phone :string(255) | |||
| # authentication :boolean default("0") | |||
| # grade :integer default("0") | |||
| # experience :integer default("0") | |||
| # nickname :string(255) | |||
| # show_realname :boolean default("1") | |||
| # professional_certification :boolean default("0") | |||
| # ID_number :string(255) | |||
| # certification :integer default("0") | |||
| # homepage_teacher :boolean default("0") | |||
| # homepage_engineer :boolean default("0") | |||
| # is_test :integer default("0") | |||
| # ecoder_user_id :integer default("0") | |||
| # business :boolean default("0") | |||
| # profile_completed :boolean default("0") | |||
| # laboratory_id :integer | |||
| # platform :string(255) default("0") | |||
| # gitea_token :string(255) | |||
| # gitea_uid :integer | |||
| # is_shixun_marker :boolean default("0") | |||
| # is_sync_pwd :boolean default("1") | |||
| # watchers_count :integer default("0") | |||
| # visibility :string(255) default("public") | |||
| # repo_admin_change_team_access :boolean default("1") | |||
| # is_org :boolean default("0") | |||
| # website :string(255) | |||
| # devops_step :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_users_on_ecoder_user_id (ecoder_user_id) | |||
| # index_users_on_homepage_engineer (homepage_engineer) | |||
| # index_users_on_homepage_teacher (homepage_teacher) | |||
| # index_users_on_laboratory_id (laboratory_id) | |||
| # index_users_on_login (login) | |||
| # index_users_on_mail (mail) | |||
| # index_users_on_type (type) | |||
| # | |||
| class Ci::User < Ci::RemoteBase | |||
| self.primary_key = 'user_id' | |||
| @@ -1,3 +1,23 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: composes | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # title :string(255) | |||
| # description :text(65535) | |||
| # show_mode :integer default("0") | |||
| # compose_mode :boolean default("0") | |||
| # compose_users_count :integer default("0") | |||
| # compose_projects_count :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_composes_on_user_id_and_show_mode_and_compose_mode (user_id,show_mode,compose_mode) | |||
| # | |||
| class Compose < ApplicationRecord | |||
| #组织 | |||
| belongs_to :user | |||
| @@ -1,3 +1,20 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: compose_projects | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # project_id :integer | |||
| # compose_id :integer | |||
| # position :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_compose_projects_on_user_id_and_project_id_and_compose_id (user_id,project_id,compose_id) | |||
| # | |||
| class ComposeProject < ApplicationRecord | |||
| #组织的项目记录表 | |||
| belongs_to :compose | |||
| @@ -1,3 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: compose_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # compose_id :integer | |||
| # is_manager :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_compose_users_on_user_id_and_compose_id (user_id,compose_id) | |||
| # | |||
| class ComposeUser < ApplicationRecord | |||
| belongs_to :compose | |||
| belongs_to :user | |||
| @@ -1,5 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: coo_imgs | |||
| # | |||
| # id :integer not null, primary key | |||
| # src_states :string(255) | |||
| # url_states :string(255) | |||
| # img_type :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # position :integer | |||
| # | |||
| class CooImg < ApplicationRecord | |||
| extend Enumerize | |||
| enumerize :img_type, in: %i[com_coop edu_coop alliance_coop] | |||
| end | |||
| end | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: diff_records | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # container_type :string(255) | |||
| # container_id :integer | |||
| # column_name :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_diff_records_on_container_type_and_container_id (container_type,container_id) | |||
| # index_diff_records_on_user_id (user_id) | |||
| # | |||
| class DiffRecord < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :container, polymorphic: true | |||
| @@ -5,4 +23,4 @@ class DiffRecord < ApplicationRecord | |||
| has_one :diff_record_content, dependent: :destroy | |||
| delegate :content, to: :diff_record_content | |||
| end | |||
| end | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: diff_record_contents | |||
| # | |||
| # id :integer not null, primary key | |||
| # diff_record_id :integer | |||
| # content :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_diff_record_contents_on_diff_record_id (diff_record_id) | |||
| # | |||
| class DiffRecordContent < ApplicationRecord | |||
| belongs_to :diff_record | |||
| end | |||
| end | |||
| @@ -1,3 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: edu_settings | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # value :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # description :string(255) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_edu_settings_on_name (name) UNIQUE | |||
| # | |||
| class EduSetting < ApplicationRecord | |||
| after_commit :expire_value_cache | |||
| @@ -1,3 +1,20 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: fork_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_id :integer | |||
| # fork_project_id :integer | |||
| # user_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_fork_users_on_project_id (project_id) | |||
| # index_fork_users_on_user_id (user_id) | |||
| # | |||
| class ForkUser < ApplicationRecord | |||
| belongs_to :project | |||
| belongs_to :user | |||
| @@ -1,3 +1,14 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: ignores | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # content :text(65535) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class Ignore < ApplicationRecord | |||
| include Projectable | |||
| end | |||
| @@ -1,3 +1,53 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: issues | |||
| # | |||
| # id :integer not null, primary key | |||
| # tracker_id :integer not null | |||
| # project_id :integer not null | |||
| # subject :string(255) default(""), not null | |||
| # description :text(4294967295) | |||
| # due_date :date | |||
| # category_id :integer | |||
| # status_id :integer not null | |||
| # assigned_to_id :integer | |||
| # priority_id :integer not null | |||
| # fixed_version_id :integer | |||
| # author_id :integer not null | |||
| # created_on :datetime | |||
| # updated_on :datetime | |||
| # start_date :date | |||
| # done_ratio :integer default("0"), not null | |||
| # estimated_hours :float(24) | |||
| # parent_id :integer | |||
| # root_id :integer | |||
| # lft :integer | |||
| # rgt :integer | |||
| # is_private :boolean default("0"), not null | |||
| # closed_on :datetime | |||
| # project_issues_index :integer | |||
| # issue_type :string(255) | |||
| # token :integer default("0") | |||
| # issue_tags_value :string(255) | |||
| # is_lock :boolean default("0") | |||
| # issue_classify :string(255) | |||
| # ref_name :string(255) | |||
| # branch_name :string(255) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_issues_on_assigned_to_id (assigned_to_id) | |||
| # index_issues_on_author_id (author_id) | |||
| # index_issues_on_category_id (category_id) | |||
| # index_issues_on_created_on (created_on) | |||
| # index_issues_on_fixed_version_id (fixed_version_id) | |||
| # index_issues_on_priority_id (priority_id) | |||
| # index_issues_on_root_id_and_lft_and_rgt (root_id,lft,rgt) | |||
| # index_issues_on_status_id (status_id) | |||
| # index_issues_on_tracker_id (tracker_id) | |||
| # issues_project_id (project_id) | |||
| # | |||
| class Issue < ApplicationRecord | |||
| #issue_type 1为普通,2为悬赏 | |||
| belongs_to :project, :counter_cache => true | |||
| @@ -1,3 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: issue_depends | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # issue_id :integer | |||
| # depend_issue_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_issue_depends_on_user_id_and_issue_id_and_depend_issue_id (user_id,issue_id,depend_issue_id) | |||
| # | |||
| class IssueDepend < ApplicationRecord | |||
| belongs_to :issue | |||
| end | |||
| @@ -1,3 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: issue_priorities | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # position :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_issue_priorities_on_name (name) | |||
| # | |||
| class IssuePriority < ApplicationRecord | |||
| has_many :issues | |||
| end | |||
| end | |||
| @@ -1,4 +1,22 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: issue_statuses | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(30) default(""), not null | |||
| # is_closed :boolean default("0"), not null | |||
| # is_default :boolean default("0"), not null | |||
| # position :integer default("1") | |||
| # default_done_ratio :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_issue_statuses_on_is_closed (is_closed) | |||
| # index_issue_statuses_on_is_default (is_default) | |||
| # index_issue_statuses_on_position (position) | |||
| # | |||
| class IssueStatus < ApplicationRecord | |||
| has_many :issues | |||
| belongs_to :project, optional: true | |||
| end | |||
| end | |||
| @@ -1,3 +1,24 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: issue_tags | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # description :string(255) | |||
| # color :string(255) | |||
| # user_id :integer | |||
| # project_id :integer | |||
| # issues_count :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # gid :integer | |||
| # gitea_url :string(255) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_issue_tags_on_user_id_and_name_and_project_id (user_id,name,project_id) | |||
| # | |||
| class IssueTag < ApplicationRecord | |||
| has_many :issue_tags_relates, dependent: :destroy | |||
| @@ -1,3 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: issue_tags_relates | |||
| # | |||
| # id :integer not null, primary key | |||
| # issue_id :integer | |||
| # issue_tag_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_issue_tags_relates_on_issue_id_and_issue_tag_id (issue_id,issue_tag_id) | |||
| # | |||
| class IssueTagsRelate < ApplicationRecord | |||
| belongs_to :issue | |||
| belongs_to :issue_tag, counter_cache: :issues_count | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: issue_times | |||
| # | |||
| # id :integer not null, primary key | |||
| # issue_id :integer | |||
| # user_id :integer | |||
| # start_time :datetime | |||
| # end_time :datetime | |||
| # cost_time :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_issue_times_on_issue_id_and_user_id (issue_id,user_id) | |||
| # | |||
| class IssueTime < ApplicationRecord | |||
| belongs_to :issue | |||
| belongs_to :user | |||
| @@ -1,3 +1,26 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: journals | |||
| # | |||
| # id :integer not null, primary key | |||
| # journalized_id :integer default("0"), not null | |||
| # journalized_type :string(30) default(""), not null | |||
| # user_id :integer default("0"), not null | |||
| # notes :text(65535) | |||
| # created_on :datetime not null | |||
| # private_notes :boolean default("0"), not null | |||
| # parent_id :integer | |||
| # comments_count :integer default("0") | |||
| # reply_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_journals_on_created_on (created_on) | |||
| # index_journals_on_journalized_id (journalized_id) | |||
| # index_journals_on_user_id (user_id) | |||
| # journals_journalized_id (journalized_id,journalized_type) | |||
| # | |||
| class Journal < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :issue, foreign_key: :journalized_id, :touch => true | |||
| @@ -150,4 +173,4 @@ class Journal < ApplicationRecord | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: journal_details | |||
| # | |||
| # id :integer not null, primary key | |||
| # journal_id :integer default("0"), not null | |||
| # property :string(30) default(""), not null | |||
| # prop_key :string(30) default(""), not null | |||
| # old_value :text(65535) | |||
| # value :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # journal_details_journal_id (journal_id) | |||
| # | |||
| class JournalDetail < ApplicationRecord | |||
| belongs_to :journal | |||
| end | |||
| end | |||
| @@ -1,3 +1,32 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: journals_for_messages | |||
| # | |||
| # id :integer not null, primary key | |||
| # jour_id :integer | |||
| # jour_type :string(255) | |||
| # user_id :integer | |||
| # notes :text(65535) | |||
| # status :integer | |||
| # reply_id :integer | |||
| # created_on :datetime not null | |||
| # updated_on :datetime not null | |||
| # m_parent_id :string(255) | |||
| # is_readed :boolean | |||
| # m_reply_count :integer | |||
| # m_reply_id :integer | |||
| # is_comprehensive_evaluation :integer | |||
| # private :integer default("0") | |||
| # root_id :integer | |||
| # hidden :boolean default("0") | |||
| # praises_count :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_journals_for_messages_on_jour_id (jour_id) | |||
| # index_journals_for_messages_on_root_id (root_id) | |||
| # | |||
| class JournalsForMessage < ApplicationRecord | |||
| belongs_to :jour, :polymorphic => true | |||
| belongs_to :user | |||
| @@ -1,3 +1,22 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: laboratories | |||
| # | |||
| # id :integer not null, primary key | |||
| # school_id :integer | |||
| # identifier :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # sync_course :boolean default("0") | |||
| # sync_subject :boolean default("0") | |||
| # sync_shixun :boolean default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_laboratories_on_identifier (identifier) UNIQUE | |||
| # index_laboratories_on_school_id (school_id) | |||
| # | |||
| class Laboratory < ApplicationRecord | |||
| belongs_to :school, optional: true | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: laboratory_settings | |||
| # | |||
| # id :integer not null, primary key | |||
| # laboratory_id :integer | |||
| # config :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_laboratory_settings_on_laboratory_id (laboratory_id) | |||
| # | |||
| class LaboratorySetting < ApplicationRecord | |||
| belongs_to :laboratory | |||
| @@ -72,4 +85,4 @@ class LaboratorySetting < ApplicationRecord | |||
| footer: nil | |||
| } | |||
| end | |||
| end | |||
| end | |||
| @@ -1,4 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: laboratory_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # laboratory_id :integer | |||
| # user_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_laboratory_users_on_laboratory_id (laboratory_id) | |||
| # index_laboratory_users_on_user_id (user_id) | |||
| # | |||
| class LaboratoryUser < ApplicationRecord | |||
| belongs_to :laboratory | |||
| belongs_to :user | |||
| end | |||
| end | |||
| @@ -1,3 +1,14 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: licenses | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # content :text(65535) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class License < ApplicationRecord | |||
| include Projectable | |||
| end | |||
| @@ -1,3 +1,25 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: members | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer default("0"), not null | |||
| # project_id :integer default("0") | |||
| # created_on :datetime | |||
| # mail_notification :boolean default("0"), not null | |||
| # course_id :integer default("-1") | |||
| # course_group_id :integer default("0") | |||
| # is_collect :integer default("1") | |||
| # graduation_group_id :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_members_on_course_id (course_id) | |||
| # index_members_on_project_id (project_id) | |||
| # index_members_on_user_id (user_id) | |||
| # index_members_on_user_id_and_project_id (user_id,project_id,course_id) UNIQUE | |||
| # | |||
| class Member < ApplicationRecord | |||
| belongs_to :user | |||
| # belongs_to :course, optional: true | |||
| @@ -1,3 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: member_roles | |||
| # | |||
| # id :integer not null, primary key | |||
| # member_id :integer not null | |||
| # role_id :integer not null | |||
| # inherited_from :integer | |||
| # is_current :integer default("1") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_member_roles_on_member_id (member_id) | |||
| # index_member_roles_on_role_id (role_id) | |||
| # | |||
| class MemberRole < ApplicationRecord | |||
| belongs_to :role | |||
| belongs_to :member | |||
| @@ -1,3 +1,17 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: mirrors | |||
| # | |||
| # id :integer not null, primary key | |||
| # repo_id :integer | |||
| # status :integer default("0"), not null | |||
| # interval :integer | |||
| # next_update_time :datetime | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # sync_num :integer default("1") | |||
| # | |||
| class Mirror < ApplicationRecord | |||
| # 0 - succeeded, 1 - waiting, 2 - failed | |||
| @@ -1,3 +1,28 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: oauths | |||
| # | |||
| # id :integer not null, primary key | |||
| # client_id :string(255) | |||
| # client_secret :string(255) | |||
| # code :string(255) | |||
| # redirect_uri :string(255) | |||
| # scope :string(255) | |||
| # access_token :string(255) | |||
| # refresh_token :string(255) | |||
| # token_created_at :integer | |||
| # token_expires_in :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # user_id :integer default("0") | |||
| # gitea_oauth_id :integer | |||
| # project_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_oauths_on_user_id (user_id) | |||
| # | |||
| # for oauth2 application | |||
| class Oauth < ApplicationRecord | |||
| belongs_to :user | |||
| @@ -1,3 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: onclick_times | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # onclick_time :datetime | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_onclick_times_on_user_id (user_id) | |||
| # | |||
| class OnclickTime < ApplicationRecord | |||
| belongs_to :user | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: open_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # type :string(255) | |||
| # uid :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # extra :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_open_users_on_type_and_uid (type,uid) UNIQUE | |||
| # index_open_users_on_user_id (user_id) | |||
| # | |||
| class OpenUser < ApplicationRecord | |||
| belongs_to :user | |||
| @@ -8,4 +26,4 @@ class OpenUser < ApplicationRecord | |||
| def can_bind_cache_key | |||
| "open_user:#{type}:#{uid}:can_bind" | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: open_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # type :string(255) | |||
| # uid :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # extra :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_open_users_on_type_and_uid (type,uid) UNIQUE | |||
| # index_open_users_on_user_id (user_id) | |||
| # | |||
| class OpenUsers::Cas < OpenUser | |||
| def nickname | |||
| extra&.[]('nickname') | |||
| @@ -6,4 +24,4 @@ class OpenUsers::Cas < OpenUser | |||
| def en_type | |||
| 'cas' | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: open_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # type :string(255) | |||
| # uid :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # extra :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_open_users_on_type_and_uid (type,uid) UNIQUE | |||
| # index_open_users_on_user_id (user_id) | |||
| # | |||
| class OpenUsers::Educoder < OpenUser | |||
| def nickname | |||
| extra&.[]('nickname') | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: open_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # type :string(255) | |||
| # uid :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # extra :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_open_users_on_type_and_uid (type,uid) UNIQUE | |||
| # index_open_users_on_user_id (user_id) | |||
| # | |||
| class OpenUsers::QQ < OpenUser | |||
| def nickname | |||
| extra&.[]('nickname') | |||
| @@ -6,4 +24,4 @@ class OpenUsers::QQ < OpenUser | |||
| def en_type | |||
| 'qq' | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: open_users | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # type :string(255) | |||
| # uid :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # extra :text(65535) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_open_users_on_type_and_uid (type,uid) UNIQUE | |||
| # index_open_users_on_user_id (user_id) | |||
| # | |||
| class OpenUsers::Wechat < OpenUser | |||
| def nickname | |||
| extra&.[]('nickname') | |||
| @@ -6,4 +24,4 @@ class OpenUsers::Wechat < OpenUser | |||
| def en_type | |||
| 'wechat' | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: praise_treads | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer not null | |||
| # praise_tread_object_id :integer | |||
| # praise_tread_object_type :string(255) | |||
| # praise_or_tread :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class PraiseTread < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :praise_tread_object, polymorphic: true, counter_cache: :praises_count | |||
| @@ -1,2 +1,15 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: praise_tread_caches | |||
| # | |||
| # id :integer not null, primary key | |||
| # object_id :integer not null | |||
| # object_type :string(255) | |||
| # praise_num :integer | |||
| # tread_num :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class PraiseTreadCache < ApplicationRecord | |||
| end | |||
| @@ -1,3 +1,23 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: private_messages | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # target_id :integer | |||
| # sender_id :integer | |||
| # receiver_id :integer | |||
| # content :text(65535) | |||
| # send_time :datetime | |||
| # status :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_private_messages_on_user_id (user_id) | |||
| # | |||
| class PrivateMessage < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :target, class_name: "User" | |||
| @@ -1,3 +1,73 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: projects | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) default(""), not null | |||
| # description :text(4294967295) | |||
| # homepage :string(255) default("") | |||
| # is_public :boolean default("1"), not null | |||
| # parent_id :integer | |||
| # created_on :datetime | |||
| # updated_on :datetime | |||
| # identifier :string(255) | |||
| # status :integer default("1"), not null | |||
| # lft :integer | |||
| # rgt :integer | |||
| # inherit_members :boolean default("0"), not null | |||
| # project_type :integer default("0") | |||
| # hidden_repo :boolean default("0"), not null | |||
| # attachmenttype :integer default("1") | |||
| # user_id :integer | |||
| # dts_test :integer default("0") | |||
| # enterprise_name :string(255) | |||
| # organization_id :integer | |||
| # project_new_type :integer | |||
| # gpid :integer | |||
| # forked_from_project_id :integer | |||
| # forked_count :integer default("0") | |||
| # publish_resource :integer default("0") | |||
| # visits :integer default("0") | |||
| # hot :integer default("0") | |||
| # invite_code :string(255) | |||
| # qrcode :string(255) | |||
| # qrcode_expiretime :integer default("0") | |||
| # script :text(65535) | |||
| # training_status :integer default("0") | |||
| # rep_identifier :string(255) | |||
| # project_category_id :integer | |||
| # project_language_id :integer | |||
| # license_id :integer | |||
| # ignore_id :integer | |||
| # praises_count :integer default("0") | |||
| # watchers_count :integer default("0") | |||
| # issues_count :integer default("0") | |||
| # pull_requests_count :integer default("0") | |||
| # language :string(255) | |||
| # versions_count :integer default("0") | |||
| # issue_tags_count :integer default("0") | |||
| # closed_issues_count :integer default("0") | |||
| # open_devops :boolean default("0") | |||
| # gitea_webhook_id :integer | |||
| # open_devops_count :integer default("0") | |||
| # recommend :boolean default("0") | |||
| # platform :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_projects_on_forked_from_project_id (forked_from_project_id) | |||
| # index_projects_on_identifier (identifier) | |||
| # index_projects_on_is_public (is_public) | |||
| # index_projects_on_lft (lft) | |||
| # index_projects_on_name (name) | |||
| # index_projects_on_platform (platform) | |||
| # index_projects_on_project_type (project_type) | |||
| # index_projects_on_recommend (recommend) | |||
| # index_projects_on_rgt (rgt) | |||
| # index_projects_on_status (status) | |||
| # index_projects_on_updated_on (updated_on) | |||
| # | |||
| class Project < ApplicationRecord | |||
| include Matchable | |||
| include Publicable | |||
| @@ -208,4 +278,5 @@ class Project < ApplicationRecord | |||
| ps = ProjectStatistic.first | |||
| ps.increment!(:mirror_projects_count) unless ps.blank? | |||
| end | |||
| end | |||
| @@ -1,3 +1,20 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_categories | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # position :integer | |||
| # projects_count :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # ancestry :string(255) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_project_categories_on_ancestry (ancestry) | |||
| # | |||
| class ProjectCategory < ApplicationRecord | |||
| include Projectable | |||
| has_ancestry | |||
| @@ -1,3 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_details | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_id :integer | |||
| # content :text(4294967295) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_project_details_on_project_id (project_id) | |||
| # | |||
| class ProjectDetail < ApplicationRecord | |||
| belongs_to :project, optional: true | |||
| has_many :attachments, as: :container, dependent: :destroy | |||
| @@ -1,3 +1,23 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_educoders | |||
| # | |||
| # id :integer not null, primary key | |||
| # owner :string(255) | |||
| # repo_name :string(255) | |||
| # image_url :string(255) | |||
| # project_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # commit_count :integer default("0") | |||
| # forked_count :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_project_educoders_on_project_id (project_id) | |||
| # index_project_educoders_on_repo_name (repo_name) | |||
| # | |||
| class ProjectEducoder < ApplicationRecord | |||
| belongs_to :project, optional: true | |||
| end | |||
| @@ -1,3 +1,15 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_languages | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # position :integer | |||
| # projects_count :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class ProjectLanguage < ApplicationRecord | |||
| include Projectable | |||
| end | |||
| @@ -1,3 +1,31 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_packages | |||
| # | |||
| # id :integer not null, primary key | |||
| # creator_id :integer | |||
| # status :string(255) | |||
| # title :string(255) | |||
| # content :text(65535) | |||
| # contact_name :string(255) | |||
| # contact_phone :string(255) | |||
| # min_price :decimal(10, ) | |||
| # max_price :decimal(10, ) | |||
| # visit_count :integer default("0") | |||
| # bidding_users_count :integer default("0") | |||
| # deadline_at :datetime | |||
| # published_at :datetime | |||
| # bidding_finished_at :datetime | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # project_package_category_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_project_packages_on_creator_id (creator_id) | |||
| # index_project_packages_on_published_at (published_at) | |||
| # | |||
| class ProjectPackage < ApplicationRecord | |||
| include AASM | |||
| @@ -1,3 +1,20 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_package_applies | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_package_id :integer | |||
| # status :string(255) | |||
| # reason :string(255) | |||
| # refused_at :datetime | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_project_package_applies_on_project_package_id (project_package_id) | |||
| # | |||
| class ProjectPackageApply < ApplicationRecord | |||
| include AASM | |||
| @@ -16,4 +33,4 @@ class ProjectPackageApply < ApplicationRecord | |||
| transitions from: :pending, to: :agreed | |||
| end | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,12 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_package_categories | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(255) | |||
| # position :integer | |||
| # | |||
| class ProjectPackageCategory < ApplicationRecord | |||
| default_scope { order(position: :asc) } | |||
| @@ -20,4 +29,4 @@ class ProjectPackageCategory < ApplicationRecord | |||
| def reset_cache_data | |||
| Rails.cache.delete(self.class.data_cache_key) | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,24 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_scores | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_id :string(255) | |||
| # score :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # issue_num :integer default("0") | |||
| # issue_journal_num :integer default("0") | |||
| # news_num :integer default("0") | |||
| # documents_num :integer default("0") | |||
| # changeset_num :integer default("0") | |||
| # board_message_num :integer default("0") | |||
| # board_num :integer default("0") | |||
| # attach_num :integer default("0") | |||
| # commit_time :datetime | |||
| # pull_request_num :integer default("0") | |||
| # | |||
| class ProjectScore < ApplicationRecord | |||
| belongs_to :project | |||
| @@ -1,2 +1,15 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_statistics | |||
| # | |||
| # id :integer not null, primary key | |||
| # common_projects_count :integer default("0") | |||
| # mirror_projects_count :integer default("0") | |||
| # sync_mirror_projects_count :integer default("0") | |||
| # commits_total_count :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class ProjectStatistic < ApplicationRecord | |||
| end | |||
| @@ -1,3 +1,22 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: project_trends | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # project_id :integer | |||
| # trend_type :string(255) | |||
| # trend_id :integer | |||
| # action_type :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_project_trends_on_trend_type_and_trend_id (trend_type,trend_id) | |||
| # index_project_trends_on_user_id_and_project_id (user_id,project_id) | |||
| # | |||
| class ProjectTrend < ApplicationRecord | |||
| belongs_to :project | |||
| belongs_to :trend, polymorphic: true, optional: true | |||
| @@ -1,3 +1,28 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: pull_requests | |||
| # | |||
| # id :integer not null, primary key | |||
| # pull_request_id :integer | |||
| # gpid :integer | |||
| # user_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # status :integer default("0") | |||
| # project_id :integer | |||
| # title :string(255) | |||
| # milestone :integer | |||
| # body :text(65535) | |||
| # head :string(255) | |||
| # base :string(255) | |||
| # issue_id :integer | |||
| # fork_project_id :integer | |||
| # is_original :boolean default("0") | |||
| # comments_count :integer default("0") | |||
| # commits_count :integer default("0") | |||
| # files_count :integer default("0") | |||
| # | |||
| class PullRequest < ApplicationRecord | |||
| #status 0 默认未合并, 1表示合并, 2表示请求拒绝 | |||
| belongs_to :issue | |||
| @@ -12,4 +37,22 @@ class PullRequest < ApplicationRecord | |||
| def fork_project | |||
| Project.find_by(id: self.fork_project_id) | |||
| end | |||
| # TODO: sync educoder platform repo's for update some statistics count | |||
| def self.update_some_count | |||
| PullRequest.includes(:user, :project).select(:id, :user_id, :gpid, :project_id, :fork_project_id).each do |pr| | |||
| puts pr.id | |||
| next if pr.gpid.blank? | |||
| project = pr.project | |||
| next if project.blank? | |||
| user = project.owner | |||
| next if pr.gpid === 6 || pr.gpid === 7 | |||
| files_result = Gitea::PullRequest::FilesService.call(user.login, project.identifier, pr.gpid) | |||
| pr.update_column(:files_count, files_result['NumFiles']) unless files_result.blank? | |||
| commits_result = Gitea::PullRequest::CommitsService.call(user.login, project.identifier, pr.gpid) | |||
| pr.update_column(:commits_count, commits_result.size) unless commits_result.blank? | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: pull_request_assigns | |||
| # | |||
| # id :integer not null, primary key | |||
| # pull_request_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # user_login :string(255) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_pull_request_assigns_on_user_id_and_pull_request_id (pull_request_id) | |||
| # index_pull_request_assigns_on_user_login (user_login) | |||
| # | |||
| class PullRequestAssign < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :pull_request | |||
| @@ -1,3 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: pull_request_tags | |||
| # | |||
| # id :integer not null, primary key | |||
| # issue_tag_id :integer | |||
| # pull_request_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_pull_request_tags_on_issue_tag_id_and_pull_request_id (issue_tag_id,pull_request_id) | |||
| # | |||
| class PullRequestTag < ApplicationRecord | |||
| belongs_to :issue_tag | |||
| belongs_to :pull_request | |||
| @@ -1,3 +1,35 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: repositories | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_id :integer default("0"), not null | |||
| # url :string(255) default(""), not null | |||
| # login :string(60) default("") | |||
| # password :string(255) default("") | |||
| # root_url :string(255) default("") | |||
| # type :string(255) | |||
| # path_encoding :string(64) | |||
| # log_encoding :string(64) | |||
| # extra_info :text(65535) | |||
| # identifier :string(255) | |||
| # is_default :boolean default("0") | |||
| # hidden :boolean default("0") | |||
| # shixun_id :integer | |||
| # myshixun_id :integer | |||
| # user_id :integer | |||
| # mirror_url :string(255) | |||
| # version_releases_count :integer default("0") | |||
| # fork_url :string(255) | |||
| # is_mirror :boolean default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_repositories_on_identifier (identifier) | |||
| # index_repositories_on_project_id (project_id) | |||
| # index_repositories_on_user_id (user_id) | |||
| # | |||
| class Repository < ApplicationRecord | |||
| self.inheritance_column = nil # FIX The single-table inheritance mechanism failed | |||
| belongs_to :project, :touch => true | |||
| @@ -34,4 +66,12 @@ class Repository < ApplicationRecord | |||
| repo_mirror.set_status!(Mirror.statuses[:waiting]) | |||
| repo_mirror.increment!(:sync_num) | |||
| end | |||
| def generate_hex(column) | |||
| loop do | |||
| hex = SecureRandom.hex | |||
| break hex unless self.class.where(column => hex).any? | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: roles | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(30) default(""), not null | |||
| # position :integer default("1") | |||
| # assignable :boolean default("1") | |||
| # builtin :integer default("0"), not null | |||
| # permissions :text(65535) | |||
| # issues_visibility :string(30) default("default"), not null | |||
| # | |||
| class Role < ApplicationRecord | |||
| has_many :member_roles, dependent: :destroy | |||
| end | |||
| end | |||
| @@ -1,2 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: system_update_notices | |||
| # | |||
| # id :integer not null, primary key | |||
| # subject :string(255) | |||
| # notes :text(65535) | |||
| # start_time :datetime | |||
| # end_time :datetime | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # notice_type :integer | |||
| # | |||
| class SystemUpdateNotice < ApplicationRecord | |||
| end | |||
| @@ -1,3 +1,30 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: tidings | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # trigger_user_id :integer | |||
| # container_id :integer | |||
| # container_type :string(255) | |||
| # parent_container_id :integer | |||
| # parent_container_type :string(255) | |||
| # belong_container_id :integer | |||
| # belong_container_type :string(255) | |||
| # status :integer default("0") | |||
| # viewed :boolean | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # tiding_type :string(255) | |||
| # extra :string(255) | |||
| # is_delete :boolean default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_tidings_on_container_id (container_id) | |||
| # index_tidings_on_user_id (user_id) | |||
| # | |||
| class Tiding < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :trigger_user, class_name: 'User', optional: true | |||
| @@ -29,4 +56,4 @@ class Tiding < ApplicationRecord | |||
| (container_type == 'StudentWorksScore' && extra.to_i == 3) || | |||
| (container_type == 'StudentWorksScoresAppeal' && parent_container_type == 'StudentWork' && tiding_type == 'System') | |||
| end | |||
| end | |||
| end | |||
| @@ -1,3 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: tokens | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer default("0"), not null | |||
| # action :string(30) default(""), not null | |||
| # value :string(40) default(""), not null | |||
| # created_on :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_tokens_on_user_id (user_id) | |||
| # tokens_value (value) UNIQUE | |||
| # | |||
| # | |||
| # This program is free software; you can redistribute it and/or | |||
| # modify it under the terms of the GNU General Public License | |||
| @@ -1,4 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: trackers | |||
| # | |||
| # id :integer not null, primary key | |||
| # name :string(30) default(""), not null | |||
| # is_in_chlog :boolean default("0"), not null | |||
| # position :integer default("1") | |||
| # is_in_roadmap :boolean default("1"), not null | |||
| # fields_bits :integer default("0") | |||
| # | |||
| class Tracker < ApplicationRecord | |||
| has_many :issues | |||
| has_and_belongs_to_many :projects | |||
| end | |||
| end | |||
| @@ -1,3 +1,67 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: users | |||
| # | |||
| # id :integer not null, primary key | |||
| # login :string(255) default(""), not null | |||
| # hashed_password :string(40) default(""), not null | |||
| # firstname :string(30) default(""), not null | |||
| # lastname :string(255) default(""), not null | |||
| # mail :string(60) | |||
| # admin :boolean default("0"), not null | |||
| # status :integer default("1"), not null | |||
| # last_login_on :datetime | |||
| # language :string(5) default("") | |||
| # auth_source_id :integer | |||
| # created_on :datetime | |||
| # updated_on :datetime | |||
| # type :string(255) | |||
| # identity_url :string(255) | |||
| # mail_notification :string(255) default(""), not null | |||
| # salt :string(64) | |||
| # gid :integer | |||
| # visits :integer default("0") | |||
| # excellent_teacher :integer default("0") | |||
| # excellent_student :integer default("0") | |||
| # phone :string(255) | |||
| # authentication :boolean default("0") | |||
| # grade :integer default("0") | |||
| # experience :integer default("0") | |||
| # nickname :string(255) | |||
| # show_realname :boolean default("1") | |||
| # professional_certification :boolean default("0") | |||
| # ID_number :string(255) | |||
| # certification :integer default("0") | |||
| # homepage_teacher :boolean default("0") | |||
| # homepage_engineer :boolean default("0") | |||
| # is_test :integer default("0") | |||
| # ecoder_user_id :integer default("0") | |||
| # business :boolean default("0") | |||
| # profile_completed :boolean default("0") | |||
| # laboratory_id :integer | |||
| # platform :string(255) default("0") | |||
| # gitea_token :string(255) | |||
| # gitea_uid :integer | |||
| # is_shixun_marker :boolean default("0") | |||
| # is_sync_pwd :boolean default("1") | |||
| # watchers_count :integer default("0") | |||
| # visibility :string(255) default("public") | |||
| # repo_admin_change_team_access :boolean default("1") | |||
| # is_org :boolean default("0") | |||
| # website :string(255) | |||
| # devops_step :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_users_on_ecoder_user_id (ecoder_user_id) | |||
| # index_users_on_homepage_engineer (homepage_engineer) | |||
| # index_users_on_homepage_teacher (homepage_teacher) | |||
| # index_users_on_laboratory_id (laboratory_id) | |||
| # index_users_on_login (login) | |||
| # index_users_on_mail (mail) | |||
| # index_users_on_type (type) | |||
| # | |||
| class User < ApplicationRecord | |||
| extend Enumerize | |||
| @@ -1,2 +1,19 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: user_actions | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # action_type :string(255) | |||
| # action_id :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # ip :string(255) | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_user_actions_on_ip (ip) | |||
| # | |||
| class UserAction < ApplicationRecord | |||
| end | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: user_agents | |||
| # | |||
| # id :integer not null, primary key | |||
| # agent_type :string(255) | |||
| # key :string(255) | |||
| # ip :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # register_status :integer default("0") | |||
| # action_status :integer default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_user_agents_on_ip (ip) UNIQUE | |||
| # | |||
| class UserAgent < ApplicationRecord | |||
| has_many :user_actions, :foreign_key => "ip", :primary_key => "ip" | |||
| USER_AD = 1 # 广告宣传的引流 | |||
| @@ -1,2 +1,17 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: user_day_certifications | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # status :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_user_day_certifications_on_user_id (user_id) | |||
| # | |||
| class UserDayCertification < ApplicationRecord | |||
| end | |||
| @@ -1,3 +1,35 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: user_extensions | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer not null | |||
| # birthday :date | |||
| # brief_introduction :string(255) | |||
| # gender :integer | |||
| # location :string(255) | |||
| # occupation :string(255) | |||
| # work_experience :integer | |||
| # zip_code :integer | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # technical_title :string(255) | |||
| # identity :integer | |||
| # student_id :string(255) | |||
| # teacher_realname :string(255) | |||
| # student_realname :string(255) | |||
| # location_city :string(255) | |||
| # school_id :integer | |||
| # description :string(255) default("") | |||
| # department_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_user_extensions_on_department_id (department_id) | |||
| # index_user_extensions_on_school_id_and_user_id (school_id,user_id) | |||
| # index_user_extensions_on_user_id (user_id) | |||
| # | |||
| class UserExtension < ApplicationRecord | |||
| # identity 0: 教师教授 1: 学生, 2: 专业人士, 3: 开发者 | |||
| enum identity: { teacher: 0, student: 1, professional: 2, developer: 3, enterprise: 4, unselect: -1 } | |||
| @@ -1,3 +1,21 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: user_grades | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer not null | |||
| # project_id :integer not null | |||
| # grade :float(24) default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_user_grades_on_grade (grade) | |||
| # index_user_grades_on_project_id (project_id) | |||
| # index_user_grades_on_user_id (user_id) | |||
| # | |||
| class UserGrade < ApplicationRecord | |||
| # belongs_to :project | |||
| # belongs_to :user | |||
| @@ -1,4 +1,18 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: user_interests | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # repertoire_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_user_interests_on_repertoire_id (repertoire_id) | |||
| # index_user_interests_on_user_id (user_id) | |||
| # | |||
| class UserInterest < ApplicationRecord | |||
| belongs_to :user | |||
| # belongs_to :repertoire | |||
| end | |||
| end | |||
| @@ -1,3 +1,22 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: verification_codes | |||
| # | |||
| # id :integer not null, primary key | |||
| # code :string(255) | |||
| # code_type :integer | |||
| # status :integer | |||
| # phone :string(255) | |||
| # email :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| # Indexes | |||
| # | |||
| # by_email (email) | |||
| # by_phone (phone) | |||
| # | |||
| class VerificationCode < ApplicationRecord | |||
| def effective? | |||
| created_at + 10.minute > Time.current | |||
| @@ -1,3 +1,28 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: versions | |||
| # | |||
| # id :integer not null, primary key | |||
| # project_id :integer default("0"), not null | |||
| # name :string(255) default(""), not null | |||
| # description :text(65535) | |||
| # effective_date :date | |||
| # created_on :datetime | |||
| # updated_on :datetime | |||
| # wiki_page_title :string(255) | |||
| # status :string(255) default("open") | |||
| # sharing :string(255) default("none"), not null | |||
| # user_id :integer | |||
| # issues_count :integer default("0") | |||
| # closed_issues_count :integer default("0") | |||
| # percent :float(24) default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_versions_on_sharing (sharing) | |||
| # versions_project_id (project_id) | |||
| # | |||
| class Version < ApplicationRecord | |||
| belongs_to :project, counter_cache: true | |||
| has_many :issues, class_name: "Issue", foreign_key: "fixed_version_id" | |||
| @@ -1,3 +1,28 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: version_releases | |||
| # | |||
| # id :integer not null, primary key | |||
| # user_id :integer | |||
| # name :string(255) | |||
| # body :text(65535) | |||
| # tag_name :string(255) | |||
| # target_commitish :string(255) | |||
| # draft :boolean default("0") | |||
| # prerelease :boolean default("0") | |||
| # tarball_url :string(255) | |||
| # zipball_url :string(255) | |||
| # url :string(255) | |||
| # version_gid :string(255) | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # repository_id :integer | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_version_releases_on_repository_id (repository_id) | |||
| # | |||
| class VersionRelease < ApplicationRecord | |||
| belongs_to :repository, counter_cache: true | |||
| belongs_to :user | |||
| @@ -1,3 +1,20 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: watchers | |||
| # | |||
| # id :integer not null, primary key | |||
| # watchable_type :string(255) default(""), not null | |||
| # watchable_id :integer default("0"), not null | |||
| # user_id :integer | |||
| # created_at :datetime | |||
| # | |||
| # Indexes | |||
| # | |||
| # index_watchers_on_user_id (user_id) | |||
| # index_watchers_on_watchable_id_and_watchable_type (watchable_id,watchable_type) | |||
| # watchers_user_id_type (user_id,watchable_type) | |||
| # | |||
| class Watcher < ApplicationRecord | |||
| belongs_to :user | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: weapp_settings | |||
| # | |||
| # id :integer not null, primary key | |||
| # type :string(255) | |||
| # link :string(255) | |||
| # online :boolean default("0") | |||
| # position :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class WeappSetting < ApplicationRecord | |||
| scope :only_online, -> { where(online: true) } | |||
| end | |||
| end | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: weapp_settings | |||
| # | |||
| # id :integer not null, primary key | |||
| # type :string(255) | |||
| # link :string(255) | |||
| # online :boolean default("0") | |||
| # position :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class WeappSettings::Advert < WeappSetting | |||
| default_scope { order(position: :asc) } | |||
| end | |||
| end | |||
| @@ -1,3 +1,16 @@ | |||
| # == Schema Information | |||
| # | |||
| # Table name: weapp_settings | |||
| # | |||
| # id :integer not null, primary key | |||
| # type :string(255) | |||
| # link :string(255) | |||
| # online :boolean default("0") | |||
| # position :integer default("0") | |||
| # created_at :datetime not null | |||
| # updated_at :datetime not null | |||
| # | |||
| class WeappSettings::Carousel < WeappSetting | |||
| default_scope { order(position: :asc) } | |||
| end | |||
| end | |||
| @@ -0,0 +1,34 @@ | |||
| # NOTE: only doing this in development as some production environments (Heroku) | |||
| # NOTE: are sensitive to local FS writes, and besides -- it's just not proper | |||
| # NOTE: to have a dev-mode tool do its thing in production. | |||
| if Rails.env.development? | |||
| task :set_annotation_options do | |||
| # You can override any of these by setting an environment variable of the | |||
| # same name. | |||
| Annotate.set_defaults({ | |||
| 'position_in_routes' => "before", | |||
| 'position_in_class' => "before", | |||
| 'position_in_test' => "before", | |||
| 'position_in_fixture' => "before", | |||
| 'position_in_factory' => "before", | |||
| 'show_indexes' => "true", | |||
| 'simple_indexes' => "false", | |||
| 'model_dir' => "app/models", | |||
| 'include_version' => "false", | |||
| 'require' => "", | |||
| 'exclude_tests' => "true", | |||
| 'exclude_fixtures' => "true", | |||
| 'exclude_factories' => "false", | |||
| 'ignore_model_sub_dir' => "false", | |||
| 'skip_on_db_migrate' => "false", | |||
| 'format_bare' => "true", | |||
| 'format_rdoc' => "false", | |||
| 'format_markdown' => "false", | |||
| 'sort' => "false", | |||
| 'force' => "false", | |||
| 'trace' => "false", | |||
| }) | |||
| end | |||
| Annotate.load_tasks | |||
| end | |||