本地版数据清理和附件同步问题

dev_local_2
daiao 6 years ago
parent 895f56fce8
commit e70d60cade

@ -18,4 +18,7 @@
educoder 123456789
9、 需要导入的TPM版本库
在mysql中select repo_name from shixuns;
将mysql输出的结果交给运维使用脚本一建导入
将mysql输出的结果交给运维使用脚本一建导入
10、 关于实训的附件问题:
select * from attachments where container_type='Shixun' and container_id in(select distinct(c.id) from subjects s join stage_shixuns ss on ss.subject_id = s.id join shixun_mirror_repositories smr on smr.shixun_id = ss.shixun_id join mirror_repositories mr on mr.id = smr.mirror_repository_id join challenges c on c.shixun_id = ss.shixun_id where s.id in(406, 51, 388, 408, 413, 411, 412, 410, 405, 407, 414));

@ -9,13 +9,23 @@ class InitializationDataController < ApplicationController
logger.info("#########{origin_database}")
raise("请配置原始数据库") if origin_database.blank?
raise("请配置本地数据库") if database.blank?
# 获取原始数据库导入数据
# 获取原始数据库导入数据 TODO: 附件同步问题。 attachemnts表
get_origin_data origin_database, paths
# 创建初始数据
create_init_data database
normal_status("初始化数据成功!")
end
def clear_test_data
# 删除测试数据.
ActiveRecord::Base.transaction do
User.where("id > 2").destroy_all
Myshixun.where(user: 1).destroy_all
Course.where(tea_id: 1).destroy_all
normal_status("初始化数据成功!")
end
end
def get_origin_data origin_database, paths
connect_to_origin_date(origin_database)
get_subject_data(paths)

@ -36,7 +36,7 @@ class User < ApplicationRecord
has_many :myshixuns, :dependent => :destroy
has_many :study_shixuns, through: :myshixuns, source: :shixun # 已学习的实训
has_many :course_messages
has_many :courses, dependent: :destroy
has_many :courses, foreign_key: :tea_id, dependent: :destroy
#试卷
has_many :exercise_banks, :dependent => :destroy
@ -108,8 +108,8 @@ class User < ApplicationRecord
has_many :manage_courses, through: :manage_course_members, source: :course
# 关注
has_many :be_watchers, foreign_key: :user_id, dependent: :destroy # 我的关注
has_many :be_watcher_users, through: :be_watchers, dependent: :destroy # 我关注的用户
#has_many :be_watchers, foreign_key: :user_id, dependent: :destroy # 我的关注
#has_many :be_watcher_users, through: :be_watchers, dependent: :destroy # 我关注的用户
# 认证
has_many :apply_user_authentication

@ -33,7 +33,11 @@ Rails.application.routes.draw do
end
end
resources :initialization_data
resources :initialization_data do
collection do
get :clear_test_data
end
end
resources :tem_tests
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
#

Loading…
Cancel
Save