diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb index ed02a5445..8098e6e07 100644 --- a/app/models/applied_message.rb +++ b/app/models/applied_message.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index 901443e81..68095d0ea 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -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 diff --git a/app/models/apply_action.rb b/app/models/apply_action.rb index 53fc8d4ca..02a14211a 100644 --- a/app/models/apply_action.rb +++ b/app/models/apply_action.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/apply_user_authentication.rb b/app/models/apply_user_authentication.rb index ad74b0261..10522a94a 100644 --- a/app/models/apply_user_authentication.rb +++ b/app/models/apply_user_authentication.rb @@ -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 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 4057e7b97..9368d2d72 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -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 diff --git a/app/models/attachment_group_setting.rb b/app/models/attachment_group_setting.rb index b7eb707f4..3eaecf2b2 100644 --- a/app/models/attachment_group_setting.rb +++ b/app/models/attachment_group_setting.rb @@ -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 diff --git a/app/models/attachment_history.rb b/app/models/attachment_history.rb index c19146b95..86b672def 100644 --- a/app/models/attachment_history.rb +++ b/app/models/attachment_history.rb @@ -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 diff --git a/app/models/bidding_user.rb b/app/models/bidding_user.rb index 3a427a011..9609e9e60 100644 --- a/app/models/bidding_user.rb +++ b/app/models/bidding_user.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/ci/cloud_account.rb b/app/models/ci/cloud_account.rb index b10ca7118..253017dc5 100644 --- a/app/models/ci/cloud_account.rb +++ b/app/models/ci/cloud_account.rb @@ -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 diff --git a/app/models/ci/language.rb b/app/models/ci/language.rb index edbdeb0b7..3db42f35a 100644 --- a/app/models/ci/language.rb +++ b/app/models/ci/language.rb @@ -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 diff --git a/app/models/ci/user.rb b/app/models/ci/user.rb index 6f077b330..fd17adce7 100644 --- a/app/models/ci/user.rb +++ b/app/models/ci/user.rb @@ -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' diff --git a/app/models/compose.rb b/app/models/compose.rb index 0b3733943..8d9467dd8 100644 --- a/app/models/compose.rb +++ b/app/models/compose.rb @@ -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 diff --git a/app/models/compose_project.rb b/app/models/compose_project.rb index 3c2d099e1..1468fb050 100644 --- a/app/models/compose_project.rb +++ b/app/models/compose_project.rb @@ -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 diff --git a/app/models/compose_user.rb b/app/models/compose_user.rb index e3b514b3e..a4d334407 100644 --- a/app/models/compose_user.rb +++ b/app/models/compose_user.rb @@ -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 diff --git a/app/models/coo_img.rb b/app/models/coo_img.rb index 0766c0727..db96ecbd2 100644 --- a/app/models/coo_img.rb +++ b/app/models/coo_img.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/diff_record.rb b/app/models/diff_record.rb index afbb9dd9c..4b40372a7 100644 --- a/app/models/diff_record.rb +++ b/app/models/diff_record.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/diff_record_content.rb b/app/models/diff_record_content.rb index ce5e1d354..c479469e3 100644 --- a/app/models/diff_record_content.rb +++ b/app/models/diff_record_content.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/edu_setting.rb b/app/models/edu_setting.rb index 835aaec76..6968b008e 100644 --- a/app/models/edu_setting.rb +++ b/app/models/edu_setting.rb @@ -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 diff --git a/app/models/fork_user.rb b/app/models/fork_user.rb index 749f74980..d0915f152 100644 --- a/app/models/fork_user.rb +++ b/app/models/fork_user.rb @@ -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 diff --git a/app/models/ignore.rb b/app/models/ignore.rb index bd75ed08c..a6dc9a5ac 100644 --- a/app/models/ignore.rb +++ b/app/models/ignore.rb @@ -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 diff --git a/app/models/issue.rb b/app/models/issue.rb index d7dd3bbbd..934e1d314 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -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 diff --git a/app/models/issue_depend.rb b/app/models/issue_depend.rb index 14686e86d..8b64dc1f1 100644 --- a/app/models/issue_depend.rb +++ b/app/models/issue_depend.rb @@ -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 diff --git a/app/models/issue_priority.rb b/app/models/issue_priority.rb index 6b815f420..27865a70f 100644 --- a/app/models/issue_priority.rb +++ b/app/models/issue_priority.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb index 82bc62abf..a7ec34f8a 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/issue_tag.rb b/app/models/issue_tag.rb index 7b61f4016..bf2368654 100644 --- a/app/models/issue_tag.rb +++ b/app/models/issue_tag.rb @@ -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 diff --git a/app/models/issue_tags_relate.rb b/app/models/issue_tags_relate.rb index bab48d409..df9fd81ae 100644 --- a/app/models/issue_tags_relate.rb +++ b/app/models/issue_tags_relate.rb @@ -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 diff --git a/app/models/issue_time.rb b/app/models/issue_time.rb index 10d7af7b6..24425d1e0 100644 --- a/app/models/issue_time.rb +++ b/app/models/issue_time.rb @@ -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 diff --git a/app/models/journal.rb b/app/models/journal.rb index f730878df..a1834ae2a 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb index c97bdf378..f5f21260d 100644 --- a/app/models/journal_detail.rb +++ b/app/models/journal_detail.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 3d0189c91..090edcb81 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -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 diff --git a/app/models/laboratory.rb b/app/models/laboratory.rb index f53a2afee..699800c92 100644 --- a/app/models/laboratory.rb +++ b/app/models/laboratory.rb @@ -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 diff --git a/app/models/laboratory_setting.rb b/app/models/laboratory_setting.rb index 5b406f444..61c677def 100644 --- a/app/models/laboratory_setting.rb +++ b/app/models/laboratory_setting.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/laboratory_user.rb b/app/models/laboratory_user.rb index be6c0c4dd..8658e410d 100644 --- a/app/models/laboratory_user.rb +++ b/app/models/laboratory_user.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/license.rb b/app/models/license.rb index 952c4a13d..0a14fb85e 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -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 diff --git a/app/models/member.rb b/app/models/member.rb index 054a072b6..e72ae7c6b 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -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 diff --git a/app/models/member_role.rb b/app/models/member_role.rb index 6e51e7011..a2011067d 100644 --- a/app/models/member_role.rb +++ b/app/models/member_role.rb @@ -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 diff --git a/app/models/mirror.rb b/app/models/mirror.rb index a534adf96..67ef73775 100644 --- a/app/models/mirror.rb +++ b/app/models/mirror.rb @@ -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 diff --git a/app/models/oauth.rb b/app/models/oauth.rb index bf7860515..90d8b61b3 100644 --- a/app/models/oauth.rb +++ b/app/models/oauth.rb @@ -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 diff --git a/app/models/onclick_time.rb b/app/models/onclick_time.rb index 588da23f5..ac064327e 100644 --- a/app/models/onclick_time.rb +++ b/app/models/onclick_time.rb @@ -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 diff --git a/app/models/open_user.rb b/app/models/open_user.rb index 45c4ee6ba..b7d90e713 100644 --- a/app/models/open_user.rb +++ b/app/models/open_user.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/open_users/cas.rb b/app/models/open_users/cas.rb index 301a197a0..df7fb5150 100644 --- a/app/models/open_users/cas.rb +++ b/app/models/open_users/cas.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/open_users/educoder.rb b/app/models/open_users/educoder.rb index 9277b2a1d..310cf9512 100644 --- a/app/models/open_users/educoder.rb +++ b/app/models/open_users/educoder.rb @@ -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') diff --git a/app/models/open_users/qq.rb b/app/models/open_users/qq.rb index 9e7827128..ef1a4b470 100644 --- a/app/models/open_users/qq.rb +++ b/app/models/open_users/qq.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/open_users/wechat.rb b/app/models/open_users/wechat.rb index 9e7e032b4..5cb221260 100644 --- a/app/models/open_users/wechat.rb +++ b/app/models/open_users/wechat.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb index cdfdbea28..123bbbdc0 100644 --- a/app/models/praise_tread.rb +++ b/app/models/praise_tread.rb @@ -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 diff --git a/app/models/praise_tread_cache.rb b/app/models/praise_tread_cache.rb index 5544d1854..b6fe0887e 100644 --- a/app/models/praise_tread_cache.rb +++ b/app/models/praise_tread_cache.rb @@ -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 diff --git a/app/models/private_message.rb b/app/models/private_message.rb index 640e48db7..bb6d1679e 100644 --- a/app/models/private_message.rb +++ b/app/models/private_message.rb @@ -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" diff --git a/app/models/project.rb b/app/models/project.rb index b29295c22..887a6952c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/app/models/project_category.rb b/app/models/project_category.rb index ff9c0a849..3a9819816 100644 --- a/app/models/project_category.rb +++ b/app/models/project_category.rb @@ -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 diff --git a/app/models/project_detail.rb b/app/models/project_detail.rb index a2d088ba4..b7ae215c9 100644 --- a/app/models/project_detail.rb +++ b/app/models/project_detail.rb @@ -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 diff --git a/app/models/project_educoder.rb b/app/models/project_educoder.rb index dcd7a2cef..a8146af4c 100644 --- a/app/models/project_educoder.rb +++ b/app/models/project_educoder.rb @@ -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 diff --git a/app/models/project_language.rb b/app/models/project_language.rb index 386c274e8..ced6c5f9e 100644 --- a/app/models/project_language.rb +++ b/app/models/project_language.rb @@ -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 diff --git a/app/models/project_package.rb b/app/models/project_package.rb index a8e134918..e6584264f 100644 --- a/app/models/project_package.rb +++ b/app/models/project_package.rb @@ -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 diff --git a/app/models/project_package_apply.rb b/app/models/project_package_apply.rb index 0dd69c0cf..9f0c2b01a 100644 --- a/app/models/project_package_apply.rb +++ b/app/models/project_package_apply.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/project_package_category.rb b/app/models/project_package_category.rb index 403fdf4cb..9db319ddd 100644 --- a/app/models/project_package_category.rb +++ b/app/models/project_package_category.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/project_score.rb b/app/models/project_score.rb index 51ed29a67..24124265b 100644 --- a/app/models/project_score.rb +++ b/app/models/project_score.rb @@ -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 diff --git a/app/models/project_statistic.rb b/app/models/project_statistic.rb index 3dbbf36de..10eb14a46 100644 --- a/app/models/project_statistic.rb +++ b/app/models/project_statistic.rb @@ -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 diff --git a/app/models/project_trend.rb b/app/models/project_trend.rb index 28fd0ffad..5858768b9 100644 --- a/app/models/project_trend.rb +++ b/app/models/project_trend.rb @@ -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 diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index d752bb859..8a5e19272 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -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 diff --git a/app/models/pull_request_assign.rb b/app/models/pull_request_assign.rb index 0c47cc88d..c8e6489ba 100644 --- a/app/models/pull_request_assign.rb +++ b/app/models/pull_request_assign.rb @@ -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 diff --git a/app/models/pull_request_tag.rb b/app/models/pull_request_tag.rb index 589530624..7f2b6d1e2 100644 --- a/app/models/pull_request_tag.rb +++ b/app/models/pull_request_tag.rb @@ -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 diff --git a/app/models/repository.rb b/app/models/repository.rb index 4c8d81111..65b4316ed 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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 diff --git a/app/models/role.rb b/app/models/role.rb index e60606ffa..0767adecd 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/system_update_notice.rb b/app/models/system_update_notice.rb index 44589a405..de4bebfbf 100644 --- a/app/models/system_update_notice.rb +++ b/app/models/system_update_notice.rb @@ -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 diff --git a/app/models/tiding.rb b/app/models/tiding.rb index aa570f5c0..01daeb964 100644 --- a/app/models/tiding.rb +++ b/app/models/tiding.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/token.rb b/app/models/token.rb index d40388440..c71a860af 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -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 diff --git a/app/models/tracker.rb b/app/models/tracker.rb index a5202b26e..c3ceca62f 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index 93c8d3357..a8fd4ac1a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/models/user_action.rb b/app/models/user_action.rb index d3d70a66d..3ad8010ea 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -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 diff --git a/app/models/user_agent.rb b/app/models/user_agent.rb index ebe7ed03c..49d7b35a1 100644 --- a/app/models/user_agent.rb +++ b/app/models/user_agent.rb @@ -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 # 广告宣传的引流 diff --git a/app/models/user_day_certification.rb b/app/models/user_day_certification.rb index 18da0fd12..ccf26a2fe 100644 --- a/app/models/user_day_certification.rb +++ b/app/models/user_day_certification.rb @@ -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 diff --git a/app/models/user_extension.rb b/app/models/user_extension.rb index 0a3c73686..20e2b5c4f 100644 --- a/app/models/user_extension.rb +++ b/app/models/user_extension.rb @@ -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 } diff --git a/app/models/user_grade.rb b/app/models/user_grade.rb index af7490edf..970392b13 100644 --- a/app/models/user_grade.rb +++ b/app/models/user_grade.rb @@ -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 diff --git a/app/models/user_interest.rb b/app/models/user_interest.rb index 1c2d8bc84..ae5538124 100644 --- a/app/models/user_interest.rb +++ b/app/models/user_interest.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/verification_code.rb b/app/models/verification_code.rb index 452e637a7..a71d9018d 100644 --- a/app/models/verification_code.rb +++ b/app/models/verification_code.rb @@ -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 diff --git a/app/models/version.rb b/app/models/version.rb index 18996d6c7..bee22cd5c 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -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" diff --git a/app/models/version_release.rb b/app/models/version_release.rb index 7d733fb1f..16b823a78 100644 --- a/app/models/version_release.rb +++ b/app/models/version_release.rb @@ -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 diff --git a/app/models/watcher.rb b/app/models/watcher.rb index 50bd75809..76a82702b 100644 --- a/app/models/watcher.rb +++ b/app/models/watcher.rb @@ -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 diff --git a/app/models/weapp_setting.rb b/app/models/weapp_setting.rb index a4ef86eb1..ed80acd09 100644 --- a/app/models/weapp_setting.rb +++ b/app/models/weapp_setting.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/weapp_settings/advert.rb b/app/models/weapp_settings/advert.rb index 993b1fd85..209b144e3 100644 --- a/app/models/weapp_settings/advert.rb +++ b/app/models/weapp_settings/advert.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/weapp_settings/carousel.rb b/app/models/weapp_settings/carousel.rb index 71445fd3f..4f9148821 100644 --- a/app/models/weapp_settings/carousel.rb +++ b/app/models/weapp_settings/carousel.rb @@ -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 \ No newline at end of file +end diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake new file mode 100644 index 000000000..356d43fcb --- /dev/null +++ b/lib/tasks/auto_annotate_models.rake @@ -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