diff --git a/README.md b/README.md index 1cf3a9c97..fedd75c2a 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,38 @@ http://localhost:3000/api/accounts/remote_register | jq ``` --- +#### 获取当前登录用户信息 +``` +GET api/users/me +``` +*示例* +``` +curl -X GET http://localhost:3000/api/users/me | jq +``` + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|user_id |int |用户id | +|username |string|用户名称| +|admin |boolean|是否为管理用户| +|login |string|登录名| +|image_url |string|用户头像| + + +返回值 +``` +{ + "username": "18816895620", + "login": "18816895620", + "user_id": 36401, + "image_url": "avatars/User/b", + "admin": false +} +``` +--- + #### 获取项目类别列表(可根据名称搜素) ``` GET api/project_categories @@ -399,15 +431,15 @@ http://localhost:3000/api/18816895620/mirror_demo/entries | jq ``` --- -#### 获取子目录代码列表 +#### 获取子目录代码列表/编辑某个具体的文件 ``` -POST api/:login/:repo_identifier/sub_entries +GET api/:login/:repo_identifier/sub_entries ``` *示例* ``` curl -X GET \ --d "ref=develop" \ --d "filepath=lib/slew.rc" \ +-d "ref=master" \ +-d "filepath=test1_create_file6.rb" \ http://localhost:3000/api/18816895620/mirror_demo/sub_entries | jq ``` *请求参数说明:* @@ -416,7 +448,7 @@ http://localhost:3000/api/18816895620/mirror_demo/sub_entries | jq -|-|-|- |login |是|string |用户标识(login) | |repo_identifier |是|string |仓库标识(identifier) | -|filepath |是|string |文件夹、文件路径 | +|filepath |是|string |文件夹、文件的相对路径 | |ref |否|string |分支名称、tag名称或是提交记录id,默认为master分支 | @@ -1075,6 +1107,149 @@ http://localhost:3000/api/praise_tread/unlike | jq ``` --- +### 项目的点赞者列表 +``` +GET /api/projects/:id/praise_tread +``` +*示例* +``` +curl -X GET \ +-d 'object_id=1' \ +-d 'object_type=project' \ +http://localhost:3000/api/projects/mirror_demo/praise_tread | jq +``` +*请求参数说明:* + +|参数名|必选|类型|说明| +-|-|-|- +|object_id |是 |int |项目id | +|object_type |否 |string | 点赞类型,默认为project| + + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|status |int|0:点赞成功,-1:操作失败,2:表示已经点过赞了| + + +返回值 +``` +{ + "status": 0, + "message": "响应成功" +} +``` +--- + +### 关注(项目) +``` +POST /api/projects/:id/watchers/follow +``` +*示例* +``` +curl -X POST http://localhost:3000/api/projects/3263/watchers/follow | jq +``` +*请求参数说明:* + +|参数名|必选|类型|说明| +-|-|-|- +|id |是|int |项目id | + + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|status |int|0:点赞成功,-1:操作失败,2:表示已经点过赞了| + + +返回值 +``` +{ + "status": 0, + "message": "响应成功" +} +``` +--- + +### 取消关注 +``` +DELETE /api/projects/:id/watchers/unfollow +``` +*示例* +``` +curl -X DELETE http://localhost:3000//api/projects/3263/watchers/unfollow | jq +``` +*请求参数说明:* + +|参数名|必选|类型|说明| +-|-|-|- +|id |是|int |项目id | + + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|status |int|0:点赞成功,-1:操作失败,2:表示还未点赞| + + +返回值 +``` +{ + "status": 0, + "message": "响应成功" +} +``` +--- + +### 项目的关注者列表 +``` +GET /api/projects/:id/watchers +``` +*示例* +``` +curl -X GET \ +-d "page=1" \ +-d "limit=5" \ +http://localhost:3000//api/projects/3263/watchers | jq +``` +*请求参数说明:* + +|参数名|必选|类型|说明| +-|-|-|- +|id |是|int |项目id | +|page |否|string |页数,第几页 | +|limit |否|string |每页多少条数据,默认15条 | + + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|total_count |int|总条数| +|watchers |array|关注数据| +|-- name |string|用户名称| +|-- login |string|用户标识/登录名(login)| +|-- image_url |string|用户头像| + + +返回值 +``` +{ + "total_count": 1, + "watchers": [ + { + "name": "18816895620", + "login": "18816895620", + "image_url": "avatars/User/b" + } + ] +} +``` +--- + ### 仓库新建文件 ``` DELETE /api/:login/:repo_identifier/contents @@ -1083,8 +1258,8 @@ DELETE /api/:login/:repo_identifier/contents ``` curl -X POST \ -d 'filepath=test1_create_file1.rb' \ --d 'branch=develop' \ --d 'content=ZnNmc2FkZg==' \ +-d 'branch=master' \ +-d 'content=提交的内容' \ -d 'message=test commit ' \ http://localhost:3000/api/18816895620/mirror_demo/contents.json | jq ``` @@ -1146,14 +1321,18 @@ http://localhost:3000/api/18816895620/mirror_demo/contents.json | jq ### 更新仓库中的文件 ``` -DELETE /api/:login/:repo_identifier/contents/files/update +PUT /api/:login/:repo_identifier/contents/files/update ``` *示例* ``` -curl -X DELETE \ --d 'filepath=1' \ --d 'object_type=project' \ -http://localhost:3000/api/118816895620/mirror_demo/contents | jq +curl -X PUT \ +-d 'filepath=text1.rb' \ +-d 'branch=master' \ +-d 'content=ruby code' \ +-d 'message=更改提交信息' \ +-d 'from_path=text.rb' \ +-d "sha=57426eb21e4ceabdf4b206f022077e0040" \ +http://localhost:3000/api/18816895620/mirror_demo/contents/files/update.json | jq ``` *请求参数说明:* @@ -1161,10 +1340,12 @@ http://localhost:3000/api/118816895620/mirror_demo/contents | jq -|-|-|- |login |是|string |用户标识 | |repo_identifier|是|string |仓库标识 | -|filepath |是|string |文件相对于仓库的路径 | -|content |否|string |内容 | +|filepath |是|string |文件相对于仓库的路径(或修改后的文件路径) | +|from_path |是|string |原文件相对于仓库的路径, 只有当需要修改原文件名称时,才需要该参数 | +|sha |是|string |文件的sha标识值 | +|content |是|string |内容 | |message |否|string |提交说明 | -|branch |否|string |分支名称, branch和new_branch必须存在一个 | +|branch |否|string |分支名称, branch和new_branch必须存在一个,且只能存在一个 | |new_branch |否|string |新的分支名称 | @@ -1172,14 +1353,40 @@ http://localhost:3000/api/118816895620/mirror_demo/contents | jq |参数名|类型|说明| -|-|- -|status |int|0:点赞成功,-1:操作失败,2:表示还未点赞| +|name |string|文件名| +|sha |string|提交文件的sha值| +|size |int|文件大小, 单位:B| +|content |string|base64编码后的文件内容| +|encoding |string|编码方式| +|commit |object|| +|-- message |string|提交备注说明信息| +|-- committer|object|| +|---- name |string|用户名| +|---- email |string|用户邮箱| +|---- date |string|文件创建时间| 返回值 ``` { - "status": 0, - "message": "响应成功" + "name": "test1_create_file6.rb", + "sha": "57426eb21e4ceabdf4b206f022257e08077e0040", + "size": 16, + "content": "5o+Q5Lqk55qE5YaF5a65MQ==", + "encoding": "base64", + "commit": { + "message": "更改提交信息\n", + "author": { + "name": "18816895620", + "email": "2456233122@qq.com", + "date": "2020-01-08T07:05:15Z" + }, + "committer": { + "name": "18816895620", + "email": "2456233122@qq.com", + "date": "2020-01-08T07:05:15Z" + } + } } ``` --- @@ -1191,9 +1398,10 @@ DELETE /api/:login/:repo_identifier/contents/files/delete *示例* ``` curl -X DELETE \ --d 'filepath=1' \ --d 'object_type=project' \ -http://localhost:3000/api/118816895620/mirror_demo/contents | jq +-d 'filepath=test1_create_file12.rb' \ +-d 'test delete file' \ +-d 'sha=7b70509105b587e71f5692b9e8ab70851e321f64' \ +http://localhost:3000/api/18816895620/mirror_demo/contents/files/delete | jq ``` *请求参数说明:* @@ -1202,9 +1410,8 @@ http://localhost:3000/api/118816895620/mirror_demo/contents | jq |login |是|string |用户标识 | |repo_identifier|是|string |仓库标识 | |filepath |是|string |文件相对于仓库的路径 | -|content |否|string |内容 | |message |否|string |提交说明 | -|branch |否|string |分支名称, branch和new_branch必须存在一个 | +|branch |否|string |分支名称, 默认为master分支| |new_branch |否|string |新的分支名称 | @@ -1212,14 +1419,32 @@ http://localhost:3000/api/118816895620/mirror_demo/contents | jq |参数名|类型|说明| -|-|- -|status |int|0:点赞成功,-1:操作失败,2:表示还未点赞| +|sha |string|提交文件的sha值| +|commit |object|| +|-- message |string|提交备注说明信息| +|-- committer|object|| +|---- name |string|用户名| +|---- email |string|用户邮箱| +|---- date |string|文件创建时间| 返回值 ``` { - "status": 0, - "message": "响应成功" + "commit": { + "sha": "7b70509105b587e71f5692b9e8ab70851e321f64", + "message": "Delete 'test1_create_file11.rb'\n", + "author": { + "name": "18816895620", + "email": "2456233122@qq.com", + "date": "2020-01-08T07:57:34Z" + }, + "committer": { + "name": "18816895620", + "email": "2456233122@qq.com", + "date": "2020-01-08T07:57:34Z" + } + } } ``` --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 843be8bbb..9461e180f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -328,7 +328,7 @@ class ApplicationController < ActionController::Base def current_user # User.current - User.find_by_id 36390 + User.find_by_id 36401 end ## 默认输出json @@ -629,12 +629,17 @@ class ApplicationController < ActionController::Base def find_user @user = User.find_by_login params[:login] - render_not_found unless @user + render_not_found("未找到’#{params[:login]}’相关的用户") unless @user end def find_repository @repo = @user.repositories.find_by_identifier params[:repo_identifier] - render_not_found unless @repo + render_not_found("未找到’#{params[:repo_identifier]}’相关的项目") unless @repo + end + + def find_project + @project = Project.find_by_identifier! params[:id] + render_not_found("未找到’#{params[:id]}’相关的项目") unless @project end private diff --git a/app/controllers/contents_controller.rb b/app/controllers/contents_controller.rb index 151470524..411747f45 100644 --- a/app/controllers/contents_controller.rb +++ b/app/controllers/contents_controller.rb @@ -1,26 +1,32 @@ class ContentsController < ApplicationController before_action :find_user, :find_repository - before_action :require_login, only: %i[create] + before_action :require_login, only: %i[create update_file delete_file] def create - # request_params = {user: @user, repo_name: @repo.identifier, filepath: params[:filepath]} - logger.info "current_user ----> #{current_user.login}" - @user = current_user - interactor = Gitea::CreateFileInteractor.call(@user, content_params) + interactor = Gitea::CreateFileInteractor.call(current_user, content_params) if interactor.success? @file = interactor.result - logger.info "@file ========> #{@file}" else render_error(interactor.error) end end def update_file - + interactor = Gitea::UpdateFileInteractor.call(current_user, params) + if interactor.success? + @file = interactor.result + else + render_error(interactor.error) + end end def delete_file - + interactor = Gitea::DeleteFileInteractor.call(current_user, params) + if interactor.success? + @file = interactor.result + else + render_error(interactor.error) + end end private diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 293c9a5ff..e0f16729b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -38,10 +38,6 @@ class ProjectsController < ApplicationController end private - def find_project - @project = Project.find_by_identifier! params[:id] - end - def project_params params.permit(:user_id, :name, :description, :repository_name, :project_category_id, :project_language_id, :license_id, :ignore_id) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ef0231c3a..e690c97ab 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -15,6 +15,7 @@ class RepositoriesController < ApplicationController interactor = Repositories::EntriesInteractor.call(@user, @repo.identifier, params[:filepath], ref: params[:ref]) if interactor.success? @sub_entries = interactor.result + @sub_entries = [] << @sub_entries unless @sub_entries.is_a? Array else render_error(interactor.error) end diff --git a/app/controllers/users/watches_controller.rb b/app/controllers/users/watches_controller.rb index 867106c52..9a9e78a3e 100644 --- a/app/controllers/users/watches_controller.rb +++ b/app/controllers/users/watches_controller.rb @@ -25,4 +25,4 @@ class Users::WatchesController < Users::BaseController current_user.unwatch!(observed_user) render_ok end -end \ No newline at end of file +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f61099627..ea50d278b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,6 +2,7 @@ class UsersController < ApplicationController before_action :load_user, only: [:show, :homepage_info] before_action :check_user_exist, only: [:show, :homepage_info] + before_action :require_login, only: %i[me] def show;end @@ -14,7 +15,6 @@ class UsersController < ApplicationController def me @user = current_user - end # 贴吧获取用户信接口 diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb new file mode 100644 index 000000000..d9a8e898c --- /dev/null +++ b/app/controllers/watchers_controller.rb @@ -0,0 +1,41 @@ +class WatchersController < ApplicationController + before_action :require_login, except: %i[index] + before_action :set_project + + def index + scope = @project.watchers.includes(:user) + @watchers = paginate(scope) + end + + def unfollow + begin + return normal_status(2, "你还没有关注哦") unless current_user.watched?(@project) + current_user.unwatch!(@project) + render_ok + rescue Exception => e + uid_logger_error(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + + def follow + begin + return normal_status(2, "你已关注了") if current_user.watched?(@project) + current_user.watch!(@project) + render_ok + rescue Exception => e + uid_logger_error(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + + private + def set_project + @project = Project.find params[:project_id] + rescue Exception => e + tip_exception(e.message) + end + +end diff --git a/app/forms/contents/delete_form.rb b/app/forms/contents/delete_form.rb new file mode 100644 index 000000000..f3f060ab6 --- /dev/null +++ b/app/forms/contents/delete_form.rb @@ -0,0 +1,6 @@ +class Contents::DeleteForm < BaseForm + attr_accessor :login, :repo_identifier, :filepath, :branch, :new_branch, :sha + + validates :login, :repo_identifier, :filepath, :sha, presence: true + +end diff --git a/app/forms/contents/update_form.rb b/app/forms/contents/update_form.rb new file mode 100644 index 000000000..f5b4a2480 --- /dev/null +++ b/app/forms/contents/update_form.rb @@ -0,0 +1,13 @@ +class Contents::UpdateForm < BaseForm + attr_accessor :login, :repo_identifier, :filepath, :branch, :new_branch, :sha + + validates :login, :repo_identifier, :filepath, :sha, presence: true + + validate :check_branch + + def check_branch + raise "branch和new_branch必须存在一个 " if branch.blank? && new_branch.blank? + raise "branch和new_branch只能存在一个" if !branch.blank? && !new_branch.blank? + end + +end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb new file mode 100644 index 000000000..dcb0c0ece --- /dev/null +++ b/app/helpers/watchers_helper.rb @@ -0,0 +1,2 @@ +module WatchersHelper +end diff --git a/app/interactors/gitea/delete_file_interactor.rb b/app/interactors/gitea/delete_file_interactor.rb new file mode 100644 index 000000000..255ce6d97 --- /dev/null +++ b/app/interactors/gitea/delete_file_interactor.rb @@ -0,0 +1,65 @@ +module Gitea + class DeleteFileInteractor + def self.call(user, params={}) + interactor = new(user, params) + interactor.run + interactor + end + + attr_reader :error, :result + + def initialize(user, params) + @user = user + @params = params + end + + def success? + @error.nil? + end + + def result + @result + end + + def run + Contents::DeleteForm.new(valid_params).validate! + response = Gitea::Repository::Entries::DeleteService.new(user, @params[:repo_identifier], @params[:filepath], file_params).call + render_result(response) + rescue Exception => exception + fail!(exception.message) + end + + private + + attr_reader :params, :user + + def fail!(error) + puts "[exception]: error" + @error = error + end + + def render_result(response) + if response.status == 200 + @result = JSON.parse(response.body) + end + end + + def valid_params + { + login: @params[:login], + repo_identifier: @params[:repo_identifier], + filepath: @params[:filepath], + sha: @params[:sha] + } + end + + def file_params + Hash.new.merge( + branch: @params[:branch], + sha: @params[:sha], + new_branch: @params[:new_branch], + message: @params[:message], + ).compact + end + end +end diff --git a/app/interactors/gitea/update_file_interactor.rb b/app/interactors/gitea/update_file_interactor.rb new file mode 100644 index 000000000..814bc0cc7 --- /dev/null +++ b/app/interactors/gitea/update_file_interactor.rb @@ -0,0 +1,69 @@ +module Gitea + class UpdateFileInteractor + def self.call(user, params={}) + interactor = new(user, params) + interactor.run + interactor + end + + attr_reader :error, :result + + def initialize(user, params) + @user = user + @params = params + end + + def success? + @error.nil? + end + + def result + @result + end + + def run + Contents::UpdateForm.new(valid_params).validate! + response = Gitea::Repository::Entries::UpdateService.new(user, @params[:repo_identifier], @params[:filepath], file_params).call + render_result(response) + rescue Exception => exception + fail!(exception.message) + end + + private + + attr_reader :params, :user + + def fail!(error) + puts "[exception]: error" + @error = error + end + + def render_result(response) + if response.status == 200 + @result = JSON.parse(response.body) + end + end + + def valid_params + { + login: @params[:login], + repo_identifier: @params[:repo_identifier], + filepath: @params[:filepath], + branch: @params[:branch], + new_branch: @params[:new_branch], + sha: @params[:sha] + } + end + + def file_params + Hash.new.merge( + branch: @params[:branch], + sha: @params[:sha], + new_branch: @params[:new_branch], + from_path: @params[:from_path], + message: @params[:message], + content: Base64.encode64(@params[:content]) + ).compact + end + end +end diff --git a/app/models/concerns/watchable.rb b/app/models/concerns/watchable.rb index 7be7d1b4c..ad707a0cf 100644 --- a/app/models/concerns/watchable.rb +++ b/app/models/concerns/watchable.rb @@ -2,8 +2,8 @@ module Watchable extend ActiveSupport::Concern included do - has_many :watchers, as: :watchable, dependent: :destroy # 关注我的 - has_many :watcher_users, through: :watchers, source: :user, validate: false # 我的粉丝 + has_many :watchers, as: :watchable, dependent: :destroy + has_many :watcher_users, through: :watchers, source: :user, validate: false scope :watched_by, -> (user_id) { includes(:watchers).where(watchers: { user_id: user_id }) } end @@ -12,15 +12,15 @@ module Watchable watchable.watchers.exists?(user: self) end - def watch!(user) - user.watchers.create!(user: self) + def watch!(watchable) + watchable.watchers.create!(user: self) end - def unwatch!(user) - obj = user.watchers.find_by(user: self) + def unwatch!(watchable) + obj = watchable.watchers.find_by(user: self) obj.destroy! if obj.present? end module ClassMethods end -end \ No newline at end of file +end diff --git a/app/services/gitea/api_service.rb b/app/services/gitea/api_service.rb deleted file mode 100644 index a849ae6c5..000000000 --- a/app/services/gitea/api_service.rb +++ /dev/null @@ -1,32 +0,0 @@ -class Gitea::APIService < ApplicationService - - def self.render_status(response) - mark = " --from gitea platform." - case response.status - when 201 - JSON.parse(response&.body) - when 401 - raise Error, "401 Unauthorized from gitea #{mark}" - when 403, 422 - body = JSON.parse(response&.body) - raise Error, body['message'] + mark - else - false - end - end - - def self.base_url - Gitea.gitea_config[:base_url] - end - - def self.domain - Gitea.gitea_config[:domain] - end - - private - - def logger - Rails.logger - end - -end diff --git a/app/services/gitea/client_service.rb b/app/services/gitea/client_service.rb index c5d7f8dfd..767754bf7 100644 --- a/app/services/gitea/client_service.rb +++ b/app/services/gitea/client_service.rb @@ -61,6 +61,14 @@ class Gitea::ClientService < ApplicationService render_status(response) end + def put(url, params={}) + puts "[gitea] put request params: #{params}" + conn(authen_params(params[:token])).put do |req| + req.url full_url(url) + req.body = params[:data].to_json + end + end + private def conn(auth={}) username = auth[:username] || access_key_id diff --git a/app/services/gitea/repository/entries/delete_service.rb b/app/services/gitea/repository/entries/delete_service.rb new file mode 100644 index 000000000..cfc79a5b6 --- /dev/null +++ b/app/services/gitea/repository/entries/delete_service.rb @@ -0,0 +1,42 @@ +class Gitea::Repository::Entries::DeleteService < Gitea::ClientService + attr_reader :user, :repo_name, :filepath, :body + + # ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master) + # filepath: path of the dir, file, symlink or submodule in the repo + # repo_name: the name of repository + # body: + # { + # "author": { + # "email": "user@example.com", + # "name": "string" + # }, + # "branch": "string", + # "committer": { + # "email": "user@example.com", + # "name": "string" + # }, + # "message": "string", + # "new_branch": "string", + # "sha": "string", #require + # } + def initialize(user, repo_name, filepath, body) + @user = user + @repo_name = repo_name + @filepath = filepath + @body = body + end + + def call + delete(url, params) + end + + private + def params + Hash.new.merge(token: user.gitea_token, data: body) + end + + def url + "/repos/#{user.login}/#{repo_name}/contents/#{filepath}".freeze + end + +end diff --git a/app/services/gitea/repository/entries/update_service.rb b/app/services/gitea/repository/entries/update_service.rb new file mode 100644 index 000000000..3f0ddf944 --- /dev/null +++ b/app/services/gitea/repository/entries/update_service.rb @@ -0,0 +1,43 @@ +class Gitea::Repository::Entries::UpdateService < Gitea::ClientService + attr_reader :user, :repo_name, :filepath, :body + + # ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master) + # filepath: path of the dir, file, symlink or submodule in the repo + # repo_name: the name of repository + # body: + # { + # "author": { + # "email": "user@example.com", + # "name": "string" + # }, + # "branch": "string", + # "committer": { + # "email": "user@example.com", + # "name": "string" + # }, + # "content": "string", # content must be base64 encoded + # "message": "string", + # "new_branch": "string" + # } + # + def initialize(user, repo_name, filepath, body) + @user = user + @repo_name = repo_name + @filepath = filepath + @body = body + end + + def call + put(url, params) + end + + private + def params + Hash.new.merge(token: user.gitea_token, data: body) + end + + def url + "/repos/#{user.login}/#{repo_name}/contents/#{filepath}".freeze + end + +end diff --git a/app/views/contents/delete_file.json.jbuilder b/app/views/contents/delete_file.json.jbuilder new file mode 100644 index 000000000..988dd201c --- /dev/null +++ b/app/views/contents/delete_file.json.jbuilder @@ -0,0 +1,6 @@ +json.commit do + json.sha @file['commit']['sha'] + json.message @file['commit']['message'] + json.author @file['commit']['author'] + json.committer @file['commit']['committer'] +end diff --git a/app/views/contents/update_file.json.jbuilder b/app/views/contents/update_file.json.jbuilder new file mode 100644 index 000000000..3c842dcce --- /dev/null +++ b/app/views/contents/update_file.json.jbuilder @@ -0,0 +1,10 @@ +json.name @file['content']['name'] +json.sha @file['content']['sha'] +json.size @file['content']['size'] +json.content @file['content']['content'] +json.encoding @file['content']['encoding'] +json.commit do + json.message @file['commit']['message'] + json.author @file['commit']['author'] + json.committer @file['commit']['committer'] +end diff --git a/app/views/repositories/sub_entries.json.jbuilder b/app/views/repositories/sub_entries.json.jbuilder index bbce2df50..1f8de1eb7 100644 --- a/app/views/repositories/sub_entries.json.jbuilder +++ b/app/views/repositories/sub_entries.json.jbuilder @@ -1,7 +1,3 @@ -if @sub_entries.is_a? Array - json.array! @sub_entries do |entry| - json.partial! 'repositories/simple_entry', locals: { entry: entry } - end -else - json.partial! 'repositories/simple_entry', locals: { entry: @sub_entries } +json.array! @sub_entries do |entry| + json.partial! 'repositories/simple_entry', locals: { entry: entry } end diff --git a/app/views/users/me.json.jbuilder b/app/views/users/me.json.jbuilder new file mode 100644 index 000000000..925c32e5e --- /dev/null +++ b/app/views/users/me.json.jbuilder @@ -0,0 +1,5 @@ +json.username @user.full_name +json.login @user.login +json.user_id @user.id +json.image_url url_to_avatar(@user) +json.admin @user.admin diff --git a/app/views/watchers/_watcher.json.jbuilder b/app/views/watchers/_watcher.json.jbuilder new file mode 100644 index 000000000..52becc9e4 --- /dev/null +++ b/app/views/watchers/_watcher.json.jbuilder @@ -0,0 +1,3 @@ +json.name watcher.user.real_name +json.login watcher.user.login +json.image_url url_to_avatar(watcher.user) diff --git a/app/views/watchers/index.json.jbuilder b/app/views/watchers/index.json.jbuilder new file mode 100644 index 000000000..72f0083c4 --- /dev/null +++ b/app/views/watchers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.total_count @watchers.size +json.watchers do + json.partial! 'watcher', collection: @watchers, as: :watcher +end diff --git a/config/routes.rb b/config/routes.rb index fbaae68ac..098ebaf2c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - + require 'sidekiq/web' require 'admin_constraint' mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new @@ -9,8 +9,6 @@ Rails.application.routes.draw do get 'auth/qq/callback', to: 'oauth/qq#create' get 'auth/failure', to: 'oauth/base#auth_failure' - - resources :edu_settings scope '/api' do resources :composes do @@ -65,84 +63,25 @@ Rails.application.routes.draw do post :update_status end end + resources :watchers, only: [:index] do + collection do + post :follow + delete :unfollow + end + end + resources :praise_tread, only: [:index] collection do post :migrate get :group_type_list + post :watch end member do get :branches + post :watch end end - get '/:login/:repo_identifier', to: 'repositories#show' - resources :repositories, path: '/:login/:repo_identifier', only: [:index] do - collection do - get :entries - get :sub_entries - get :commits - get :single_commit - post :files - get :tags - end - end - - resources :contents, path: '/:login/:repo_identifier/contents', only: [:create] do - collection do - put 'files/update', :action => 'update_file' - delete 'files/delete', :action => 'delete_file' - end - end - # resources :memos do - # member do - # post :sticky_or_cancel - # post :hidden - # get :more_reply - # end - # - # collection do - # post :reply - # end - # end - - # resources :hacks, path: :problems, param: :identifier do - # collection do - # get :unpulished_list - # end - # member do - # post :publish - # get :start - # post :update_set - # delete :delete_set - # end - # resources :comments do - # post :reply - # end - # end - - # resources :hack_user_lastest_codes, path: :myproblems, param: :identifier do - # member do - # post :update_code - # get :code_debug - # get :code_submit - # match :listen_result, :via => [:get, :post] - # get :result - # get :submit_records - # post :restore_initial_code - # end - # - # collection do - # get :record_detail - # end - # - # - # end - - - # resources :tem_tests - # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html - # - # resources :accounts do collection do @@ -162,9 +101,7 @@ Rails.application.routes.draw do get :homepage_info end - resources :repositories do - end collection do @@ -204,6 +141,31 @@ Rails.application.routes.draw do end end end + + get '/:login/:repo_identifier', to: 'repositories#show' + resources :repositories, path: '/:login/:repo_identifier', only: [:index] do + collection do + get :entries + match :sub_entries, :via => [:get, :put] + get :commits + get :single_commit + post :files + get :tags + end + end + + resources :contents, path: '/:login/:repo_identifier/contents', only: [:create] do + collection do + put 'files/update', :action => 'update_file' + delete 'files/delete', :action => 'delete_file' + end + end + + + + + + resources :users_for_private_messages, only: [:index] resources :myshixuns, param: :identifier, shallow: true do @@ -419,266 +381,6 @@ Rails.application.routes.draw do end end - resources :courses do - member do - get 'settings', :action => 'settings', :as => 'settings' - post 'set_invite_code_halt' - post 'set_public_or_private' - post 'search_teacher_candidate' - post 'add_teacher' - post 'create_graduation_group' - post 'join_graduation_group' - post 'set_course_group' - post 'change_course_admin' - post 'change_member_role' - post 'change_course_teacher' - post 'delete_course_teacher' - post 'teacher_application_review' - post 'transfer_to_course_group' - post 'delete_from_course' - post 'add_students_by_search' - post 'create_group_by_importing_file' - post 'duplicate_course' - post 'visits_plus_one' - get 'get_historical_courses' - get 'get_historical_course_students' - get 'course_group_list' - get 'add_teacher_popup' - get 'teachers' - get 'apply_teachers' - get 'graduation_group_list' - get 'top_banner' - get 'left_banner' - get 'students' - get 'all_course_groups' - get 'search_users' - get 'base_info' - get 'attahcment_category_list' - get 'export_member_scores_excel' #导出课堂信息 - get 'export_couser_info' - get 'export_member_act_score' - post 'switch_to_teacher' - post 'switch_to_assistant' - post 'switch_to_student' - post 'exit_course' - get 'informs' - post 'update_informs' - post 'new_informs' - delete 'delete_informs' - get 'online_learning' - post 'join_excellent_course' - get 'tasks_list' - post 'update_task_position' - get 'course_groups' - post 'join_course_group' - get 'work_score' - get 'act_score' - get 'statistics' - post :inform_up - post :inform_down - get :calculate_all_shixun_scores - end - - collection do - post 'apply_to_join_course' - post 'search_course_list' - get 'board_list' - get 'mine' - get 'search_slim' - end - - resources :course_stages, shallow: true do - member do - post :up_position - post :down_position - end - end - - resources :polls, only:[:index,:new,:create] do - collection do - post :publish # 立即发布 - post :end_poll # 立即截止 - post :destroys # 多个删除 - post :set_public # 设置公开 - post :join_poll_banks # 加入习题集 - get :my_polls #我的问卷题库 - get :public_polls # 公共问卷题库 - get :publish_modal # 立即发布弹窗内容 - get :end_poll_modal # 立即截止弹窗内容 - end - end - - resources :homework_commons, shallow: true do - - member do - get :group_list - post :homework_code_repeat - get :code_review_results - get :code_review_detail - post :update_explanation - get :show_comment - get :settings - post :update_settings - match 'works_list', :via => [:get, :post] - # post :works_list - get :reference_answer - get :publish_groups - get :end_groups - post :alter_name - get :update_score - get :update_student_score - end - - collection do - post 'create_shixun_homework' - match 'shixuns', via: [:get, :post] - match 'subjects', via: [:get, :post] - post 'create_subject_homework' - post 'publish_homework' - post 'end_homework' - post 'set_public' - post 'move_to_category' - get 'choose_category' - post 'multi_destroy' - post 'add_to_homework_bank' - end - - resources :student_works do - member do - get :shixun_work - get :shixun_work_report - post :adjust_review_score - get :commit_des - post :update_des - post :adjust_score - post :add_score - post :add_score_reply - delete :destroy_score - delete :destroy_score_reply - get :comment_list - get :supply_attachments - post :revise_attachment - delete :destroy_score - post :appeal_anonymous_score - post :deal_appeal_score - post :cancel_appeal - get :export_shixun_work_report - post :shixun_work_comment - delete :destroy_work_comment - end - - collection do - get :search_member_list - get :check_project - get :cancel_relate_project - post :relate_project - delete :delete_work - end - end - end - - - resources :boards, shallow: true do - resources :messages do - collection do - delete :bulk_delete - put :bulk_move - post :bulk_send - put :bulk_public - end - - member do - get :reply_list - put :sticky_top - post :reply - end - end - member do - post 'move_category' - end - end - - resources :exercises ,only:[:index,:new,:create] do - collection do - get :my_exercises #我的试卷题库 - get :public_exercises # 公共试卷题库 - get :publish_modal # 立即发布弹窗内容 - get :end_modal # 立即截止弹窗内容 - post :destroys - post :set_public # 设置公开 - post :join_exercise_banks # 加入习题集 - post :publish # 立即发布 - post :end_exercise # 立即截止 - end - end - - resources :course_groups, shallow: true do - member do - post 'rename_group' - post 'move_category' - end - - collection do - end - end - - resources :graduation_topics do - member do - post :refuse_student_topic - post :accept_student_topic - post :student_select_topic - post :student_cancel_topic - get :show_detail - get :show_comment - end - collection do - delete :destroys - post :set_public - get :export - post :add_to_bank - end - end - - resources :graduation_tasks, shallow: true do - resources :graduation_works do - collection do - post 'search_member_list' - get 'check_project' - post 'relate_project' - get 'cancel_relate_project' - post 'revise_attachment' - delete 'delete_work' - end - - member do - get 'comment_list' - post 'add_score' - post 'adjust_score' - delete 'delete_score' - get 'supply_attachments' - post 'revise_attachment' - post :assign_teacher - end - end - member do - get 'settings' - post 'update_settings' - get 'tasks_list' - get :show_comment - get :cross_comment_setting - post :assign_works - post :commit_comment_setting - end - - collection do - post 'set_public' - delete 'multi_destroy' - post 'publish_task' - post 'end_task' - post 'add_to_bank' - end - end - end resources :polls,except:[:index,:new,:create] do member do diff --git a/db/migrate/20180920063955_create_graduation_topics.rb b/db/migrate/20180920063955_create_graduation_topics.rb deleted file mode 100644 index 5e7a4640e..000000000 --- a/db/migrate/20180920063955_create_graduation_topics.rb +++ /dev/null @@ -1,26 +0,0 @@ -class CreateGraduationTopics < ActiveRecord::Migration[5.2] - def change - create_table :graduation_topics do |t| - t.references :user - t.references :course - t.integer :tea_id - t.string :name - t.text :description - t.integer :status, :default => 0 - t.integer :topic_type - t.integer :source - t.integer :property - t.integer :property_two - t.string :source_unit - t.integer :repeat - t.string :province - t.string :city - t.boolean :is_public, :default => 0 - - t.timestamps - end - add_index :graduation_topics, :user_id - add_index :graduation_topics, :course_id - add_index :graduation_topics, :tea_id - end -end diff --git a/db/migrate/20181024015607_add_column_to_poll.rb b/db/migrate/20181024015607_add_column_to_poll.rb deleted file mode 100644 index 65ebe98d3..000000000 --- a/db/migrate/20181024015607_add_column_to_poll.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddColumnToPoll < ActiveRecord::Migration[5.2] - # 问卷是否实名 - def change - add_column :polls, :un_anonymous, :boolean, :default => 0 - end -end diff --git a/db/migrate/20181105031300_add_repo_name_to_shixuns.rb b/db/migrate/20181105031300_add_repo_name_to_shixuns.rb deleted file mode 100644 index 3210184ad..000000000 --- a/db/migrate/20181105031300_add_repo_name_to_shixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRepoNameToShixuns < ActiveRecord::Migration[5.2] - def change - add_column :shixuns, :repo_name, :string - end -end diff --git a/db/migrate/20181105061745_add_repo_name_to_myshixuns.rb b/db/migrate/20181105061745_add_repo_name_to_myshixuns.rb deleted file mode 100644 index 70ca92abb..000000000 --- a/db/migrate/20181105061745_add_repo_name_to_myshixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRepoNameToMyshixuns < ActiveRecord::Migration[5.2] - def change - add_column :myshixuns, :repo_name, :string - end -end diff --git a/db/migrate/20181115071148_create_relationships.rb b/db/migrate/20181115071148_create_relationships.rb deleted file mode 100644 index 4437e9ea5..000000000 --- a/db/migrate/20181115071148_create_relationships.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateRelationships < ActiveRecord::Migration[5.2] - def change - create_table :relationships do |t| - t.integer :follower_id - t.integer :followed_id - - t.timestamps - end - add_index :relationships, :followed_id - add_index :relationships, :follower_id - add_index :relationships, [:follower_id, :followed_id], unique: true - end -end diff --git a/db/migrate/20181118075620_sync_gitlab_admin.rb b/db/migrate/20181118075620_sync_gitlab_admin.rb deleted file mode 100644 index 17cb3bd18..000000000 --- a/db/migrate/20181118075620_sync_gitlab_admin.rb +++ /dev/null @@ -1,6 +0,0 @@ -class SyncGitlabAdmin < ActiveRecord::Migration[5.2] - def change - user = User.find_by_login("forge01") - user.update_column(:mail, 'admin@example.com') - end -end diff --git a/db/migrate/20181207064509_add_cloud_url_to_attachments.rb b/db/migrate/20181207064509_add_cloud_url_to_attachments.rb deleted file mode 100644 index 6dd3ffb6d..000000000 --- a/db/migrate/20181207064509_add_cloud_url_to_attachments.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCloudUrlToAttachments < ActiveRecord::Migration[5.2] - def change - add_column :attachments, :cloud_url, :string, default: '' - end -end diff --git a/db/migrate/20181213024859_add_averge_star_to_shixuns.rb b/db/migrate/20181213024859_add_averge_star_to_shixuns.rb deleted file mode 100644 index c801c8675..000000000 --- a/db/migrate/20181213024859_add_averge_star_to_shixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAvergeStarToShixuns < ActiveRecord::Migration[5.2] - def change - add_column :shixuns, :averge_star, :float, :default => 0 - end -end diff --git a/db/migrate/20181213025239_sync_averger_star_to_shixun.rb b/db/migrate/20181213025239_sync_averger_star_to_shixun.rb deleted file mode 100644 index e117475a4..000000000 --- a/db/migrate/20181213025239_sync_averger_star_to_shixun.rb +++ /dev/null @@ -1,12 +0,0 @@ -class SyncAvergerStarToShixun < ActiveRecord::Migration[5.2] - def change - Shixun.find_each do |shixun| - averge_star = Game.find_by_sql("select ifnull(sum(g.star),0)/ifnull(count(*),1) as averge_star from (games g left join - (myshixuns m join shixuns s on s.id = m.shixun_id) on m.id = g.myshixun_id) - where star != 0 and s.id = #{shixun.id}").first.try(:averge_star) - averge_star = averge_star || 5 - puts(averge_star) - shixun.update_column(:averge_star, averge_star.round(1)) - end - end -end diff --git a/db/migrate/20181228095820_create_shixun_infos.rb b/db/migrate/20181228095820_create_shixun_infos.rb deleted file mode 100644 index f5c72d5a3..000000000 --- a/db/migrate/20181228095820_create_shixun_infos.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateShixunInfos < ActiveRecord::Migration[5.2] - def change - create_table :shixun_infos do |t| - t.longtext :propaedeutics - t.longtext :description - t.longtext :evaluate_script - t.integer :shixun_id - - t.timestamps - end - end -end diff --git a/db/migrate/20181228115324_add_index_to_users.rb b/db/migrate/20181228115324_add_index_to_users.rb deleted file mode 100644 index ccd8f771f..000000000 --- a/db/migrate/20181228115324_add_index_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToUsers < ActiveRecord::Migration[5.2] - def change - add_index :users, :experience - end -end diff --git a/db/migrate/20190108074759_modify_status_and_visits_for_subjects.rb b/db/migrate/20190108074759_modify_status_and_visits_for_subjects.rb deleted file mode 100644 index 08a5d0e3a..000000000 --- a/db/migrate/20190108074759_modify_status_and_visits_for_subjects.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ModifyStatusAndVisitsForSubjects < ActiveRecord::Migration[5.2] - def change - change_column :subjects, :status, :integer, :default => 0 - change_column :subjects, :visits, :integer, :default => 1 - end -end diff --git a/db/migrate/20190109005614_add_opening_time_for_shixuns.rb b/db/migrate/20190109005614_add_opening_time_for_shixuns.rb deleted file mode 100644 index d02cd6113..000000000 --- a/db/migrate/20190109005614_add_opening_time_for_shixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddOpeningTimeForShixuns < ActiveRecord::Migration[5.2] - def change - add_column :shixuns, :opening_time, :string - end -end diff --git a/db/migrate/20190109013210_modify_opening_time_for_shixuns.rb b/db/migrate/20190109013210_modify_opening_time_for_shixuns.rb deleted file mode 100644 index b3360c424..000000000 --- a/db/migrate/20190109013210_modify_opening_time_for_shixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ModifyOpeningTimeForShixuns < ActiveRecord::Migration[5.2] - def change - change_column :shixuns, :opening_time, :datetime - end -end diff --git a/db/migrate/20190111063956_add_averge_star_default_for_shixuns.rb b/db/migrate/20190111063956_add_averge_star_default_for_shixuns.rb deleted file mode 100644 index fb0b4d3aa..000000000 --- a/db/migrate/20190111063956_add_averge_star_default_for_shixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAvergeStarDefaultForShixuns < ActiveRecord::Migration[5.2] - def change - change_column :shixuns, :averge_star, :float, :default => 5 - end -end diff --git a/db/migrate/20190120063702_sync_reponame.rb b/db/migrate/20190120063702_sync_reponame.rb deleted file mode 100644 index c40eba131..000000000 --- a/db/migrate/20190120063702_sync_reponame.rb +++ /dev/null @@ -1,16 +0,0 @@ -class SyncReponame < ActiveRecord::Migration[5.2] - def change - g = Gitlab.client - myshixuns = Myshixun.where("repo_name is null") - myshixuns.find_each do |myshixun| - begin - puts myshixun.id - repo_name = g.project(myshixun.gpid).path_with_namespace - puts repo_name - myshixun.update_column(:repo_name, repo_name) - rescue Exception => e - Rails.logger.error("e.message") - end - end - end -end diff --git a/db/migrate/20190220014052_add_shixuns_count_to_stage.rb b/db/migrate/20190220014052_add_shixuns_count_to_stage.rb deleted file mode 100644 index caf459a8e..000000000 --- a/db/migrate/20190220014052_add_shixuns_count_to_stage.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddShixunsCountToStage < ActiveRecord::Migration[5.2] - def change - add_column :stages, :shixuns_count, :integer, default: 0 - end -end diff --git a/db/migrate/20190220061013_add_shixuns_count_to_subject.rb b/db/migrate/20190220061013_add_shixuns_count_to_subject.rb deleted file mode 100644 index 3f803d2f1..000000000 --- a/db/migrate/20190220061013_add_shixuns_count_to_subject.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddShixunsCountToSubject < ActiveRecord::Migration[5.2] - def change - add_column :subjects, :shixuns_count, :integer, default: 0 - end -end diff --git a/db/migrate/20190220074947_sync_cache_count_for_subjects.rb b/db/migrate/20190220074947_sync_cache_count_for_subjects.rb deleted file mode 100644 index ce2b22d62..000000000 --- a/db/migrate/20190220074947_sync_cache_count_for_subjects.rb +++ /dev/null @@ -1,8 +0,0 @@ -class SyncCacheCountForSubjects < ActiveRecord::Migration[5.2] - def change - Subject.find_each do |s| - Subject.reset_counters s.id, :shixuns - Subject.reset_counters s.id, :stages - end - end -end diff --git a/db/migrate/20190221003048_add_users_count_to_shixun.rb b/db/migrate/20190221003048_add_users_count_to_shixun.rb deleted file mode 100644 index dffca5be9..000000000 --- a/db/migrate/20190221003048_add_users_count_to_shixun.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUsersCountToShixun < ActiveRecord::Migration[5.2] - def change - add_column :shixuns, :users_count, :integer, default: 0 - end -end diff --git a/db/migrate/20190221003137_sync_users_count_for_shixun.rb b/db/migrate/20190221003137_sync_users_count_for_shixun.rb deleted file mode 100644 index 155ddda58..000000000 --- a/db/migrate/20190221003137_sync_users_count_for_shixun.rb +++ /dev/null @@ -1,7 +0,0 @@ -class SyncUsersCountForShixun < ActiveRecord::Migration[5.2] - def change - Shixun.find_each do |s| - Shixun.reset_counters s.id, :users_count - end - end -end diff --git a/db/migrate/20190228030508_delete_none_myshixun_games.rb b/db/migrate/20190228030508_delete_none_myshixun_games.rb deleted file mode 100644 index 89130d3fa..000000000 --- a/db/migrate/20190228030508_delete_none_myshixun_games.rb +++ /dev/null @@ -1,6 +0,0 @@ -class DeleteNoneMyshixunGames < ActiveRecord::Migration[5.2] - def change - games = Game.where.not(myshixun_id: Myshixun.where(nil).pluck(:id)) - games.destroy_all - end -end diff --git a/db/migrate/20190304082236_create_challenge_answers.rb b/db/migrate/20190304082236_create_challenge_answers.rb deleted file mode 100644 index 630c92661..000000000 --- a/db/migrate/20190304082236_create_challenge_answers.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateChallengeAnswers < ActiveRecord::Migration[5.2] - def change - create_table :challenge_answers do |t| - t.string :name - t.longtext :contents - t.integer :score - t.integer :level - t.references :challenge, index: true - t.timestamps - end - - end -end diff --git a/db/migrate/20190304082811_create_course_members.rb b/db/migrate/20190304082811_create_course_members.rb deleted file mode 100644 index fd54891fd..000000000 --- a/db/migrate/20190304082811_create_course_members.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateCourseMembers < ActiveRecord::Migration[5.2] - def change - create_table :course_members do |t| - t.integer :course_id - t.integer :user_id - t.integer :course_group_id, default: 0 - t.integer :graduation_group_id, default: 0 - t.integer :role, default: 0 - t.boolean :is_active, default: 1 - - t.timestamps - end - - add_index :course_members, :course_id - add_index :course_members, :user_id - add_index :course_members, :course_group_id - add_index :course_members, :graduation_group_id - end -end diff --git a/db/migrate/20190305015556_modify_answer_open_for_games.rb b/db/migrate/20190305015556_modify_answer_open_for_games.rb deleted file mode 100644 index 7ae83ac9e..000000000 --- a/db/migrate/20190305015556_modify_answer_open_for_games.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ModifyAnswerOpenForGames < ActiveRecord::Migration[5.2] - def change - change_column :games, :answer_open, :integer, :default => 0 - end -end diff --git a/db/migrate/20190305074102_add_checkout_answer_score_for_games.rb b/db/migrate/20190305074102_add_checkout_answer_score_for_games.rb deleted file mode 100644 index 9c026fc3f..000000000 --- a/db/migrate/20190305074102_add_checkout_answer_score_for_games.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCheckoutAnswerScoreForGames < ActiveRecord::Migration[5.2] - def change - add_column :games, :answer_deduction, :integer, :default => 0 - end -end diff --git a/db/migrate/20190305080703_add_course_members_count_to_course.rb b/db/migrate/20190305080703_add_course_members_count_to_course.rb deleted file mode 100644 index d38aaca5b..000000000 --- a/db/migrate/20190305080703_add_course_members_count_to_course.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddCourseMembersCountToCourse < ActiveRecord::Migration[5.2] - def change - add_column :courses, :course_members_count, :integer, default: 0 - - Course.find_each do |c| - Course.reset_counters c.id, :course_members - end - end -end diff --git a/db/migrate/20190306023331_add_score_for_test_sets.rb b/db/migrate/20190306023331_add_score_for_test_sets.rb deleted file mode 100644 index 08b67ad85..000000000 --- a/db/migrate/20190306023331_add_score_for_test_sets.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddScoreForTestSets < ActiveRecord::Migration[5.2] - def change - add_column :test_sets, :score, :integer - add_column :challenges, :test_set_score, :boolean, :default => false - end -end diff --git a/db/migrate/20190306064421_add_answer_for_challenge_answer.rb b/db/migrate/20190306064421_add_answer_for_challenge_answer.rb deleted file mode 100644 index 32a6a6aa2..000000000 --- a/db/migrate/20190306064421_add_answer_for_challenge_answer.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddAnswerForChallengeAnswer < ActiveRecord::Migration[5.2] - def change - challenges = Challenge.where("answer is not null") - challenges.find_each do |c| - puts "####################{c.id}" - ChallengeAnswer.create(name: "解题代码", contents: "#{c.answer}", level: 1, score: 100, challenge_id: c.id) - end - - end -end diff --git a/db/migrate/20190307063217_add_pod_life_to_shixuns.rb b/db/migrate/20190307063217_add_pod_life_to_shixuns.rb deleted file mode 100644 index e596367f2..000000000 --- a/db/migrate/20190307063217_add_pod_life_to_shixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPodLifeToShixuns < ActiveRecord::Migration[5.2] - def change - add_column :shixuns, :pod_life, :integer, :default => 0 - end -end diff --git a/db/migrate/20190309085449_migrate_course_members.rb b/db/migrate/20190309085449_migrate_course_members.rb deleted file mode 100644 index a6d049dd7..000000000 --- a/db/migrate/20190309085449_migrate_course_members.rb +++ /dev/null @@ -1,38 +0,0 @@ -class MigrateCourseMembers < ActiveRecord::Migration[5.2] - def change - # add_column :course_groups, :position, :integer, default: 0 - - Course.find_each do |course| - position = 1 - course.course_groups.reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each do |group| - group.update_attribute(:position, position) - position += 1 - end - end - - - add_column :course_groups, :course_members_count, :integer, default: 0 - - CourseGroup.find_each do |g| - CourseGroup.reset_counters g.id, :course_members - end - - ActiveRecord::Base.transaction do - begin - Member.where("course_id != -1").includes(:member_roles).find_each(batch_size: 500) do |member| - puts(member.id) - member.member_roles.each do |role| - course_member_role = role.role_id == 3 ? 1 : (role.role_id == 9 ? 2 : (role.role_id == 7 ? 3 : 4)) - member_group_id = role.role_id == 10 ? member.course_group_id : 0 - CourseMember.create!(course_id: member.course_id, user_id: member.user_id, course_group_id: member_group_id, - graduation_group_id: member.graduation_group_id, role: course_member_role, is_active: role.is_current) - end - end - rescue Exception => e - uid_logger_error(e.message) - tip_exception("migrate_course_members 迁移失败!") - raise ActiveRecord::Rollback - end - end - end -end diff --git a/db/migrate/20190309091056_add_course_member_id.rb b/db/migrate/20190309091056_add_course_member_id.rb deleted file mode 100644 index 86993d725..000000000 --- a/db/migrate/20190309091056_add_course_member_id.rb +++ /dev/null @@ -1,21 +0,0 @@ -class AddCourseMemberId < ActiveRecord::Migration[5.2] - def change - add_column :student_graduation_topics, :course_member_id, :integer - add_index :student_graduation_topics, :course_member_id - - StudentGraduationTopic.find_each do |student| - course_member = CourseMember.where(course_id: student.course_id, user_id: student.user_id, - role: 4).first - student.update_column("course_member_id", course_member.try(:id)) if course_member.present? - end - - add_column :teacher_course_groups, :course_member_id, :integer - add_index :teacher_course_groups, :course_member_id - - TeacherCourseGroup.find_each do |teacher| - course_member = CourseMember.where(course_id: teacher.course_id, user_id: teacher.user_id, - role: [1, 2, 3]).first - teacher.update_column("course_member_id", course_member.try(:id)) if course_member.present? - end - end -end diff --git a/db/migrate/20190311064138_add_course_groups_count_to_course.rb b/db/migrate/20190311064138_add_course_groups_count_to_course.rb deleted file mode 100644 index ecd11e7cb..000000000 --- a/db/migrate/20190311064138_add_course_groups_count_to_course.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddCourseGroupsCountToCourse < ActiveRecord::Migration[5.2] - def change - add_column :courses, :course_groups_count, :integer, default: 0 - - Course.find_each do |c| - Course.reset_counters c.id, :course_groups - end - end -end diff --git a/db/migrate/20190311080729_add_position_to_course_groups.rb b/db/migrate/20190311080729_add_position_to_course_groups.rb deleted file mode 100644 index 4a59a7d97..000000000 --- a/db/migrate/20190311080729_add_position_to_course_groups.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPositionToCourseGroups < ActiveRecord::Migration[5.2] - def change - - end -end diff --git a/db/migrate/20190311090818_create_course_second_categories.rb b/db/migrate/20190311090818_create_course_second_categories.rb deleted file mode 100644 index 51850c2fd..000000000 --- a/db/migrate/20190311090818_create_course_second_categories.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateCourseSecondCategories < ActiveRecord::Migration[5.2] - def change - create_table :course_second_categories do |t| - t.references :course - t.string :category_type - t.string :name - t.integer :position - - t.timestamps - end - end -end diff --git a/db/migrate/20190312024018_migrate_course_second_category.rb b/db/migrate/20190312024018_migrate_course_second_category.rb deleted file mode 100644 index 382c6fd6f..000000000 --- a/db/migrate/20190312024018_migrate_course_second_category.rb +++ /dev/null @@ -1,19 +0,0 @@ -class MigrateCourseSecondCategory < ActiveRecord::Migration[5.2] - def change - add_column :homework_commons, :course_second_category_id, :integer, default: 0 - add_index :homework_commons, :course_second_category_id - add_column :course_second_categories, :course_module_id, :integer - add_index :course_second_categories, :course_module_id - - Course.find_each do |course| - homework_position = 1 - course_module = course.course_modules.where(module_type: "shixun_homework").first - course.course_homework_categories.reorder("CONVERT(name USING gbk) COLLATE gbk_chinese_ci ASC").find_each do |category| - new_category = CourseSecondCategory.create!(course_id: course.id, name: category.name, category_type: "shixun_homework", - position: homework_position, course_module_id: course_module.id) - course.homework_commons.where(course_homework_category_id: category.id).update_all(course_second_category_id: new_category.id) - homework_position += 1 - end - end - end -end diff --git a/db/migrate/20190312032623_add_course_second_category_to_attachment.rb b/db/migrate/20190312032623_add_course_second_category_to_attachment.rb deleted file mode 100644 index 972422e43..000000000 --- a/db/migrate/20190312032623_add_course_second_category_to_attachment.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCourseSecondCategoryToAttachment < ActiveRecord::Migration[5.2] - def change - add_column :attachments, :course_second_category_id, :integer, default: 0 - add_index :attachments, :course_second_category_id - end -end diff --git a/db/migrate/20190321081720_add_praises_count_to_messages.rb b/db/migrate/20190321081720_add_praises_count_to_messages.rb deleted file mode 100644 index 14f9260cb..000000000 --- a/db/migrate/20190321081720_add_praises_count_to_messages.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddPraisesCountToMessages < ActiveRecord::Migration[5.2] - def change - add_column :messages, :praises_count, :integer, :default => 0 - - Message.find_each do |msg| - total_count = msg.praise_treads.liker.count - puts "====> set message's praises_count to #{total_count}" - msg.update_column(:praises_count, total_count) - end - end -end diff --git a/db/migrate/20190321091429_change_praise_or_tread_default_in_praise_treads.rb b/db/migrate/20190321091429_change_praise_or_tread_default_in_praise_treads.rb deleted file mode 100644 index 15dd3f6e9..000000000 --- a/db/migrate/20190321091429_change_praise_or_tread_default_in_praise_treads.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangePraiseOrTreadDefaultInPraiseTreads < ActiveRecord::Migration[5.2] - def change - change_column_default :praise_treads, :praise_or_tread, from: nil, to: 1 - end -end diff --git a/db/migrate/20190322065716_create_message_details.rb b/db/migrate/20190322065716_create_message_details.rb deleted file mode 100644 index 5fd1ba7d8..000000000 --- a/db/migrate/20190322065716_create_message_details.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateMessageDetails < ActiveRecord::Migration[5.2] - def change - create_table :message_details do |t| - t.longtext :content - t.integer :message_id - - t.timestamps - end - add_index :message_details, :message_id - end -end diff --git a/db/migrate/20190322070515_move_content_of_messages_to_message_details.rb b/db/migrate/20190322070515_move_content_of_messages_to_message_details.rb deleted file mode 100644 index be747c898..000000000 --- a/db/migrate/20190322070515_move_content_of_messages_to_message_details.rb +++ /dev/null @@ -1,10 +0,0 @@ -class MoveContentOfMessagesToMessageDetails < ActiveRecord::Migration[5.2] - def change - Message.find_each do |msg| - unless msg.message_detail.present? - message_detail = MessageDetail.create(message: msg, content: msg.content) - puts "-------> create MessageDetail success: id is #{message_detail.id}" - end - end - end -end diff --git a/db/migrate/20190322091313_remove_content_from_messages.rb b/db/migrate/20190322091313_remove_content_from_messages.rb deleted file mode 100644 index ee6830e53..000000000 --- a/db/migrate/20190322091313_remove_content_from_messages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveContentFromMessages < ActiveRecord::Migration[5.2] - def change - remove_column :messages, :content, :longtext - end -end diff --git a/db/migrate/20190323005303_modify_graduation_topics.rb b/db/migrate/20190323005303_modify_graduation_topics.rb deleted file mode 100644 index 18998fdcd..000000000 --- a/db/migrate/20190323005303_modify_graduation_topics.rb +++ /dev/null @@ -1,8 +0,0 @@ -class ModifyGraduationTopics < ActiveRecord::Migration[5.2] - def change - rename_column :graduation_topics, :source, :topic_source - rename_column :graduation_topics, :property, :topic_property_first - rename_column :graduation_topics, :property_two, :topic_property_second - rename_column :graduation_topics, :repeat, :topic_repeat - end -end diff --git a/db/migrate/20190325022227_add_is_public_to_graduation_task.rb b/db/migrate/20190325022227_add_is_public_to_graduation_task.rb deleted file mode 100644 index 159aa90e9..000000000 --- a/db/migrate/20190325022227_add_is_public_to_graduation_task.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddIsPublicToGraduationTask < ActiveRecord::Migration[5.2] - def change - add_column :graduation_tasks, :is_public, :boolean, default: false - add_column :graduation_tasks, :late_time, :datetime - - GraduationTask.where(status: 3).update_all(status: 4) - end -end diff --git a/db/migrate/20190325023830_change_digest_to_string_in_attachments.rb b/db/migrate/20190325023830_change_digest_to_string_in_attachments.rb deleted file mode 100644 index 3b59e56e8..000000000 --- a/db/migrate/20190325023830_change_digest_to_string_in_attachments.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeDigestToStringInAttachments < ActiveRecord::Migration[5.2] - def change - change_column :attachments, :digest, :string, :limit => 60 - end -end diff --git a/db/migrate/20190326015900_add_hidden_for_journal_for_messages.rb b/db/migrate/20190326015900_add_hidden_for_journal_for_messages.rb deleted file mode 100644 index 2ff25360d..000000000 --- a/db/migrate/20190326015900_add_hidden_for_journal_for_messages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHiddenForJournalForMessages < ActiveRecord::Migration[5.2] - def change - add_column :journals_for_messages, :hidden, :boolean, :default => false - end -end diff --git a/db/migrate/20190326095920_add_is_hidden_to_messages.rb b/db/migrate/20190326095920_add_is_hidden_to_messages.rb deleted file mode 100644 index ee97a3f6c..000000000 --- a/db/migrate/20190326095920_add_is_hidden_to_messages.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIsHiddenToMessages < ActiveRecord::Migration[5.2] - def change - add_column :messages, :is_hidden, :boolean, :default => false - add_index :messages, :is_hidden - end -end diff --git a/db/migrate/20190327063241_course_group_count_cache.rb b/db/migrate/20190327063241_course_group_count_cache.rb deleted file mode 100644 index cf0b868ff..000000000 --- a/db/migrate/20190327063241_course_group_count_cache.rb +++ /dev/null @@ -1,5 +0,0 @@ -class CourseGroupCountCache < ActiveRecord::Migration[5.2] - def change - - end -end diff --git a/db/migrate/20190329091942_add_index_to_shixun_infos.rb b/db/migrate/20190329091942_add_index_to_shixun_infos.rb deleted file mode 100644 index c7a14dfaa..000000000 --- a/db/migrate/20190329091942_add_index_to_shixun_infos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToShixunInfos < ActiveRecord::Migration[5.2] - def change - add_index :shixun_infos, :shixun_id, unique: true - end -end diff --git a/db/migrate/20190401083919_change_quotes_to_integer_in_attachments.rb b/db/migrate/20190401083919_change_quotes_to_integer_in_attachments.rb deleted file mode 100644 index 4e25ab522..000000000 --- a/db/migrate/20190401083919_change_quotes_to_integer_in_attachments.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeQuotesToIntegerInAttachments < ActiveRecord::Migration[5.2] - def change - change_column :attachments, :quotes, :integer, :default => 0 - add_index :attachments, :quotes - end -end diff --git a/db/migrate/20190401094623_add_index_to_attachments_is_public.rb b/db/migrate/20190401094623_add_index_to_attachments_is_public.rb deleted file mode 100644 index d098253d0..000000000 --- a/db/migrate/20190401094623_add_index_to_attachments_is_public.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToAttachmentsIsPublic < ActiveRecord::Migration[5.2] - def change - add_index :attachments, :is_public - end -end diff --git a/db/migrate/20190402015918_add_invalid_to_graduation_work_score.rb b/db/migrate/20190402015918_add_invalid_to_graduation_work_score.rb deleted file mode 100644 index 5a7ea9c16..000000000 --- a/db/migrate/20190402015918_add_invalid_to_graduation_work_score.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddInvalidToGraduationWorkScore < ActiveRecord::Migration[5.2] - def change - add_column :graduation_work_scores, :is_invalid, :boolean, default: false - end -end diff --git a/db/migrate/20190402083252_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/db/migrate/20190402083252_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb deleted file mode 100644 index b4bc9a2f6..000000000 --- a/db/migrate/20190402083252_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,40 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 1) -if ActiveRecord.gem_version >= Gem::Version.new('5.0') - class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]; end -else - class ActsAsTaggableOnMigration < ActiveRecord::Migration; end -end -ActsAsTaggableOnMigration.class_eval do - def self.up - unless ActiveRecord::Base.connection.table_exists? 'tags' - create_table :tags do |t| - t.string :name - end - end - - unless ActiveRecord::Base.connection.table_exists? 'taggings' - create_table :taggings do |t| - t.references :tag - - # You should make sure that the column created is - # long enough to store the required class names. - t.references :taggable, polymorphic: true - t.references :tagger, polymorphic: true - - # Limit is created to prevent MySQL error on index - # length for MyISAM table type: http://bit.ly/vgW2Ql - t.string :context, limit: 128 - - t.datetime :created_at - end - end - - # add_index :taggings, :tag_id - # add_index :taggings, [:taggable_id, :taggable_type, :context] - end - - def self.down - drop_table :taggings - drop_table :tags - end -end diff --git a/db/migrate/20190402083253_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20190402083253_add_missing_unique_indices.acts_as_taggable_on_engine.rb deleted file mode 100644 index 7206c90e6..000000000 --- a/db/migrate/20190402083253_add_missing_unique_indices.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,26 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 2) -if ActiveRecord.gem_version >= Gem::Version.new('5.0') - class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end -else - class AddMissingUniqueIndices < ActiveRecord::Migration; end -end -AddMissingUniqueIndices.class_eval do - def self.up - # add_index :tags, :name, unique: true - - remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id) - remove_index :taggings, [:taggable_id, :taggable_type, :context] - add_index :taggings, - [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], - unique: true, name: 'taggings_idx' - end - - def self.down - remove_index :tags, :name - - remove_index :taggings, name: 'taggings_idx' - - add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id) - add_index :taggings, [:taggable_id, :taggable_type, :context] - end -end diff --git a/db/migrate/20190402083254_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20190402083254_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb deleted file mode 100644 index 5409eef63..000000000 --- a/db/migrate/20190402083254_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,20 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 3) -if ActiveRecord.gem_version >= Gem::Version.new('5.0') - class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end -else - class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end -end -AddTaggingsCounterCacheToTags.class_eval do - def self.up - add_column :tags, :taggings_count, :integer, default: 0 - - ActsAsTaggableOn::Tag.reset_column_information - ActsAsTaggableOn::Tag.find_each do |tag| - ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) - end - end - - def self.down - remove_column :tags, :taggings_count - end -end diff --git a/db/migrate/20190402083255_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/db/migrate/20190402083255_add_missing_taggable_index.acts_as_taggable_on_engine.rb deleted file mode 100644 index 097600b59..000000000 --- a/db/migrate/20190402083255_add_missing_taggable_index.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,15 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 4) -if ActiveRecord.gem_version >= Gem::Version.new('5.0') - class AddMissingTaggableIndex < ActiveRecord::Migration[4.2]; end -else - class AddMissingTaggableIndex < ActiveRecord::Migration; end -end -AddMissingTaggableIndex.class_eval do - def self.up - add_index :taggings, [:taggable_id, :taggable_type, :context] - end - - def self.down - remove_index :taggings, [:taggable_id, :taggable_type, :context] - end -end diff --git a/db/migrate/20190402083256_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20190402083256_change_collation_for_tag_names.acts_as_taggable_on_engine.rb deleted file mode 100644 index 731f66c5a..000000000 --- a/db/migrate/20190402083256_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,15 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 5) -# This migration is added to circumvent issue #623 and have special characters -# work properly -if ActiveRecord.gem_version >= Gem::Version.new('5.0') - class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end -else - class ChangeCollationForTagNames < ActiveRecord::Migration; end -end -ChangeCollationForTagNames.class_eval do - def up - if ActsAsTaggableOn::Utils.using_mysql? - execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") - end - end -end diff --git a/db/migrate/20190402083257_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb b/db/migrate/20190402083257_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb deleted file mode 100644 index 7073df2a2..000000000 --- a/db/migrate/20190402083257_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb +++ /dev/null @@ -1,23 +0,0 @@ -# This migration comes from acts_as_taggable_on_engine (originally 6) -if ActiveRecord.gem_version >= Gem::Version.new('5.0') - class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end -else - class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end -end -AddMissingIndexesOnTaggings.class_eval do - def change - add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id - add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id - add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type - add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id - add_index :taggings, :context unless index_exists? :taggings, :context - - unless index_exists? :taggings, [:tagger_id, :tagger_type] - add_index :taggings, [:tagger_id, :tagger_type] - end - - unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy' - add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy' - end - end -end diff --git a/db/migrate/20190403022053_create_gtask_banks.rb b/db/migrate/20190403022053_create_gtask_banks.rb deleted file mode 100644 index f7c7b4ffb..000000000 --- a/db/migrate/20190403022053_create_gtask_banks.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateGtaskBanks < ActiveRecord::Migration[5.2] - def change - create_table :gtask_banks do |t| - t.references :user - t.string :name - t.text :description - t.integer :task_type - t.integer :min_num, default: 0 - t.integer :max_num, default: 0 - t.integer :base_on_project, default: false - t.boolean :is_public, default: false - t.integer :quotes, default: 0 - t.references :graduation_task - t.references :course_list - - t.timestamps - end - end -end diff --git a/db/migrate/20190403025525_add_praises_count_for_jouranls_for_messages.rb b/db/migrate/20190403025525_add_praises_count_for_jouranls_for_messages.rb deleted file mode 100644 index a175d64e5..000000000 --- a/db/migrate/20190403025525_add_praises_count_for_jouranls_for_messages.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddPraisesCountForJouranlsForMessages < ActiveRecord::Migration[5.2] - def change - add_column :journals_for_messages, :praises_count, :integer, :default => 0 - - messages = JournalsForMessage.includes(:praise_treads).all - messages.find_each do |m| - puts("####{m.id}") - praises_count = m.praise_treads.liker.count - m.update_column(:praises_count, praises_count) - end - - end -end diff --git a/db/migrate/20190403065609_create_gtopic_banks.rb b/db/migrate/20190403065609_create_gtopic_banks.rb deleted file mode 100644 index a4e280252..000000000 --- a/db/migrate/20190403065609_create_gtopic_banks.rb +++ /dev/null @@ -1,23 +0,0 @@ -class CreateGtopicBanks < ActiveRecord::Migration[5.2] - def change - create_table :gtopic_banks do |t| - t.references :user - t.string :name - t.text :description - t.integer :quotes - t.boolean :is_public - t.integer :topic_type - t.integer :topic_source - t.integer :topic_property_first - t.integer :topic_property_second - t.string :source_unit - t.integer :topic_repeat - t.string :province - t.string :city - t.references :graduation_topic - t.references :course_list - - t.timestamps - end - end -end diff --git a/db/migrate/20190408060723_add_is_ordered_to_exercise_standard_answers.rb b/db/migrate/20190408060723_add_is_ordered_to_exercise_standard_answers.rb deleted file mode 100644 index 8ed2a6f8c..000000000 --- a/db/migrate/20190408060723_add_is_ordered_to_exercise_standard_answers.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIsOrderedToExerciseStandardAnswers < ActiveRecord::Migration[5.2] - def change - #试题的多空标准答案是否为一一对应,默认为一一对应,即true - add_column :exercise_standard_answers,:is_ordered,:boolean,:default => true - end -end diff --git a/db/migrate/20190410033511_change_column_in_homeworks.rb b/db/migrate/20190410033511_change_column_in_homeworks.rb deleted file mode 100644 index df8da9b43..000000000 --- a/db/migrate/20190410033511_change_column_in_homeworks.rb +++ /dev/null @@ -1,12 +0,0 @@ -class ChangeColumnInHomeworks < ActiveRecord::Migration[5.2] - def change - change_column_default :homework_commons, :late_penalty, from: nil, to: 5 - change_column_default :homework_commons, :anonymous_comment, from: 0, to: 1 - change_column_default :homework_commons, :work_efficiency, from: 1, to: 0 - change_column_default :homework_commons, :eff_score, from: 20, to: 0 - change_column_default :homework_detail_manuals, :ta_proportion, from: nil, to: 0 - change_column_default :homework_detail_manuals, :comment_status, from: nil, to: 0 - change_column_default :homework_detail_manuals, :evaluation_num, from: nil, to: 0 - change_column_default :homework_detail_manuals, :absence_penalty, from: 1, to: 0 - end -end diff --git a/db/migrate/20190410081421_change_is_ordered_from_answer_to_question.rb b/db/migrate/20190410081421_change_is_ordered_from_answer_to_question.rb deleted file mode 100644 index ae7144c4e..000000000 --- a/db/migrate/20190410081421_change_is_ordered_from_answer_to_question.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeIsOrderedFromAnswerToQuestion < ActiveRecord::Migration[5.2] - def change - remove_column :exercise_standard_answers,:is_ordered - add_column :exercise_questions,:is_ordered,:boolean,:default => true - end -end diff --git a/db/migrate/20190410081736_migrate_homework_attachments.rb b/db/migrate/20190410081736_migrate_homework_attachments.rb deleted file mode 100644 index fbdc26f6a..000000000 --- a/db/migrate/20190410081736_migrate_homework_attachments.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateHomeworkAttachments < ActiveRecord::Migration[5.2] - def change - Attachment.where(container_type: "HomeworkCommon").update_all(attachtype: 1) - end -end diff --git a/db/migrate/20190413011125_add_cloud_url_to_attachment_histories.rb b/db/migrate/20190413011125_add_cloud_url_to_attachment_histories.rb deleted file mode 100644 index a2f9db27d..000000000 --- a/db/migrate/20190413011125_add_cloud_url_to_attachment_histories.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCloudUrlToAttachmentHistories < ActiveRecord::Migration[5.2] - def change - add_column :attachment_histories, :cloud_url, :string, default: '' - end -end diff --git a/db/migrate/20190415090426_change_homework_common_columns.rb b/db/migrate/20190415090426_change_homework_common_columns.rb deleted file mode 100644 index 11360d47f..000000000 --- a/db/migrate/20190415090426_change_homework_common_columns.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ChangeHomeworkCommonColumns < ActiveRecord::Migration[5.2] - def up - change_column :homework_commons, :score_open, :boolean, default: 1 - change_column :homework_commons, :anonymous_comment, :boolean, default: 1 - change_column :homework_commons, :anonymous_appeal, :boolean, default: 0 - end - - def down - change_column :homework_commons, :score_open, :int, default: 1 - change_column :homework_commons, :anonymous_comment, :int, default: 1 - change_column :homework_commons, :anonymous_appeal, :int, default: 0 - end -end diff --git a/db/migrate/20190422032141_migrate_homework_late_time.rb b/db/migrate/20190422032141_migrate_homework_late_time.rb deleted file mode 100644 index 342986b9c..000000000 --- a/db/migrate/20190422032141_migrate_homework_late_time.rb +++ /dev/null @@ -1,21 +0,0 @@ -class MigrateHomeworkLateTime < ActiveRecord::Migration[5.2] - def change - homeworks = HomeworkCommon.where.not(end_time: nil).where(homework_type: [1, 3 ,4], allow_late: 1, late_time: nil) - homeworks.each do |homework| - if homework.course.try(:end_date).present? - homework.update_column("late_time", homework.course.end_date) - elsif homework.end_time.present? - homework.update_column("late_time", Time.at(homework.end_time.to_i + 30*24*3600)) - end - end - - tasks = GraduationTask.where.not(end_time: nil).where(allow_late: 1, late_time: nil) - tasks.each do |task| - if task.course.try(:end_date).present? - task.update_column("late_time", task.course.end_date) - elsif task.end_time.present? - task.update_column("late_time", Time.at(task.end_time.to_i + 30*24*3600)) - end - end - end -end diff --git a/db/migrate/20190422083020_add_journals_for_messages_count_for_hm_and_gt_and_gw.rb b/db/migrate/20190422083020_add_journals_for_messages_count_for_hm_and_gt_and_gw.rb deleted file mode 100644 index 37162c850..000000000 --- a/db/migrate/20190422083020_add_journals_for_messages_count_for_hm_and_gt_and_gw.rb +++ /dev/null @@ -1,18 +0,0 @@ -class AddJournalsForMessagesCountForHmAndGtAndGw < ActiveRecord::Migration[5.2] - def change - #add_column :homework_commons, :journals_for_messages_count, :integer, :default => 0 - #add_column :graduation_tasks, :journals_for_messages_count, :integer, :default => 0 - #add_column :graduation_topics, :journals_for_messages_count, :integer, :default => 0 - - type = ["GraduationTopic", "GraduationTask", "HomeworkCommon"] - messages = JournalsForMessage.where(jour_type: type).where("m_parent_id is not null") - # 迁移所有2级以上的回复 - messages.each do |message| - while message.parent.try(:m_parent_id).present? do - puts "parent: #{message.parent.try(:m_parent_id)}" - message.update_attribute(:m_parent_id, message.parent.m_parent_id) - end - end - - end -end diff --git a/db/migrate/20190424014128_migrate_homework_anonymous_comment.rb b/db/migrate/20190424014128_migrate_homework_anonymous_comment.rb deleted file mode 100644 index 21c20fcce..000000000 --- a/db/migrate/20190424014128_migrate_homework_anonymous_comment.rb +++ /dev/null @@ -1,7 +0,0 @@ -class MigrateHomeworkAnonymousComment < ActiveRecord::Migration[5.2] - def change - change_column_default :homework_commons, :anonymous_comment, from: 1, to: 0 - - HomeworkCommon.update_all("anonymous_comment = !anonymous_comment") - end -end diff --git a/db/migrate/20190426010412_add_is_invalid_to_student_works_scores.rb b/db/migrate/20190426010412_add_is_invalid_to_student_works_scores.rb deleted file mode 100644 index 2d782f924..000000000 --- a/db/migrate/20190426010412_add_is_invalid_to_student_works_scores.rb +++ /dev/null @@ -1,25 +0,0 @@ -class AddIsInvalidToStudentWorksScores < ActiveRecord::Migration[5.2] - def change - add_column :student_works_scores, :is_invalid, :boolean, default: false - - StudentWorksScore.where("score is not null").order("id desc").find_each do |score| - unless score.is_invalid - if score.student_work.present? - puts score.id - work = score.student_work - - # 如果分数是调整分 则之前的所有分都无效 - if score.is_ultimate - work.student_works_scores.where("score is not null and id < #{score.id}").update_all(is_invalid: 1) - - # 如果是同一个用户角色的重复评分,则之前的评分都无效 - elsif work.student_works_scores.where("user_id = #{score.user_id} and reviewer_role = #{score.reviewer_role} - and score is not null and id < #{score.id}").count > 0 - work.student_works_scores.where("user_id = #{score.user_id} and reviewer_role = #{score.reviewer_role} - and score is not null and id < #{score.id}").update_all(is_invalid: 1) - end - end - end - end - end -end diff --git a/db/migrate/20190427010940_change_exercise_score_to_float.rb b/db/migrate/20190427010940_change_exercise_score_to_float.rb deleted file mode 100644 index e8c57bc1e..000000000 --- a/db/migrate/20190427010940_change_exercise_score_to_float.rb +++ /dev/null @@ -1,29 +0,0 @@ -class ChangeExerciseScoreToFloat < ActiveRecord::Migration[5.2] - def up - change_column :exercise_users,:score,:decimal,precision: 10, scale: 1 - change_column :exercise_users, :objective_score, :decimal,precision: 10, scale: 1,default: 0.0 - # change_column :exercise_users, :subjective_score, :decimal,precision: 10, scale: 1,default: 0.0 - change_column :exercise_users, :subjective_score, :decimal,precision: 10, scale: 1,default: -1.0 - # change_column :exercise_answers,:score,:decimal,precision: 10, scale: 1,default: 0.0 - change_column :exercise_answers,:score,:decimal,precision: 10, scale: 1,default: -1.0 #6.10修改,方便判断主观题是否批阅 - change_column :exercise_bank_questions,:question_score,:decimal,precision: 10, scale: 1 - change_column :exercise_bank_shixun_challenges,:question_score,:decimal,precision: 10, scale: 1 - change_column :exercise_questions,:question_score,:decimal,precision: 10, scale: 1 - change_column :exercise_shixun_answers,:score,:decimal,precision: 10, scale: 1 - change_column :exercise_shixun_challenges,:question_score,:decimal,precision: 10, scale: 1 - change_column :exercise_answer_comments, :score,:decimal,precision: 10, scale: 1 - end - - def down - change_column :exercise_users,:score,:integer - change_column :exercise_users, :objective_score, :integer,default: -1 - change_column :exercise_users, :subjective_score, :integer,default: -1 - change_column :exercise_answers,:score,:integer,default: -1 - change_column :exercise_bank_questions,:question_score,:integer - change_column :exercise_shixun_answers,:score,:integer - change_column :exercise_bank_shixun_challenges,:question_score,:integer - change_column :exercise_questions,:question_score,:integer - change_column :exercise_shixun_challenges,:question_score,:integer - change_column :exercise_answer_comments, :score,:integer - end -end diff --git a/db/migrate/20190427045904_update_exercise_default_value.rb b/db/migrate/20190427045904_update_exercise_default_value.rb deleted file mode 100644 index 05d76ee44..000000000 --- a/db/migrate/20190427045904_update_exercise_default_value.rb +++ /dev/null @@ -1,7 +0,0 @@ -class UpdateExerciseDefaultValue < ActiveRecord::Migration[5.2] - def change - ExerciseUser.where(objective_score: -1.0).update_all(objective_score: 0.0) - # ExerciseUser.where(subjective_score: -1.0).update_all(subjective_score: 0.0) #主观题默认分数为-1,不需修改 - # ExerciseAnswer.where(score: -1.0).update_all(score: 0.0) #6.10 修改,方便判断主观题是否 - end -end diff --git a/db/migrate/20190429012219_change_digest_to_string_in_attachment_histories.rb b/db/migrate/20190429012219_change_digest_to_string_in_attachment_histories.rb deleted file mode 100644 index d7c7e5b14..000000000 --- a/db/migrate/20190429012219_change_digest_to_string_in_attachment_histories.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeDigestToStringInAttachmentHistories < ActiveRecord::Migration[5.2] - def change - change_column :attachment_histories, :digest, :string, :limit => 60 - end -end diff --git a/db/migrate/20190429015510_add_default_for_exercises.rb b/db/migrate/20190429015510_add_default_for_exercises.rb deleted file mode 100644 index 3ebbf6e2f..000000000 --- a/db/migrate/20190429015510_add_default_for_exercises.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddDefaultForExercises < ActiveRecord::Migration[5.2] - def change - change_column :exercises, :exercise_status, :integer, :default => 1 - change_column :exercises, :show_result, :integer, :default => 1 - change_column :exercises, :time, :integer, :default => -1 - end -end diff --git a/db/migrate/20190429080104_add_quotes_for_graduation_topics.rb b/db/migrate/20190429080104_add_quotes_for_graduation_topics.rb deleted file mode 100644 index 57694008e..000000000 --- a/db/migrate/20190429080104_add_quotes_for_graduation_topics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddQuotesForGraduationTopics < ActiveRecord::Migration[5.2] - def change - add_column :graduation_topics, :quotes, :integer, :default => 0 - end -end diff --git a/db/migrate/20190430090659_add_default_for_polls.rb b/db/migrate/20190430090659_add_default_for_polls.rb deleted file mode 100644 index 2fcb260ab..000000000 --- a/db/migrate/20190430090659_add_default_for_polls.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDefaultForPolls < ActiveRecord::Migration[5.2] - def change - change_column :polls, :polls_status, :integer, :default => 1 - end -end diff --git a/db/migrate/20190505031946_sync_users_index.rb b/db/migrate/20190505031946_sync_users_index.rb deleted file mode 100644 index a1f9b40fb..000000000 --- a/db/migrate/20190505031946_sync_users_index.rb +++ /dev/null @@ -1,8 +0,0 @@ -class SyncUsersIndex < ActiveRecord::Migration[5.2] - def change - remove_index :users, name: :index_users_on_phone_and_mail - remove_index :users, name: :index_users_on_id_and_type - remove_index :users, name: :index_users_on_auth_source_id - remove_index :users, name: :index_users_on_type - end -end diff --git a/db/migrate/20190505072404_remove_index_from_users.rb b/db/migrate/20190505072404_remove_index_from_users.rb deleted file mode 100644 index b19219346..000000000 --- a/db/migrate/20190505072404_remove_index_from_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveIndexFromUsers < ActiveRecord::Migration[5.2] - def change - remove_index :users, name: :index_users_on_experience - end -end diff --git a/db/migrate/20190505093440_init_use_index.rb b/db/migrate/20190505093440_init_use_index.rb deleted file mode 100644 index b7c3101dd..000000000 --- a/db/migrate/20190505093440_init_use_index.rb +++ /dev/null @@ -1,9 +0,0 @@ -class InitUseIndex < ActiveRecord::Migration[5.2] - def change - remove_index :users, name: :index_users_on_login if index_exists?(:users, :login, name: :index_users_on_login) - remove_index :users, name: :index_users_on_mail if index_exists?(:users, :mail, name: :index_users_on_mail) - # add_index :users, :login, unique: true - # add_index :users, :mail, unique: true - # add_index :users, :phone, unique: true - end -end diff --git a/db/migrate/20190505095131_add_authentication_and_professional_certification_to_courses.rb b/db/migrate/20190505095131_add_authentication_and_professional_certification_to_courses.rb deleted file mode 100644 index 2cc1ba940..000000000 --- a/db/migrate/20190505095131_add_authentication_and_professional_certification_to_courses.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddAuthenticationAndProfessionalCertificationToCourses < ActiveRecord::Migration[5.2] - def change - add_column :courses, :authentication, :boolean, default: false - add_column :courses, :professional_certification, :boolean, default: false - end -end diff --git a/db/migrate/20190508090916_migrate_new_student_work_status.rb b/db/migrate/20190508090916_migrate_new_student_work_status.rb deleted file mode 100644 index d2e9bb379..000000000 --- a/db/migrate/20190508090916_migrate_new_student_work_status.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MigrateNewStudentWorkStatus < ActiveRecord::Migration[5.2] - def change - homeworks = HomeworkCommon.where(allow_late: 0) - StudentWork.where(homework_common_id: homeworks, work_status: 2).update_all(work_status: 1) - end -end diff --git a/db/migrate/20190511020736_add_is_public_to_messages.rb b/db/migrate/20190511020736_add_is_public_to_messages.rb deleted file mode 100644 index bbbba8f50..000000000 --- a/db/migrate/20190511020736_add_is_public_to_messages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIsPublicToMessages < ActiveRecord::Migration[5.2] - def change - add_column :messages, :is_public, :boolean, :default => false - end -end diff --git a/db/migrate/20190514023907_add_column_to_zip_packs.rb b/db/migrate/20190514023907_add_column_to_zip_packs.rb deleted file mode 100644 index 8ba250f37..000000000 --- a/db/migrate/20190514023907_add_column_to_zip_packs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddColumnToZipPacks < ActiveRecord::Migration[5.2] - def change - add_column :zip_packs, :container_id, :integer, default: 0 - add_column :zip_packs, :container_type, :string - - add_index :zip_packs, [:container_id, :container_type] - - ZipPack.all.update_all("container_type='HomeworkCommon', container_id = homework_id") - end -end diff --git a/db/migrate/20190514083047_change_question_random_exercises.rb b/db/migrate/20190514083047_change_question_random_exercises.rb deleted file mode 100644 index 313d648bb..000000000 --- a/db/migrate/20190514083047_change_question_random_exercises.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ChangeQuestionRandomExercises < ActiveRecord::Migration[5.2] - def up - change_column :exercises,:question_random,:boolean,default: false - change_column :exercises,:choice_random,:boolean,default: false - - end - def down - change_column :exercises,:question_random,:integer,default: 0 - change_column :exercises,:choice_random,:integer,default: 0 - end -end diff --git a/db/migrate/20190515014734_change_poll_show_result_boolean.rb b/db/migrate/20190515014734_change_poll_show_result_boolean.rb deleted file mode 100644 index f74dd02c4..000000000 --- a/db/migrate/20190515014734_change_poll_show_result_boolean.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ChangePollShowResultBoolean < ActiveRecord::Migration[5.2] - def change - def up - change_column :polls,:show_result,:boolean,default: true - end - def down - change_column :polls,:show_result,:integer,default: 1 - end - end -end diff --git a/db/migrate/20190517080313_add_test_set_average_for_challenges.rb b/db/migrate/20190517080313_add_test_set_average_for_challenges.rb deleted file mode 100644 index cac1d80bc..000000000 --- a/db/migrate/20190517080313_add_test_set_average_for_challenges.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTestSetAverageForChallenges < ActiveRecord::Migration[5.2] - def change - add_column :challenges, :test_set_average, :boolean, :default => true - end -end diff --git a/db/migrate/20190517085407_create_edu_settings.rb b/db/migrate/20190517085407_create_edu_settings.rb deleted file mode 100644 index e6c081233..000000000 --- a/db/migrate/20190517085407_create_edu_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateEduSettings < ActiveRecord::Migration[5.2] - def change - create_table :edu_settings do |t| - t.string :name - t.string :value - - t.timestamps - end - end -end diff --git a/db/migrate/20190517092730_add_description_to_edu_settings.rb b/db/migrate/20190517092730_add_description_to_edu_settings.rb deleted file mode 100644 index ad273b805..000000000 --- a/db/migrate/20190517092730_add_description_to_edu_settings.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddDescriptionToEduSettings < ActiveRecord::Migration[5.2] - def change - add_column :edu_settings, :description, :string - add_index :edu_settings, :name, unique: :true - - ['tomcat_webssh', 'webssh_username', 'webssh_password', 'git_address_ip', 'git_address_domain', 'git_username', - 'git_password', 'public_key', 'private_key', 'public_bucket', 'public_bucket_host', 'public_cdn_host', 'cloud_bridge', - 'cloud_tomcat_php', 'host_name', 'old_edu_host'].each do |name| - if EduSetting.find_by_name(name).nil? - EduSetting.create(name: name) - end - end - end -end diff --git a/db/migrate/20190518085626_add_index_to_verificatiojn_codes.rb b/db/migrate/20190518085626_add_index_to_verificatiojn_codes.rb deleted file mode 100644 index e4bdaac19..000000000 --- a/db/migrate/20190518085626_add_index_to_verificatiojn_codes.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexToVerificatiojnCodes < ActiveRecord::Migration[5.2] - def change - add_index :verification_codes, [:phone], name: 'by_phone' if !index_exists?(:verification_codes, :phone) - add_index :verification_codes, [:email], name: 'by_email' if !index_exists?(:verification_codes, :email) - end -end diff --git a/db/migrate/20190522091226_alter_educoder_indexs.rb b/db/migrate/20190522091226_alter_educoder_indexs.rb deleted file mode 100644 index 6e1ed9bb5..000000000 --- a/db/migrate/20190522091226_alter_educoder_indexs.rb +++ /dev/null @@ -1,70 +0,0 @@ -class AlterEducoderIndexs < ActiveRecord::Migration[5.2] - def change - - add_index :onclick_times, :user_id if !index_exists?(:onclick_times, :user_id) - remove_index :courses, :syllabus_id - add_index :courses, :tea_id - add_index :course_modules, [:course_id, :module_type] - remove_index :homework_commons, :course_homework_category_id - add_index :exercises, :course_id - remove_index :teacher_course_groups, :member_id - remove_index :student_works, :created_at - remove_index :student_works, :user_id - remove_index :student_works, :myshixun_id - remove_index :homework_challenge_settings, :shixun_id - remove_index :exercise_users, :exercise_id - add_index :exercise_users, [:exercise_id, :user_id] - add_index :homework_banks, :user_id - remove_index :exercise_answers, :exercise_choice_id - remove_index :exercise_answers, :exercise_question_id - add_index :exercise_answers, [:exercise_question_id, :user_id] - remove_index :exercise_shixun_challenges, :shixun_id - remove_index :exercise_shixun_answers, :exercise_shixun_challenge_id - remove_index :exercise_shixun_answers, :exercise_question_id - add_index :exercise_shixun_answers, [:exercise_question_id, :user_id], name: "exercise_question_id_user_id" - remove_index :student_works_evaluation_distributions, :student_work_id - add_index :student_works_evaluation_distributions, :user_id - remove_index :challenge_work_scores, :user_id - add_index :poll_questions, :poll_id - add_index :poll_users, [:poll_id, :user_id] - add_index :poll_answers, :poll_question_id - add_index :poll_votes, [:poll_question_id, :user_id], name: "poll_question_id_user_id" - remove_index :graduation_tasks, :user_id - remove_index :graduation_work_comment_assignations, :graduation_group_id - remove_index :graduation_works, :course_id - remove_index :graduation_works, :project_id - remove_index :graduation_works, :graduation_task_id - remove_index :graduation_works, :user_id - add_index :graduation_works, [:graduation_task_id, :user_id], name: "graduation_task_id_user_id" - - remove_index :graduation_work_scores, :graduation_task_id - remove_index :graduation_topics, :user_id - remove_index :graduation_topics, :tea_id - remove_index :student_graduation_topics, :member_id - remove_index :student_graduation_topics, :course_member_id - add_index :boards, :course_id - remove_index :messages, :author_id - remove_index :messages, :is_hidden - remove_index :messages, :root_id - remove_index :messages, :created_on - remove_index :attachments, :quotes - remove_index :attachments, :is_public - remove_index :attachments, :course_second_category_id - remove_index :course_members, :graduation_group_id - add_index :student_works_scores_appeals, :student_works_score_id - add_index :challenges, :shixun_id - add_index :challenge_chooses, :challenge_id - add_index :challenge_questions, :challenge_choose_id - add_index :challenge_tags, :challenge_id - remove_index :games, :user_id - add_index :shixun_members, :shixun_id - add_index :shixun_tag_repertoires, [:shixun_id, :tag_repertoire_id], name: "shixun_id_tag_repertoire_id" - add_index :shixun_schools, :shixun_id - add_index :shixun_mirror_repositories, :shixun_id - add_index :shixun_modifies, [:shixun_id, :myshixun_id], name: "shixun_id_myshixun_id" - remove_index :myshixuns, :user_id - remove_index :outputs, :created_at - remove_index :outputs, :test_set_position - remove_index :stages, :user_id - end -end diff --git a/db/migrate/20190524020819_change_exercise_question_type.rb b/db/migrate/20190524020819_change_exercise_question_type.rb deleted file mode 100644 index 625a57d06..000000000 --- a/db/migrate/20190524020819_change_exercise_question_type.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ChangeExerciseQuestionType < ActiveRecord::Migration[5.2] - def change - ExerciseQuestion.where(question_type: 1).update_all(question_type: 0) #新版0为单选题,1为多选题,2为判断题 - ExerciseQuestion.where(question_type: 2).update_all(question_type: 1) - - ExerciseBankQuestion.where(question_type: 1).update_all(question_type: 0) - ExerciseBankQuestion.where(question_type: 2).update_all(question_type: 1) - - end -end diff --git a/db/migrate/20190528024055_migrate_base_on_project.rb b/db/migrate/20190528024055_migrate_base_on_project.rb deleted file mode 100644 index d0ee197cb..000000000 --- a/db/migrate/20190528024055_migrate_base_on_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateBaseOnProject < ActiveRecord::Migration[5.2] - def change - change_column :homework_detail_groups, :base_on_project, :boolean, default: true - end -end diff --git a/db/migrate/20190603024856_migrate_course_late_settings.rb b/db/migrate/20190603024856_migrate_course_late_settings.rb deleted file mode 100644 index 3097d3d34..000000000 --- a/db/migrate/20190603024856_migrate_course_late_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class MigrateCourseLateSettings < ActiveRecord::Migration[5.2] - def change - change_column_default :homework_commons, :allow_late, from: 1, to: 0 - change_column_default :homework_commons, :late_penalty, from: 5, to: 0 - - change_column_default :graduation_tasks, :allow_late, from: 1, to: 0 - change_column_default :graduation_tasks, :late_penalty, from: 5, to: 0 - end -end diff --git a/db/migrate/20190606061948_migrate_student_works_scores_score.rb b/db/migrate/20190606061948_migrate_student_works_scores_score.rb deleted file mode 100644 index c531357a8..000000000 --- a/db/migrate/20190606061948_migrate_student_works_scores_score.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateStudentWorksScoresScore < ActiveRecord::Migration[5.2] - def change - change_column :student_works_scores, :score, :float - end -end diff --git a/db/migrate/20190610013620_change_question_random_default_true.rb b/db/migrate/20190610013620_change_question_random_default_true.rb deleted file mode 100644 index d0c785d46..000000000 --- a/db/migrate/20190610013620_change_question_random_default_true.rb +++ /dev/null @@ -1,12 +0,0 @@ -class ChangeQuestionRandomDefaultTrue < ActiveRecord::Migration[5.2] - #试卷的题目和选项的随机显示,需默认勾选 - def up - change_column_default :exercises,:question_random,true - change_column_default :exercises,:choice_random,true - end - - def down - change_column_default :exercises,:question_random,false - change_column_default :exercises,:choice_random,false - end -end diff --git a/db/migrate/20190613022158_add_exec_time_to_challenge.rb b/db/migrate/20190613022158_add_exec_time_to_challenge.rb deleted file mode 100644 index c1743674c..000000000 --- a/db/migrate/20190613022158_add_exec_time_to_challenge.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddExecTimeToChallenge < ActiveRecord::Migration[5.2] - def change - add_column :challenges, :exec_time, :integer - - Shixun.find_each do |shixun| - shixun.challenges.update_all(exec_time: shixun.exec_time) - end - end -end diff --git a/db/migrate/20190617081105_change_default_data_for_name_in_borads.rb b/db/migrate/20190617081105_change_default_data_for_name_in_borads.rb deleted file mode 100644 index 2dbbb7146..000000000 --- a/db/migrate/20190617081105_change_default_data_for_name_in_borads.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ChangeDefaultDataForNameInBorads < ActiveRecord::Migration[5.2] - def change - puts "--------- START ------------" - Board.roots.joins(:course).where('courses.id = boards.course_id').find_each do |board| - board.update_columns(name: '讨论区') unless board.name.strip === '讨论区' - puts "Board ID IS #{board.id}" - end - puts "--------- END ----------" - end -end diff --git a/db/migrate/20190619055012_add_uniq_index_to_course_modules.rb b/db/migrate/20190619055012_add_uniq_index_to_course_modules.rb deleted file mode 100644 index 92ae6449f..000000000 --- a/db/migrate/20190619055012_add_uniq_index_to_course_modules.rb +++ /dev/null @@ -1,43 +0,0 @@ -class AddUniqIndexToCourseModules < ActiveRecord::Migration[5.2] - def change - # sql = %Q(delete from exercise_users where (user_id, exercise_id) in - # (select * from (select user_id, exercise_id from exercise_users group by user_id, exercise_id having count(*) > 1) a) - # and id not in (select * from (select min(id) from exercise_users group by user_id, exercise_id having count(*) > 1 order by id) b)) - # ActiveRecord::Base.connection.execute sql - # - # add_index :exercise_users, [:user_id, :exercise_id], unique: true, name: "index_user_id_and_exercise_id" - - - sql = %Q(delete from exercise_shixun_answers where (user_id, exercise_shixun_challenge_id) in - (select * from (select user_id, exercise_shixun_challenge_id from exercise_shixun_answers group by user_id, exercise_shixun_challenge_id having count(*) > 1) a) - and id not in (select * from (select min(id) from exercise_shixun_answers group by user_id, exercise_shixun_challenge_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - - add_index :exercise_shixun_answers, [:user_id, :exercise_shixun_challenge_id], unique: true, - name: "index_user_id_and_exercise_shixun_challenge_id" - - - # sql = %Q(delete from student_works where (user_id, homework_common_id) in - # (select * from (select user_id, homework_common_id from student_works group by user_id, homework_common_id having count(*) > 1) a) - # and id not in (select * from (select min(id) from student_works group by user_id, homework_common_id having count(*) > 1 order by id) b)) - # ActiveRecord::Base.connection.execute sql - # - # add_index :student_works, [:user_id, :homework_common_id], unique: true, name: "index_user_id_and_homework_common_id" - # - # - # sql = %Q(delete from poll_users where (user_id, poll_id) in - # (select * from (select user_id, poll_id from poll_users group by user_id, poll_id having count(*) > 1) a) and - # id not in (select * from (select min(id) from poll_users group by user_id, poll_id having count(*) > 1 order by id) b)) - # ActiveRecord::Base.connection.execute sql - # - # add_index :poll_users, [:user_id, :poll_id], unique: true, name: "index_user_id_and_poll_id" - # - # - # sql = %Q(delete from graduation_works where (user_id, graduation_task_id) in - # (select * from (select user_id, graduation_task_id from graduation_works group by user_id, graduation_task_id having count(*) > 1) a) and - # id not in (select * from (select min(id) from graduation_works group by user_id, graduation_task_id having count(*) > 1 order by id) b)) - # ActiveRecord::Base.connection.execute sql - # - # add_index :graduation_works, [:user_id, :graduation_task_id], unique: true, name: "index_user_id_and_graduation_task_id" - end -end diff --git a/db/migrate/20190619093200_add_profile_completed_to_users.rb b/db/migrate/20190619093200_add_profile_completed_to_users.rb deleted file mode 100644 index 5248abd58..000000000 --- a/db/migrate/20190619093200_add_profile_completed_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddProfileCompletedToUsers < ActiveRecord::Migration[5.2] - def change - add_column :users, :profile_completed, :boolean, default: false - end -end diff --git a/db/migrate/20190619120609_add_graduation_topics_count_to_course.rb b/db/migrate/20190619120609_add_graduation_topics_count_to_course.rb deleted file mode 100644 index 01444b7ce..000000000 --- a/db/migrate/20190619120609_add_graduation_topics_count_to_course.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddGraduationTopicsCountToCourse < ActiveRecord::Migration[5.2] - def change - add_column :courses, :graduation_topics_count, :integer, :default => 0 - add_column :courses, :graduation_tasks_count, :integer, :default => 0 - # add_column :courses, :attachments_count, :integer, :default => 0 - add_column :courses, :polls_count, :integer, :default => 0 - add_column :courses, :exercises_count, :integer, :default => 0 - end -end diff --git a/db/migrate/20190619123328_sync_countcha_for_course.rb b/db/migrate/20190619123328_sync_countcha_for_course.rb deleted file mode 100644 index acd9e9716..000000000 --- a/db/migrate/20190619123328_sync_countcha_for_course.rb +++ /dev/null @@ -1,11 +0,0 @@ -class SyncCountchaForCourse < ActiveRecord::Migration[5.2] - def change - Course.find_each do |course| - Course.reset_counters course.id, :graduation_topics - Course.reset_counters course.id, :graduation_tasks - Course.reset_counters course.id, :polls - Course.reset_counters course.id, :exercises - # Course.reset_counters course.id, :attachments - end - end -end diff --git a/db/migrate/20190620010439_add_uniq_index_to_course_member.rb b/db/migrate/20190620010439_add_uniq_index_to_course_member.rb deleted file mode 100644 index f17cd4274..000000000 --- a/db/migrate/20190620010439_add_uniq_index_to_course_member.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddUniqIndexToCourseMember < ActiveRecord::Migration[5.2] - def change - # sql = %Q(delete from course_members where (user_id, course_id, role) in - # (select * from (select user_id, course_id, role from course_members group by user_id, course_id, role having count(*) > 1) a) - # and id not in (select * from (select min(id) from course_members group by user_id, course_id, role having count(*) > 1 order by id) b)) - # ActiveRecord::Base.connection.execute sql - # - # add_index :course_members, [:user_id, :course_id, :role], unique: true, name: "index_user_id_course_id_role" - end -end diff --git a/db/migrate/20190620015912_modify_colla_index.rb b/db/migrate/20190620015912_modify_colla_index.rb deleted file mode 100644 index 0e9e23301..000000000 --- a/db/migrate/20190620015912_modify_colla_index.rb +++ /dev/null @@ -1,51 +0,0 @@ -class ModifyCollaIndex < ActiveRecord::Migration[5.2] - def change - remove_index :exercise_users, [:user_id, :exercise_id] if index_exists?(:exercise_users, [:user_id, :exercise_id]) - remove_index :exercise_users, [:exercise_id, :user_id] if index_exists?(:exercise_users, [:exercise_id, :user_id]) - sql = %Q(delete from exercise_users where (user_id, exercise_id) in - (select * from (select user_id, exercise_id from exercise_users group by user_id, exercise_id having count(*) > 1) a) - and id not in (select * from (select min(id) from exercise_users group by user_id, exercise_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - add_index :exercise_users, [:exercise_id, :user_id], unique: true, name: "index_on_exercise_id_user_id" - - - remove_index :exercise_shixun_answers, :user_id - - - remove_index :student_works, [:user_id, :homework_common_id] if index_exists?(:student_works, [:user_id, :homework_common_id]) - remove_index :student_works, [:homework_common_id, :user_id] if index_exists?(:student_works, [:homework_common_id, :user_id]) - sql = %Q(delete from student_works where (user_id, homework_common_id) in - (select * from (select user_id, homework_common_id from student_works group by user_id, homework_common_id having count(*) > 1) a) - and id not in (select * from (select min(id) from student_works group by user_id, homework_common_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - add_index :student_works, [:homework_common_id, :user_id], unique: true, name: "index_on_homework_common_id_user_id" - - - remove_index :poll_users, [:user_id, :poll_id] if index_exists?(:poll_users, [:user_id, :poll_id]) - remove_index :poll_users, [:poll_id, :user_id] if index_exists?(:poll_users, [:poll_id, :user_id]) - sql = %Q(delete from poll_users where (user_id, poll_id) in - (select * from (select user_id, poll_id from poll_users group by user_id, poll_id having count(*) > 1) a) and - id not in (select * from (select min(id) from poll_users group by user_id, poll_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - add_index :poll_users, [:poll_id, :user_id], unique: true, name: "index_poll_id_and_user_id" - - - remove_index :graduation_works, [:user_id, :graduation_task_id] if index_exists?(:graduation_works, [:user_id, :graduation_task_id]) - remove_index :graduation_works, [:graduation_task_id, :user_id] if index_exists?(:graduation_works, [:graduation_task_id, :user_id]) - sql = %Q(delete from graduation_works where (user_id, graduation_task_id) in - (select * from (select user_id, graduation_task_id from graduation_works group by user_id, graduation_task_id having count(*) > 1) a) and - id not in (select * from (select min(id) from graduation_works group by user_id, graduation_task_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - add_index :graduation_works, [:graduation_task_id, :user_id], unique: true, name: "index_graduation_task_id_and_user_id" - - - remove_index :course_members, [:user_id, :course_id, :role] if index_exists?(:course_members, [:user_id, :course_id, :role]) - remove_index :course_members, :course_id if index_exists?(:course_members, :course_id) - remove_index :course_members, :user_id if index_exists?(:course_members, :user_id) - sql = %Q(delete from course_members where (course_id, user_id, role) in - (select * from (select course_id, user_id, role from course_members group by course_id, user_id, role having count(*) > 1) a) - and id not in (select * from (select min(id) from course_members group by course_id, user_id, role having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - add_index :course_members, [:course_id, :user_id, :role], unique: true, name: "index_course_id_user_id_role" - end -end diff --git a/db/migrate/20190620021243_add_homework_bank_id_index_to_homework_commons.rb b/db/migrate/20190620021243_add_homework_bank_id_index_to_homework_commons.rb deleted file mode 100644 index 9a97b82bf..000000000 --- a/db/migrate/20190620021243_add_homework_bank_id_index_to_homework_commons.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHomeworkBankIdIndexToHomeworkCommons < ActiveRecord::Migration[5.2] - def change - add_index :homework_commons, :homework_bank_id - end -end diff --git a/db/migrate/20190620075503_add_bank_id_for_graduation_task_and_topic.rb b/db/migrate/20190620075503_add_bank_id_for_graduation_task_and_topic.rb deleted file mode 100644 index 8149731e7..000000000 --- a/db/migrate/20190620075503_add_bank_id_for_graduation_task_and_topic.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddBankIdForGraduationTaskAndTopic < ActiveRecord::Migration[5.2] - def change - add_column :graduation_tasks, :gtask_bank_id, :integer - add_column :graduation_topics, :gtopic_bank_id, :integer - end -end diff --git a/db/migrate/20190621010002_change_default_to_max_num.rb b/db/migrate/20190621010002_change_default_to_max_num.rb deleted file mode 100644 index 435756cd8..000000000 --- a/db/migrate/20190621010002_change_default_to_max_num.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeDefaultToMaxNum < ActiveRecord::Migration[5.2] - def change - change_column :graduation_tasks, :max_num, :integer, default: 5 - end -end diff --git a/db/migrate/20190621062948_migrate_course_module_activity.rb b/db/migrate/20190621062948_migrate_course_module_activity.rb deleted file mode 100644 index 1fa1ea112..000000000 --- a/db/migrate/20190621062948_migrate_course_module_activity.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateCourseModuleActivity < ActiveRecord::Migration[5.2] - def change - CourseModule.where(module_type: 'activity').update_all(hidden: 1) - end -end \ No newline at end of file diff --git a/db/migrate/20190621083604_add_descendants_count_to_messages.rb b/db/migrate/20190621083604_add_descendants_count_to_messages.rb deleted file mode 100644 index 02b721583..000000000 --- a/db/migrate/20190621083604_add_descendants_count_to_messages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDescendantsCountToMessages < ActiveRecord::Migration[5.2] - def change - add_column :messages, :descendants_count, :integer, default: 0 - end -end diff --git a/db/migrate/20190621105144_sync_ivalid_users.rb b/db/migrate/20190621105144_sync_ivalid_users.rb deleted file mode 100644 index f2875977f..000000000 --- a/db/migrate/20190621105144_sync_ivalid_users.rb +++ /dev/null @@ -1,34 +0,0 @@ -class SyncIvalidUsers < ActiveRecord::Migration[5.2] - # def change - # users = User.where.not(id: 2).find_by_sql("select count(*) as user_count, login from users group by login having user_count>1") - # users.each do |user| - # valid_users = User.where(login: user.login) - # valid_users.each do |valid_user| - # unless valid_user.lastname.present? - # valid_user.delete - # end - # end - # end - # - # mail_users = User.where.not(id: 2).find_by_sql("select count(*) as user_count, mail from users where mail is not null group by mail having user_count>1") - # mail_users.each do |mail_user| - # valid_mail_users = User.where(mail: mail_user.mail) - # valid_mail_users.each do |valid_mail_user| - # unless valid_mail_user.lastname.present? - # valid_mail_user.delete - # end - # end - # end - # - # - # phone_users = User.where.not(id: 2).find_by_sql("select count(*) as user_count, phone from users where phone is not null group by phone having user_count>1") - # phone_users.each do |phone_user| - # valid_phone_users = User.where(phone: phone_user.phone) - # valid_phone_users.each do |valid_phone_user| - # unless valid_phone_user.lastname.present? - # valid_phone_user.delete - # end - # end - # end - # end -end diff --git a/db/migrate/20190622055449_modify_shixun_info_for_shixuns.rb b/db/migrate/20190622055449_modify_shixun_info_for_shixuns.rb deleted file mode 100644 index 1a3aa147b..000000000 --- a/db/migrate/20190622055449_modify_shixun_info_for_shixuns.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ModifyShixunInfoForShixuns < ActiveRecord::Migration[5.2] - def change - Shixun.find_each do |shixun| - if shixun.shixun_info - shixun.shixun_info.update_attributes(propaedeutics: shixun[:propaedeutics], - description: shixun[:description], - evaluate_script: shixun[:evaluate_script], - shixun_id: shixun[:id]) - else - ShixunInfo.create!(propaedeutics: shixun[:propaedeutics], description: shixun[:description], - evaluate_script: shixun[:evaluate_script], shixun_id: shixun.id) - end - end - end -end diff --git a/db/migrate/20190622060005_remove_shixun_long_text_for_shixuns.rb b/db/migrate/20190622060005_remove_shixun_long_text_for_shixuns.rb deleted file mode 100644 index 4557c610f..000000000 --- a/db/migrate/20190622060005_remove_shixun_long_text_for_shixuns.rb +++ /dev/null @@ -1,7 +0,0 @@ -class RemoveShixunLongTextForShixuns < ActiveRecord::Migration[5.2] - def change - if Shixun.first.has_attribute?(:description) - remove_columns :shixuns, :description, :propaedeutics, :evaluate_script - end - end -end diff --git a/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb b/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb deleted file mode 100644 index 49a385ad9..000000000 --- a/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddUniqIndexToHomeworkChallengeSettings < ActiveRecord::Migration[5.2] - def change - remove_index :homework_challenge_settings, [:homework_common_id, :challenge_id] if index_exists?(:homework_challenge_settings, [:homework_common_id, :challenge_id]) - sql = %Q(delete from homework_challenge_settings where (homework_common_id, challenge_id) in - (select * from (select homework_common_id, challenge_id from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1) a) - and id not in (select * from (select max(id) from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - add_index :homework_challenge_settings, [:homework_common_id, :challenge_id], unique: true, name: "index_on_homework_common_id_challenge_id" - end -end diff --git a/db/migrate/20190625012548_add_index_for_evaluate_record.rb b/db/migrate/20190625012548_add_index_for_evaluate_record.rb deleted file mode 100644 index d67e33b1e..000000000 --- a/db/migrate/20190625012548_add_index_for_evaluate_record.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexForEvaluateRecord < ActiveRecord::Migration[5.2] - def change - # 增加evalute_records的索引,提高查询效率 - add_index :evaluate_records, :game_id - end -end diff --git a/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb b/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb deleted file mode 100644 index a47157414..000000000 --- a/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ModifyQuotesForGtopicBanks < ActiveRecord::Migration[5.2] - def change - GtopicBank.where("quotes is null").update_all(:quotes => 0) - change_column :gtopic_banks, :quotes, :integer, :default => 0 - end -end diff --git a/db/migrate/20190701013243_add_calculation_time_to_homework.rb b/db/migrate/20190701013243_add_calculation_time_to_homework.rb deleted file mode 100644 index 4a622ee92..000000000 --- a/db/migrate/20190701013243_add_calculation_time_to_homework.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCalculationTimeToHomework < ActiveRecord::Migration[5.2] - def change - add_column :homework_commons, :calculation_time, :datetime - add_column :student_works, :calculation_time, :datetime - end -end diff --git a/db/migrate/20190703072611_add_old_exercise_tiankong_choice_id.rb b/db/migrate/20190703072611_add_old_exercise_tiankong_choice_id.rb deleted file mode 100644 index 9ad1429e2..000000000 --- a/db/migrate/20190703072611_add_old_exercise_tiankong_choice_id.rb +++ /dev/null @@ -1,23 +0,0 @@ -class AddOldExerciseTiankongChoiceId < ActiveRecord::Migration[5.2] - - def up - #类型为3 的问题答案及标准答案更新exercise_choice_id 为1,即表示第一空 - exercise_question_ids = ExerciseQuestion.where("question_type = 3").pluck(:id) - ExerciseAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: nil).update_all(exercise_choice_id:1) - ExerciseStandardAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: nil).update_all(exercise_choice_id:1) - - exercise_bank_question_ids = ExerciseBankQuestion.where("question_type =3").pluck(:id) - ExerciseBankStandardAnswer.where(exercise_bank_question_id: exercise_bank_question_ids).update_all(exercise_bank_choice_id:1) - end - - def down - #类型为3 的问题答案及标准答案更新exercise_choice_id 为1,即表示第一空 - exercise_question_ids = ExerciseQuestion.where("question_type = 3").pluck(:id) - ExerciseAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: 1).update_all(exercise_choice_id:nil) - ExerciseStandardAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: 1).update_all(exercise_choice_id:nil) - - exercise_bank_question_ids = ExerciseBankQuestion.where("question_type =3").pluck(:id) - ExerciseBankStandardAnswer.where(exercise_bank_question_id: exercise_bank_question_ids).update_all(exercise_bank_choice_id:nil) - end - -end diff --git a/db/migrate/20190703090511_add_index_for_shixun_services.rb b/db/migrate/20190703090511_add_index_for_shixun_services.rb deleted file mode 100644 index 693add3e3..000000000 --- a/db/migrate/20190703090511_add_index_for_shixun_services.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddIndexForShixunServices < ActiveRecord::Migration[5.2] - def change - sql = %Q(delete from shixun_service_configs where (shixun_id, mirror_repository_id) in - (select * from (select shixun_id, mirror_repository_id from shixun_service_configs group by shixun_id, mirror_repository_id having count(*) > 1) a) - and id not in (select * from (select min(id) from shixun_service_configs group by shixun_id, mirror_repository_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - add_index :shixun_service_configs, [:shixun_id, :mirror_repository_id], unique: true, name: "shixun_id_mirror_id_unique" - end -end diff --git a/db/migrate/20190705011739_add_praises_count_for_challenges.rb b/db/migrate/20190705011739_add_praises_count_for_challenges.rb deleted file mode 100644 index 6ae1d8420..000000000 --- a/db/migrate/20190705011739_add_praises_count_for_challenges.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPraisesCountForChallenges < ActiveRecord::Migration[5.2] - def change - add_column :challenges, :praises_count, :integer, :default => 0 - end -end diff --git a/db/migrate/20190705013204_modify_praises_count_for_challenges.rb b/db/migrate/20190705013204_modify_praises_count_for_challenges.rb deleted file mode 100644 index 59aa6ca53..000000000 --- a/db/migrate/20190705013204_modify_praises_count_for_challenges.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ModifyPraisesCountForChallenges < ActiveRecord::Migration[5.2] - def change - challenges = Challenge.where(nil).unscoped - challenges.find_each do |c| - praises_count = c.praise_treads.where(praise_or_tread: 1).count - c.update_column(:praises_count, praises_count) - end - end -end diff --git a/db/migrate/20190705022502_add_praises_count_for_discuess.rb b/db/migrate/20190705022502_add_praises_count_for_discuess.rb deleted file mode 100644 index 47fd5ec1a..000000000 --- a/db/migrate/20190705022502_add_praises_count_for_discuess.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPraisesCountForDiscuess < ActiveRecord::Migration[5.2] - def change - add_column :discusses, :praises_count, :integer, :default => 0 - end -end diff --git a/db/migrate/20190705022737_modify_praises_count_for_discuess.rb b/db/migrate/20190705022737_modify_praises_count_for_discuess.rb deleted file mode 100644 index 4d5b6ca97..000000000 --- a/db/migrate/20190705022737_modify_praises_count_for_discuess.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ModifyPraisesCountForDiscuess < ActiveRecord::Migration[5.2] - def change - discusses = Discuss.includes(:praise_treads).unscoped - discusses.find_each do |d| - praises_count = d.praise_treads.liker.count - d.update_column(:praises_count, praises_count) - end - end -end diff --git a/db/migrate/20190705085829_add_sec_key_to_outputs.rb b/db/migrate/20190705085829_add_sec_key_to_outputs.rb deleted file mode 100644 index 1da2930ae..000000000 --- a/db/migrate/20190705085829_add_sec_key_to_outputs.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddSecKeyToOutputs < ActiveRecord::Migration[5.2] - def change - #add_column :outputs, :sec_key, :string - # add_column :outputs, :ts_mem, :float - # add_column :outputs, :ts_time, :float - end -end diff --git a/db/migrate/20190706010307_create_user_interests.rb b/db/migrate/20190706010307_create_user_interests.rb deleted file mode 100644 index d64a1c228..000000000 --- a/db/migrate/20190706010307_create_user_interests.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateUserInterests < ActiveRecord::Migration[5.2] - def change - create_table :user_interests do |t| - t.references :user - t.references :repertoire - end - end -end diff --git a/db/migrate/20190708062910_add_index_for_run_code_message.rb b/db/migrate/20190708062910_add_index_for_run_code_message.rb deleted file mode 100644 index 4449d58a2..000000000 --- a/db/migrate/20190708062910_add_index_for_run_code_message.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexForRunCodeMessage < ActiveRecord::Migration[5.2] - def change - add_index :run_code_messages, :game_id - end -end diff --git a/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb b/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb deleted file mode 100644 index 86052375b..000000000 --- a/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ModifyChallengeIdForDiscusses < ActiveRecord::Migration[5.2] - def change - discusses = Discuss.where(challenge_id: nil) - discusses.each do |dis| - challenge_id = Shixun.find(dis.dis_id).challenges.first.id - dis.update_column(:challenge_id, challenge_id) - end - add_index :discusses, :challenge_id - - end -end diff --git a/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb b/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb deleted file mode 100644 index 10b821fc5..000000000 --- a/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb +++ /dev/null @@ -1,35 +0,0 @@ -class ModifyMdAttachmentUrlForMdCotents < ActiveRecord::Migration[5.2] - def change - # 更新MarkDown图片的URL - homework_commons = HomeworkCommon.all - homework_commons.find_each do |hc| - hc.update_column(:description, hc.description.gsub("![](/attachments/download", "![](/api/attachments")) if hc.description.present? - end - - challenges = Challenge.all.unscoped - challenges.find_each do |c| - c.update_column(:task_pass, c.task_pass.gsub("![](/attachments/download", "![](/api/attachments")) if c.task_pass.present? - end - - challenge_answers = ChallengeAnswer.all.unscoped - challenge_answers.find_each do |ca| - ca.update_column(:contents, ca.contents.gsub("![](/attachments/download", "![](/api/attachments")) if ca.contents.present? - end - - shixun_infos = ShixunInfo.all - shixun_infos.find_each do |si| - si.update_column(:propaedeutics, si.propaedeutics.gsub("![](/attachments/download", "![](/api/attachments")) if si.propaedeutics.present? - si.update_column(:description, si.description.gsub("![](/attachments/download", "![](/api/attachments")) if si.description.present? - end - - subjects = Subject.all - subjects.find_each do |s| - s.update_column(:description, s.description.gsub("![](/attachments/download", "![](/api/attachments")) if s.description.present? - end - - plats = PlatformSample.where(samples_type: ['introduction', 'knowledge']) - plats.find_each do |p| - p.update_column(:contents, p.contents.gsub("![](/attachments/download", "![](/api/attachments")) if p.contents.present? - end - end -end diff --git a/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb b/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb deleted file mode 100644 index 86425262d..000000000 --- a/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMaxMemToEvaluateRecords < ActiveRecord::Migration[5.2] - def change - #add_column :evaluate_records, :max_mem, :float - end -end diff --git a/db/migrate/20190720025309_add_ts_mem_for_outputs.rb b/db/migrate/20190720025309_add_ts_mem_for_outputs.rb deleted file mode 100644 index fac886fda..000000000 --- a/db/migrate/20190720025309_add_ts_mem_for_outputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTsMemForOutputs < ActiveRecord::Migration[5.2] - def change - #add_column :outputs, :ts_mem, :float - end -end diff --git a/db/migrate/20190720025341_add_ts_time_for_outputs.rb b/db/migrate/20190720025341_add_ts_time_for_outputs.rb deleted file mode 100644 index 9c5f8a23f..000000000 --- a/db/migrate/20190720025341_add_ts_time_for_outputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTsTimeForOutputs < ActiveRecord::Migration[5.2] - def change - #add_column :outputs, :ts_time, :float - end -end diff --git a/db/migrate/20190720121537_add_is_md_for_messages.rb b/db/migrate/20190720121537_add_is_md_for_messages.rb deleted file mode 100644 index a801fb387..000000000 --- a/db/migrate/20190720121537_add_is_md_for_messages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIsMdForMessages < ActiveRecord::Migration[5.2] - def change - add_column :messages, :is_md, :boolean, :default => true - end -end diff --git a/db/migrate/20190720122123_modify_is_md_for_messages.rb b/db/migrate/20190720122123_modify_is_md_for_messages.rb deleted file mode 100644 index 4137fc8af..000000000 --- a/db/migrate/20190720122123_modify_is_md_for_messages.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ModifyIsMdForMessages < ActiveRecord::Migration[5.2] - def change - Message.find_each do |m| - m.update_column(:is_md, false) - end - end -end diff --git a/db/migrate/20190722062801_modify_answer_for_challenges.rb b/db/migrate/20190722062801_modify_answer_for_challenges.rb deleted file mode 100644 index 747564d68..000000000 --- a/db/migrate/20190722062801_modify_answer_for_challenges.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ModifyAnswerForChallenges < ActiveRecord::Migration[5.2] - def change - challenges = Challenge.where("answer is not null or answer != ''") - .includes(:challenge_answers).unscoped - challenges.find_each do |c| - next if c.challenge_answers.present? - puts("############challenge_id:##{c.id}") - ChallengeAnswer.create(name: "解题代码", contents: "#{c.answer}", level: 1, score: 100, challenge_id: c.id) - end - end -end diff --git a/db/migrate/20190723152256_delete_contents_is_null_for_challenge_answers.rb b/db/migrate/20190723152256_delete_contents_is_null_for_challenge_answers.rb deleted file mode 100644 index a85152894..000000000 --- a/db/migrate/20190723152256_delete_contents_is_null_for_challenge_answers.rb +++ /dev/null @@ -1,6 +0,0 @@ -class DeleteContentsIsNullForChallengeAnswers < ActiveRecord::Migration[5.2] - def change - contents = ChallengeAnswer.where("contents = ''") - contents.delete_all - end -end diff --git a/db/migrate/20190724013024_modify_final_score_for_games.rb b/db/migrate/20190724013024_modify_final_score_for_games.rb deleted file mode 100644 index e926cccd6..000000000 --- a/db/migrate/20190724013024_modify_final_score_for_games.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ModifyFinalScoreForGames < ActiveRecord::Migration[5.2] - def change - grades = Grade.where(container_type: "Answer") - grades.each do |grade| - g = Game.find_by_id(grade.container_id) - if g.present? - if g.status == 2 && g.answer_open > 0 && g.final_score <= 0 && g.end_time < grade.created_at - g.update_column(:final_score, g.challenge.score) - elsif g.final_score < 0 - g.update_column(:final_score, 0) - end - end - end - end -end diff --git a/db/migrate/20190726082937_add_is_md_for_homeworks.rb b/db/migrate/20190726082937_add_is_md_for_homeworks.rb deleted file mode 100644 index 0b25dde97..000000000 --- a/db/migrate/20190726082937_add_is_md_for_homeworks.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddIsMdForHomeworks < ActiveRecord::Migration[5.2] - def change - # add_column :homework_commons, :is_md, :boolean, :default => true - # add_column :homework_banks, :is_md, :boolean, :default => true - # - # - # add_column :exercise_questions,:is_md, :boolean, :default => true - # add_column :poll_questions,:is_md, :boolean, :default => true - # - # add_column :exercise_bank_questions, :is_md, :boolean, :default => true - end -end diff --git a/db/migrate/20190726083814_migrate_course_is_md.rb b/db/migrate/20190726083814_migrate_course_is_md.rb deleted file mode 100644 index 6988db14a..000000000 --- a/db/migrate/20190726083814_migrate_course_is_md.rb +++ /dev/null @@ -1,14 +0,0 @@ -class MigrateCourseIsMd < ActiveRecord::Migration[5.2] - def change - # HomeworkCommon.where(homework_type: [1, 3]).where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false) - # HomeworkBank.where(homework_type: [1, 3]).where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false) - # - # HomeworkCommon.where(homework_type: [1, 3]).where("created_at >= '2019-07-21 00:00:00' and homework_bank_id is not null").each do |homework| - # - # end - # - # ExerciseQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false) - # PollQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false) - # ExerciseBankQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false) - end -end diff --git a/db/migrate/20190729080935_modify_login_for_users.rb b/db/migrate/20190729080935_modify_login_for_users.rb deleted file mode 100644 index 60e5e0964..000000000 --- a/db/migrate/20190729080935_modify_login_for_users.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ModifyLoginForUsers < ActiveRecord::Migration[5.2] - def change - users = User.where("created_on > '2019-07-26 19:00:00'") - users.find_each do |use| - use.update_attributes(login: use.login&.strip, phone: use.phone&.strip) - use.user_extension.update_column(:student_id, use.user_extension&.student_id&.strip) if use.user_extension - end - end -end diff --git a/db/migrate/20190729095722_delete_error_myshixun_from_myshxiuns.rb b/db/migrate/20190729095722_delete_error_myshixun_from_myshxiuns.rb deleted file mode 100644 index ef5b86975..000000000 --- a/db/migrate/20190729095722_delete_error_myshixun_from_myshxiuns.rb +++ /dev/null @@ -1,11 +0,0 @@ -class DeleteErrorMyshixunFromMyshxiuns < ActiveRecord::Migration[5.2] - def change - myshixuns = Myshixun.where("created_at > '2019-07-26 00:00:00' and repo_name is null") - myshixuns.find_each do |myshixun| - if myshixun.games.blank? - puts("###########user_login: #{User.find(myshixun.user_id).login}") - myshixun.destroy! - end - end - end -end diff --git a/db/migrate/20190729122213_delete_myshixun_games_for_users.rb b/db/migrate/20190729122213_delete_myshixun_games_for_users.rb deleted file mode 100644 index d52369828..000000000 --- a/db/migrate/20190729122213_delete_myshixun_games_for_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class DeleteMyshixunGamesForUsers < ActiveRecord::Migration[5.2] - def change - myshixuns = Myshixun.where("created_at > '2019-07-26 19:00:00' and repo_name is null") - myshixuns.find_each do |m| - if m.games.count == m.games.select{|g| g.status == 3}.count - puts("#######login: #{User.find(m.user_id).login}") - m.destroy! - end - end - end -end diff --git a/db/migrate/20190801075337_add_praises_count_to_memos.rb b/db/migrate/20190801075337_add_praises_count_to_memos.rb deleted file mode 100644 index 0cc2259e2..000000000 --- a/db/migrate/20190801075337_add_praises_count_to_memos.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddPraisesCountToMemos < ActiveRecord::Migration[5.2] - def change - add_column :memos, :praises_count, :integer, :default => 0 - - memos = Memo.includes(:praise_treads).all - memos.find_each do |m| - puts("####{m.id}") - praises_count = m.praise_treads.select{|pt| pt.praise_or_tread == 1}.count - m.update_column(:praises_count, praises_count) - end - end -end diff --git a/db/migrate/20190801084533_add_praises_count_to_libraries.rb b/db/migrate/20190801084533_add_praises_count_to_libraries.rb deleted file mode 100644 index b773cf918..000000000 --- a/db/migrate/20190801084533_add_praises_count_to_libraries.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddPraisesCountToLibraries < ActiveRecord::Migration[5.2] - def change - # add_column :libraries, :praises_count, :integer, :default => 0 - # - # Library.find_each do |library| - # praises_count = library.praise_treads.count - # library.update_column(:praises_count, praises_count) - # end - end -end diff --git a/db/migrate/20190802105008_tranfer_tiding_data.rb b/db/migrate/20190802105008_tranfer_tiding_data.rb deleted file mode 100644 index ef7682530..000000000 --- a/db/migrate/20190802105008_tranfer_tiding_data.rb +++ /dev/null @@ -1,5 +0,0 @@ -class TranferTidingData < ActiveRecord::Migration[5.2] - def change - Tiding.where(container_type: 'ApplyAddSchool').update_all(container_type: 'ApplyAddSchools') - end -end diff --git a/db/migrate/20190805004505_sync_index_to_users.rb b/db/migrate/20190805004505_sync_index_to_users.rb deleted file mode 100644 index 33adca30c..000000000 --- a/db/migrate/20190805004505_sync_index_to_users.rb +++ /dev/null @@ -1,7 +0,0 @@ -class SyncIndexToUsers < ActiveRecord::Migration[5.2] - def change - add_index :users, :login, unique: true - add_index :users, :mail, unique: true - add_index :users, :phone, unique: true - end -end diff --git a/db/migrate/20190805010562_modify_ke_contents_for_markdown.rb b/db/migrate/20190805010562_modify_ke_contents_for_markdown.rb deleted file mode 100644 index 958b70448..000000000 --- a/db/migrate/20190805010562_modify_ke_contents_for_markdown.rb +++ /dev/null @@ -1,51 +0,0 @@ -class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2] - include ActionView::Helpers::SanitizeHelper - def change - # def ke_transform_to_md content - # return content if content.blank? - # s_contents = sanitize(content, tags: %w(img a table td tr tbody pre), attributes: %w(src href target style)) - # s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", "").gsub(/(\n)+/, "
") - # .gsub("\t", "").gsub("\n", "").gsub(" ", "    ").gsub(/()+/, "
") - # s_contents.gsub("\n", "
").gsub(/()+/, "
") - # end - # - # # 课程讨论区 - # MessageDetail.find_each do |m| - # content = ke_transform_to_md m.content - # m.update_column(:content, content) - # end - - #试卷的标题 - # ExerciseQuestion.where(:exercise_id => 1892).find_each do |eq| - # puts("#eq.question_title: #{eq.question_title}") - # question_title = ke_transform_to_md eq.question_title - # puts("#question_title: #{question_title}") - # eq.update_column(:question_title, question_title) - # end - - # # 试卷的答案 - # ExerciseStandardAnswer.find_each do |esa| - # answer_text = ke_transform_to_md esa.answer_text - # esa.update_column(:answer_text, answer_text) - # end - # - # 试卷题库的问题标题 - # ExerciseBankQuestion.find_each do |ebq| - # question_title = ke_transform_to_md ebq.question_title - # ebq.update_column(:question_title, question_title) - # end - # - # # 试卷答案 - # ExerciseBankStandardAnswer.find_each do |ebsa| - # answer_text = ke_transform_to_md ebsa.answer_text - # ebsa.update_column(:answer_text, answer_text) - # end - - # # 问卷的标题 - # PollQuestion.find_each do |pq| - # question_title = ke_transform_to_md pq.question_title - # pq.update_column(:question_title, question_title) - # end - - end -end diff --git a/db/migrate/20190805014624_migrate_anonymous_tiding_type.rb b/db/migrate/20190805014624_migrate_anonymous_tiding_type.rb deleted file mode 100644 index cd45ec196..000000000 --- a/db/migrate/20190805014624_migrate_anonymous_tiding_type.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MigrateAnonymousTidingType < ActiveRecord::Migration[5.2] - def change - Tiding.where(container_type: "StudentWorksScore", extra: "3").update_all(tiding_type: "System", trigger_user_id: 0) - Tiding.where(container_type: "StudentWorksScoresAppeal", parent_container_type: "StudentWork", tiding_type: "HomeworkCommon").update_all(tiding_type: "System", trigger_user_id: 0) - end -end diff --git a/db/migrate/20190805061306_add_exec_time_to_evaluate_records.rb b/db/migrate/20190805061306_add_exec_time_to_evaluate_records.rb deleted file mode 100644 index 95edeb7d5..000000000 --- a/db/migrate/20190805061306_add_exec_time_to_evaluate_records.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddExecTimeToEvaluateRecords < ActiveRecord::Migration[5.2] - def change - # remove_columns :evaluate_records, :exec_time if EvaluateRecord.first.attributes.include?("exec_time") - # - # add_column :evaluate_records, :exec_time, :integer - end -end diff --git a/db/migrate/20190806062209_second_mofidy_ke_contents_for_md.rb b/db/migrate/20190806062209_second_mofidy_ke_contents_for_md.rb deleted file mode 100644 index c8068e049..000000000 --- a/db/migrate/20190806062209_second_mofidy_ke_contents_for_md.rb +++ /dev/null @@ -1,64 +0,0 @@ -class SecondMofidyKeContentsForMd < ActiveRecord::Migration[5.2] - include ActionView::Helpers::SanitizeHelper - def change - # def ke_transform_to_md content - # return content if content.blank? - # s_contents = sanitize(content, tags: %w(img a span table td tr tbody pre), attributes: %w(src href target style)) - # s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", " ").gsub(/(\n)+/, "
") - # .gsub("\t", "    ").gsub("\n", "").gsub(" ", " ").gsub(/()+/, "
") - # - # end - # - # # 作业 - # HomeworkCommon.find_each do |hc| - # description = ke_transform_to_md hc.description - # reference_answer = ke_transform_to_md hc.reference_answer - # explanation = ke_transform_to_md hc.explanation - # hc.update_attributes(description: description, reference_answer: reference_answer, explanation: explanation) - # end - # - # # 作业题库 - # HomeworkBank.find_each do |hb| - # description = ke_transform_to_md hb.description - # reference_answer = ke_transform_to_md hb.reference_answer - # hb.update_attributes(description: description, reference_answer: reference_answer) - # end - # - # # 毕业任务 - # GraduationTask.find_each do |gt| - # description = ke_transform_to_md gt.description - # gt.update_column(:description, description) - # end - # - # # 毕设选题 - # GraduationTopic.find_each do |gt| - # description = ke_transform_to_md gt.description - # gt.update_column(:description, description) - # end - # - # # 毕设作品 - # GraduationWork.find_each do |gw| - # description = ke_transform_to_md gw.description - # gw.update_column(:description, description) - # end - # - # # 毕设任务题库 - # GtaskBank.find_each do |gb| - # description = ke_transform_to_md gb.description - # gb.update_column(:description, description) - # end - # - # # 毕设选题题库 - # GtopicBank.find_each do |gb| - # description = ke_transform_to_md gb.description - # gb.update_column(:description, description) - # end - # - # # 交流问答 - # Memo.find_each do |m| - # content = ke_transform_to_md m.content - # m.update_column(:content, content) - # end - - end -end diff --git a/db/migrate/20190806063903_third_modify_ke_for_student_work.rb b/db/migrate/20190806063903_third_modify_ke_for_student_work.rb deleted file mode 100644 index 0b1be8d00..000000000 --- a/db/migrate/20190806063903_third_modify_ke_for_student_work.rb +++ /dev/null @@ -1,17 +0,0 @@ -class ThirdModifyKeForStudentWork < ActiveRecord::Migration[5.2] - include ActionView::Helpers::SanitizeHelper - def change - # def ke_transform_to_md content - # return content if content.blank? - # s_contents = sanitize(content, tags: %w(img a span table td tr tbody pre), attributes: %w(src href target style)) - # s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", " ").gsub(/(\n)+/, "
") - # .gsub("\t", "    ").gsub("\n", "").gsub(" ", " ").gsub(/()+/, "
") - # end - # - # # 学生的作品 过滤掉一些描述的ke图片的作品 - # StudentWork.where("description is not null and LENGTH(description) < 1000000").find_each do |sw| - # description = ke_transform_to_md sw.description - # sw.update_column(:description, description) - # end - end -end diff --git a/db/migrate/20190808025851_create_videos.rb b/db/migrate/20190808025851_create_videos.rb deleted file mode 100644 index e7d89f7eb..000000000 --- a/db/migrate/20190808025851_create_videos.rb +++ /dev/null @@ -1,20 +0,0 @@ -class CreateVideos < ActiveRecord::Migration[5.2] - def change - create_table :videos do |t| - t.references :user, index: true, type: :integer - t.string :title - t.string :uuid, comment: 'Aliyun媒体ID' - t.string :cover_url, comment: '视频封面' - t.string :file_url, comment: '视频地址' - - t.string :status - t.string :vod_status, comment: 'Aliyun媒体状态' - - t.datetime :published_at, index: true - - t.timestamps - - t.index :uuid, unique: true - end - end -end diff --git a/db/migrate/20190809010636_create_video_applies.rb b/db/migrate/20190809010636_create_video_applies.rb deleted file mode 100644 index e8b4037c5..000000000 --- a/db/migrate/20190809010636_create_video_applies.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateVideoApplies < ActiveRecord::Migration[5.2] - def change - create_table :video_applies do |t| - t.references :video, index: true, type: :integer - t.string :status - t.string :reason - t.timestamps - end - end -end diff --git a/db/migrate/20190813015633_add_new_column_to_course.rb b/db/migrate/20190813015633_add_new_column_to_course.rb deleted file mode 100644 index cfadc4ce4..000000000 --- a/db/migrate/20190813015633_add_new_column_to_course.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddNewColumnToCourse < ActiveRecord::Migration[5.2] - def change - add_column :courses, :start_date, :date - add_column :courses, :subject_id, :integer, default: 0 - - add_index :courses, :subject_id - end -end diff --git a/db/migrate/20190813074730_add_excellent_to_courses.rb b/db/migrate/20190813074730_add_excellent_to_courses.rb deleted file mode 100644 index c83fcc702..000000000 --- a/db/migrate/20190813074730_add_excellent_to_courses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddExcellentToCourses < ActiveRecord::Migration[5.2] - def change - add_column :courses, :excellent, :boolean, default: false - end -end diff --git a/db/migrate/20190815064542_modify_class_period_for_courses.rb b/db/migrate/20190815064542_modify_class_period_for_courses.rb deleted file mode 100644 index c0f8600b4..000000000 --- a/db/migrate/20190815064542_modify_class_period_for_courses.rb +++ /dev/null @@ -1,8 +0,0 @@ -class ModifyClassPeriodForCourses < ActiveRecord::Migration[5.2] - def change - Course.find_each do |c| - c.update_column(:class_period, c.class_period.to_i) - end - change_column :courses, :class_period, :integer - end -end diff --git a/db/migrate/20190815085136_modify_path_for_challenges.rb b/db/migrate/20190815085136_modify_path_for_challenges.rb deleted file mode 100644 index a17fdbd04..000000000 --- a/db/migrate/20190815085136_modify_path_for_challenges.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ModifyPathForChallenges < ActiveRecord::Migration[5.2] - def change - change_column :challenges, :path, :text - end -end diff --git a/db/migrate/20190819081514_add_filesize_to_videos.rb b/db/migrate/20190819081514_add_filesize_to_videos.rb deleted file mode 100644 index da5b6fb50..000000000 --- a/db/migrate/20190819081514_add_filesize_to_videos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddFilesizeToVideos < ActiveRecord::Migration[5.2] - def change - add_column :videos, :filesize, :integer, default: 0 - end -end diff --git a/db/migrate/20190820021047_migrate_course_task_position.rb b/db/migrate/20190820021047_migrate_course_task_position.rb deleted file mode 100644 index f32ac88b1..000000000 --- a/db/migrate/20190820021047_migrate_course_task_position.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateCourseTaskPosition < ActiveRecord::Migration[5.2] - def change - add_column :homework_commons, :position, :integer, :default => 0 - end -end diff --git a/db/migrate/20190820102040_change_exercise_1930_position.rb b/db/migrate/20190820102040_change_exercise_1930_position.rb deleted file mode 100644 index acf99b9e5..000000000 --- a/db/migrate/20190820102040_change_exercise_1930_position.rb +++ /dev/null @@ -1,29 +0,0 @@ -class ChangeExercise1930Position < ActiveRecord::Migration[5.2] - def change - exs = Exercise.all.includes(:exercise_questions) - exs.each do |ex| - ex_questions = ex&.exercise_questions&.select(:id,:question_number,:exercise_id)&.order("question_number ASC") #试卷的位置迁移 - if ex_questions.present? - ex_questions.each_with_index do |q,index| - puts index - q_num = index + 1 - if q.question_number.to_i != q_num - q.update_attributes(question_number: q_num) - end - end - end - - ex_q_bank = ex&.exercise_bank&.exercise_bank_questions&.select(:id,:question_number,:exercise_bank_id,:shixun_id)&.order("question_number ASC") #试卷的习题库位置迁移 - if ex_q_bank.present? - ex_q_bank.each_with_index do |q,index| - puts index - q_num_1 = index + 1 - if q.question_number.to_i != q_num_1 - q.update_attributes(question_number: q_num_1) - end - end - end - end - - end -end diff --git a/db/migrate/20190821054352_create_open_users.rb b/db/migrate/20190821054352_create_open_users.rb deleted file mode 100644 index f8e0aba4b..000000000 --- a/db/migrate/20190821054352_create_open_users.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateOpenUsers < ActiveRecord::Migration[5.2] - def change - create_table :open_users do |t| - t.references :user - - t.string :type - t.string :uid - - t.timestamps - - t.index [:type, :uid], unique: true - end - end -end diff --git a/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb b/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb deleted file mode 100644 index 9a19b12e3..000000000 --- a/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb +++ /dev/null @@ -1,11 +0,0 @@ -class MigrateCourseShixunHomeworkPosition < ActiveRecord::Migration[5.2] - def change - Course.find_each do |course| - puts course.id - course.practice_homeworks.order("IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC, - homework_commons.created_at DESC").reverse.each_with_index do |homework, index| - homework.update_columns(position: index + 1) - end - end - end -end diff --git a/db/migrate/20190822022306_add_exercise_user_update.rb b/db/migrate/20190822022306_add_exercise_user_update.rb deleted file mode 100644 index 7a8784c30..000000000 --- a/db/migrate/20190822022306_add_exercise_user_update.rb +++ /dev/null @@ -1,39 +0,0 @@ -class AddExerciseUserUpdate < ActiveRecord::Migration[5.2] - - # include ExercisesHelper - # def change - # #2019,8,22添加 - # two_months = Time.now - 2.months - # exs = Exercise.all.is_exercise_published.where("publish_time > ?",two_months).includes(:exercise_questions,:exercise_users) - # exs.each do |ex| - # if ex.exercise_questions.where("created_at < ?",Time.now - 1.month).pluck(:question_type).include?(1) #含有多选题,且是1个月前创建的才更新 - # ex_users = ex.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",two_months) - # if ex_users.exists? - # ex_users.each do |ex_user| - # calculate_score = calculate_student_score(ex,ex_user.user)[:total_score] - # subjective_score = ex_user.subjective_score - # total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - # total_score = calculate_score + total_score_subjective_score - # ex_user.update_attributes(score:total_score,objective_score:calculate_score) - # puts ex_user.id - # end - # end - # end - # end - # - # #1936的试卷成绩有问题。 - # # #https://www.educoder.net/courses/2935/exercises/1936/users/pizfnr5ts - # ex_special = Exercise.find_by_id(1936) - # ex_special_users = ex_special.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",two_months) - # if ex_special.present? && ex_special_users.exists? - # ex_special_users.each do |ex_user| - # calculate_score = calculate_student_score(ex_special,ex_user.user)[:total_score] - # subjective_score = ex_user.subjective_score - # total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - # total_score = calculate_score + total_score_subjective_score - # ex_user.update_attributes(score:total_score,objective_score:calculate_score) - # puts ex_user.id - # end - # end - # end -end diff --git a/db/migrate/20190823015610_add_message_count_for_boards.rb b/db/migrate/20190823015610_add_message_count_for_boards.rb deleted file mode 100644 index 6f121cfc0..000000000 --- a/db/migrate/20190823015610_add_message_count_for_boards.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddMessageCountForBoards < ActiveRecord::Migration[5.2] - def change - boards = Board.where(:parent_id => 0) - Board.reset_column_information - boards.find_each do |board| - Board.reset_counters board.id, :messages - end - end -end diff --git a/db/migrate/20190823024643_modify_course_introduction_for_boards.rb b/db/migrate/20190823024643_modify_course_introduction_for_boards.rb deleted file mode 100644 index 3dfcf09f8..000000000 --- a/db/migrate/20190823024643_modify_course_introduction_for_boards.rb +++ /dev/null @@ -1,42 +0,0 @@ -class ModifyCourseIntroductionForBoards < ActiveRecord::Migration[5.2] - def change - platform = PlatformSample.where(:samples_type => "courseGuide").first - content = '大家好! - -欢迎进入在线课堂! - -该课堂对应于一个或多个线下班级,课堂成员可以利用老师发布的邀请码申请加入。 - -在这里,老师和教辅将结合教学内容,把不同类型的实训项目发布给大家,让大家在真实的实战环境中得到锻炼。 - -那么什么是实训项目呢?大家有空自己尝试一下就知道了: - -- Python实训:[Python程序设计入门](https://www.educoder.net/paths/13) | [大学计算机基础——基于Python](https://www.educoder.net/paths/11) - -- Java实训:[Java语言程序设计(基础篇)](https://www.educoder.net/paths/38) - -- C/C++实训:[C/C++程序设计](https://www.educoder.net/paths/3) | [数据结构与算法(C语言)](https://www.educoder.net/paths/4) - -- Matlab实训:[智取MATLAB:基本语法](https://www.educoder.net/shixuns/7bvs54gw/challenges) | [控制结构](https://www.educoder.net/shixuns/q4fowkfa/challenges) | [矩阵进阶](https://www.educoder.net/shixuns/grunzcs3/challenges) - -- HTML/CSS实训:[HTML5+CSS3网页制作(基础篇)](https://www.educoder.net/paths/15) - -- 云计算实训:[Docker企业级实训(基础篇)](https://www.educoder.net/paths/29) - -... ... 等等 - -你们现在就可以去体验哦! - -欢迎提出宝贵建议,平台一定会给您带来更多惊喜! - - -支持团队' - platform.update_column(:contents, content) - messages = Message.where(subject: "新课导语") - messages.find_each do |m| - m.update_column(:is_md, true) - message_detail = m.message_detail - message_detail.update_column(:content, content) if message_detail - end - end -end diff --git a/db/migrate/20190823063747_modify_contents_for_old_message_details.rb b/db/migrate/20190823063747_modify_contents_for_old_message_details.rb deleted file mode 100644 index 4607881fe..000000000 --- a/db/migrate/20190823063747_modify_contents_for_old_message_details.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ModifyContentsForOldMessageDetails < ActiveRecord::Migration[5.2] - def change - messages = Message.where(subject: "新课导语").where.not(parent_id: 0).where("created_on < '2019-08-23 02:00:00'") - messages.find_each do |m| - m.update_column(:is_md, true) - message_detail = m.message_detail - if message_detail - content = OldMessageDetail.find_by_id(message_detail.id)&.content - message_detail.update_column(:content, content) - end - end - end -end diff --git a/db/migrate/20190823090957_rechange_exercise_1936_scores.rb b/db/migrate/20190823090957_rechange_exercise_1936_scores.rb deleted file mode 100644 index f089714ee..000000000 --- a/db/migrate/20190823090957_rechange_exercise_1936_scores.rb +++ /dev/null @@ -1,19 +0,0 @@ -class RechangeExercise1936Scores < ActiveRecord::Migration[5.2] - include ExercisesHelper - def change - #1936的试卷成绩有问题。 - # #https://www.educoder.net/courses/2935/exercises/1936/users/pizfnr5ts - ex_special = Exercise.find_by_id(1936) - ex_special_users = ex_special&.exercise_users&.exercise_user_committed&.where("end_at is not null and end_at > ?",Time.now - 2.months) - if ex_special.present? && ex_special_users.exists? - ex_special_users.each do |ex_user| - calculate_score = calculate_student_score(ex_special,ex_user.user)[:total_score] - subjective_score = ex_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - ex_user.update_attributes(score:total_score,objective_score:calculate_score) - puts ex_user.id - end - end - end -end diff --git a/db/migrate/20190824032658_migrate_subject_shixun_count.rb b/db/migrate/20190824032658_migrate_subject_shixun_count.rb deleted file mode 100644 index bef29346e..000000000 --- a/db/migrate/20190824032658_migrate_subject_shixun_count.rb +++ /dev/null @@ -1,9 +0,0 @@ -class MigrateSubjectShixunCount < ActiveRecord::Migration[5.2] - def change - Subject.reset_column_information - Subject.all.each do |subject| - Subject.reset_counters subject.id, :stage_shixuns - Subject.reset_counters subject.id, :shixuns - end - end -end diff --git a/db/migrate/20190827055814_modify_challnege_score_for_choose.rb b/db/migrate/20190827055814_modify_challnege_score_for_choose.rb deleted file mode 100644 index 7b96877e3..000000000 --- a/db/migrate/20190827055814_modify_challnege_score_for_choose.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ModifyChallnegeScoreForChoose < ActiveRecord::Migration[5.2] - def change - challenges = Challenge.where(st: 1) - challenges.find_each do |c| - puts(c.id) - score = c.challenge_chooses.sum(:score) - c.update_column(:score, score) - end - end -end diff --git a/db/migrate/20190828011222_add_update_user_id_to_student_works.rb b/db/migrate/20190828011222_add_update_user_id_to_student_works.rb deleted file mode 100644 index c8e007998..000000000 --- a/db/migrate/20190828011222_add_update_user_id_to_student_works.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddUpdateUserIdToStudentWorks < ActiveRecord::Migration[5.2] - def change - add_column :student_works, :update_user_id, :integer - StudentWork.update_all("update_user_id = commit_user_id") - end -end diff --git a/db/migrate/20190828055710_add_is_ordered_to_exercise_bank_question.rb b/db/migrate/20190828055710_add_is_ordered_to_exercise_bank_question.rb deleted file mode 100644 index 967d89e5f..000000000 --- a/db/migrate/20190828055710_add_is_ordered_to_exercise_bank_question.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIsOrderedToExerciseBankQuestion < ActiveRecord::Migration[5.2] - def change - add_column :exercise_bank_questions, :is_ordered, :boolean, :default => true - end -end diff --git a/db/migrate/20190829025855_migrate_gtopic_bank_is_public.rb b/db/migrate/20190829025855_migrate_gtopic_bank_is_public.rb deleted file mode 100644 index c267284a0..000000000 --- a/db/migrate/20190829025855_migrate_gtopic_bank_is_public.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateGtopicBankIsPublic < ActiveRecord::Migration[5.2] - def change - change_column :gtopic_banks, :is_public, :boolean, default: 0 - end -end diff --git a/db/migrate/20190829084147_migrate_course_group_position.rb b/db/migrate/20190829084147_migrate_course_group_position.rb deleted file mode 100644 index 3a71baae4..000000000 --- a/db/migrate/20190829084147_migrate_course_group_position.rb +++ /dev/null @@ -1,11 +0,0 @@ -class MigrateCourseGroupPosition < ActiveRecord::Migration[5.2] - def change - Course.all.each do |course| - if course.course_groups.exists?(position: 0) - course.course_groups.each_with_index do |group, index| - group.update_attributes(position: index+1) - end - end - end - end -end diff --git a/db/migrate/20190830064803_add_announcement_to_course_modules.rb b/db/migrate/20190830064803_add_announcement_to_course_modules.rb deleted file mode 100644 index 5f4d1eeb9..000000000 --- a/db/migrate/20190830064803_add_announcement_to_course_modules.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddAnnouncementToCourseModules < ActiveRecord::Migration[5.2] - def change - Course.all.each do |course| - unless course.course_modules.exists?(module_type: "announcement") - course.course_modules.where.not(module_type: "activity").update_all("position = position + 1") - course.course_modules << CourseModule.new(module_type: "announcement", hidden: 1, module_name: "公告栏", position: 2) - end - end - end -end diff --git a/db/migrate/20190830082934_add_tag_to_libraries.rb b/db/migrate/20190830082934_add_tag_to_libraries.rb deleted file mode 100644 index ea40cda5d..000000000 --- a/db/migrate/20190830082934_add_tag_to_libraries.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTagToLibraries < ActiveRecord::Migration[5.2] - def change - execute "insert into library_tags(name) values('企业案例')" - end -end diff --git a/db/migrate/20190831014325_migrate_poll_bank_question.rb b/db/migrate/20190831014325_migrate_poll_bank_question.rb deleted file mode 100644 index cd9168a73..000000000 --- a/db/migrate/20190831014325_migrate_poll_bank_question.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MigratePollBankQuestion < ActiveRecord::Migration[5.2] - def change - ExerciseBankQuestion.where(question_type: 0, exercise_bank_id: ExerciseBank.where(container_type: 'Poll').pluck(:id)).update_all(question_type: 1) - ExerciseBankQuestion.where(question_type: 1, exercise_bank_id: ExerciseBank.where(container_type: 'Poll').pluck(:id)).update_all(question_type: 2) - end -end diff --git a/db/migrate/20190902062449_migrate_excellent_course_course_list.rb b/db/migrate/20190902062449_migrate_excellent_course_course_list.rb deleted file mode 100644 index a93db7695..000000000 --- a/db/migrate/20190902062449_migrate_excellent_course_course_list.rb +++ /dev/null @@ -1,12 +0,0 @@ -class MigrateExcellentCourseCourseList < ActiveRecord::Migration[5.2] - def change - courses = Course.where(excellent: true) - courses.each do |course| - if !course.course_list.present? && course.subject - subject = course.subject - course_list = CourseList.find_by(name: subject.name) || CourseList.create!(name: subject.name, user_id: course.tea_id, is_admin: 0) - course.update_attributes(course_list_id: course_list.id) - end - end - end -end diff --git a/db/migrate/20190903022313_add_graduation_work_id_to_group_assignations.rb b/db/migrate/20190903022313_add_graduation_work_id_to_group_assignations.rb deleted file mode 100644 index e1db275fb..000000000 --- a/db/migrate/20190903022313_add_graduation_work_id_to_group_assignations.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddGraduationWorkIdToGroupAssignations < ActiveRecord::Migration[5.2] - def change - add_column :graduation_task_group_assignations, :graduation_work_id, :integer, default: 0 - - add_index :graduation_task_group_assignations, :graduation_work_id - end -end diff --git a/db/migrate/20190903025159_add_temporary_to_graduation.rb b/db/migrate/20190903025159_add_temporary_to_graduation.rb deleted file mode 100644 index adf7e1aa3..000000000 --- a/db/migrate/20190903025159_add_temporary_to_graduation.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTemporaryToGraduation < ActiveRecord::Migration[5.2] - def change - add_column :graduation_task_group_assignations, :temporary, :integer, default: 0 - add_column :graduation_work_comment_assignations, :temporary, :integer, default: 0 - end -end diff --git a/db/migrate/20190905070518_reorder_coo_img_position.rb b/db/migrate/20190905070518_reorder_coo_img_position.rb deleted file mode 100644 index 1aa8a6842..000000000 --- a/db/migrate/20190905070518_reorder_coo_img_position.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ReorderCooImgPosition < ActiveRecord::Migration[5.2] - def change - CooImg.all.group_by(&:img_type).each do |_type, objs| - objs.sort_by(&:position).each_with_index do |obj, index| - obj.update!(position: index + 1) - end - end - end -end diff --git a/db/migrate/20190905070821_change_public_model_default_value.rb b/db/migrate/20190905070821_change_public_model_default_value.rb deleted file mode 100644 index 09d4af61a..000000000 --- a/db/migrate/20190905070821_change_public_model_default_value.rb +++ /dev/null @@ -1,20 +0,0 @@ -class ChangePublicModelDefaultValue < ActiveRecord::Migration[5.2] - def change - #试卷的默认值的修改 - change_column_default :exercises,:show_result,0 - change_column_default :exercises, :answer_open, false - change_column_default :exercises, :score_open, false - - #问卷的默认值的修改 - change_column_default :polls, :show_result, 0 - - #实训作业/普通作业/分组作业 - change_column_default :homework_commons, :score_open, false - change_column_default :homework_commons, :work_public, false - change_column_default :homework_commons, :answer_public, false - - #毕设任务 - change_column_default :graduation_tasks, :open_score, false - change_column_default :graduation_tasks, :open_work, false - end -end diff --git a/db/migrate/20190906062930_modify_is_test_for_user.rb b/db/migrate/20190906062930_modify_is_test_for_user.rb deleted file mode 100644 index f3f5bfd3b..000000000 --- a/db/migrate/20190906062930_modify_is_test_for_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ModifyIsTestForUser < ActiveRecord::Migration[5.2] - def change - change_column :users, :is_test, :integer, :limit => 1 - end -end diff --git a/db/migrate/20190906111746_gtopic_bank_is_public.rb b/db/migrate/20190906111746_gtopic_bank_is_public.rb deleted file mode 100644 index 193824dc4..000000000 --- a/db/migrate/20190906111746_gtopic_bank_is_public.rb +++ /dev/null @@ -1,5 +0,0 @@ -class GtopicBankIsPublic < ActiveRecord::Migration[5.2] - def change - GtopicBank.where(is_public: nil).update_all(is_public: 0) - end -end diff --git a/db/migrate/20190907014649_add_vnc_evaluate_for_shixuns.rb b/db/migrate/20190907014649_add_vnc_evaluate_for_shixuns.rb deleted file mode 100644 index 861c4501e..000000000 --- a/db/migrate/20190907014649_add_vnc_evaluate_for_shixuns.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddVncEvaluateForShixuns < ActiveRecord::Migration[5.2] - def change - add_column :shixuns, :vnc_evaluate, :boolean, default: false - end -end diff --git a/db/migrate/20190907021100_migrate_bank_reference_id.rb b/db/migrate/20190907021100_migrate_bank_reference_id.rb deleted file mode 100644 index c71034167..000000000 --- a/db/migrate/20190907021100_migrate_bank_reference_id.rb +++ /dev/null @@ -1,31 +0,0 @@ -class MigrateBankReferenceId < ActiveRecord::Migration[5.2] - def change - HomeworkBank.all.each do |bank| - if bank.homework_common - bank.homework_common.update_column("homework_bank_id", bank.id) if bank.homework_common.homework_bank_id.nil? - end - end - - GtopicBank.all.each do |bank| - if bank.graduation_topic - bank.graduation_topic.update_column("gtopic_bank_id", bank.id) if bank.graduation_topic.gtopic_bank_id.nil? - end - end - - GtaskBank.all.each do |bank| - if bank.graduation_task - bank.graduation_task.update_column("gtask_bank_id", bank.id) if bank.graduation_task.gtask_bank_id.nil? - end - end - - ExerciseBank.all.each do |bank| - if bank.container_type == 'Exercise' - exercise = Exercise.find_by(id: bank.container_id) - exercise.update_column("exercise_bank_id", bank.id) if exercise && exercise.exercise_bank_id.nil? - elsif bank.container_type == 'Poll' - poll = Poll.find_by(id: bank.container_id) - poll.update_column("exercise_bank_id", bank.id) if poll && poll.exercise_bank_id.nil? - end - end - end -end diff --git a/db/migrate/20190907061918_migrate_bank_quotes.rb b/db/migrate/20190907061918_migrate_bank_quotes.rb deleted file mode 100644 index 9f278860d..000000000 --- a/db/migrate/20190907061918_migrate_bank_quotes.rb +++ /dev/null @@ -1,28 +0,0 @@ -class MigrateBankQuotes < ActiveRecord::Migration[5.2] - def change - HomeworkBank.all.each do |bank| - task_count = bank.homework_commons.count - bank.update_column("quotes", task_count == 0 ? 1 : task_count) - end - - GtopicBank.all.each do |bank| - task_count = bank.graduation_topics.count - bank.update_column("quotes", task_count == 0 ? 1 : task_count) - end - - GtaskBank.all.each do |bank| - task_count = bank.graduation_tasks.count - bank.update_column("quotes", task_count == 0 ? 1 : task_count) - end - - ExerciseBank.all.each do |bank| - if bank.container_type == 'Exercise' - task_count = bank.exercises.count - bank.update_column("quotes", task_count == 0 ? 1 : task_count) - elsif bank.container_type == 'Poll' - task_count = bank.polls.count - bank.update_column("quotes", task_count == 0 ? 1 : task_count) - end - end - end -end diff --git a/db/migrate/20190909061930_create_shixun_secret_repositories.rb b/db/migrate/20190909061930_create_shixun_secret_repositories.rb deleted file mode 100644 index 5526869f8..000000000 --- a/db/migrate/20190909061930_create_shixun_secret_repositories.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateShixunSecretRepositories < ActiveRecord::Migration[5.2] - def change - create_table :shixun_secret_repositories do |t| - t.references :shixun - t.string :repo_name - t.string :secret_dir_path - t.timestamps - end - end -end diff --git a/db/migrate/20190909072626_add_match_rule_for_test_sets.rb b/db/migrate/20190909072626_add_match_rule_for_test_sets.rb deleted file mode 100644 index 2d9d53f0f..000000000 --- a/db/migrate/20190909072626_add_match_rule_for_test_sets.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddMatchRuleForTestSets < ActiveRecord::Migration[5.2] - def change - add_column :test_sets, :match_rule, :string - TestSet.update_all(match_rule: 'full') - - end -end diff --git a/db/migrate/20190909080508_create_shixun_work_comments.rb b/db/migrate/20190909080508_create_shixun_work_comments.rb deleted file mode 100644 index eb21f0d04..000000000 --- a/db/migrate/20190909080508_create_shixun_work_comments.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateShixunWorkComments < ActiveRecord::Migration[5.2] - def change - create_table :shixun_work_comments do |t| - t.references :student_work, index: true, type: :integer - t.references :challenge, index: true, type: :integer, default: 0 - t.references :user, index: true, type: :integer - t.text :comment - t.text :hidden_comment - - t.timestamps - end - end -end diff --git a/db/migrate/20190909082555_migrate_shixun_work_comment.rb b/db/migrate/20190909082555_migrate_shixun_work_comment.rb deleted file mode 100644 index f58531b80..000000000 --- a/db/migrate/20190909082555_migrate_shixun_work_comment.rb +++ /dev/null @@ -1,13 +0,0 @@ -class MigrateShixunWorkComment < ActiveRecord::Migration[5.2] - def change - StudentWorksScore.where(is_ultimate: 0, score: nil).where("created_at > '2019-09-04 00:00:00'").each do |work_score| - if work_score.student_work && work_score.student_work.homework_common&.shixuns - if work_score.is_hidden - ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, hidden_comment: work_score.comment) - else - ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, comment: work_score.comment) - end - end - end - end -end diff --git a/db/migrate/20190910061807_create_course_stages.rb b/db/migrate/20190910061807_create_course_stages.rb deleted file mode 100644 index c664b7f92..000000000 --- a/db/migrate/20190910061807_create_course_stages.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateCourseStages < ActiveRecord::Migration[5.2] - def change - create_table :course_stages do |t| - t.references :course, index: true - t.string :name - t.text :description - t.integer :position - t.integer :shixuns_count - - t.timestamps - end - end -end diff --git a/db/migrate/20190910062710_create_course_stage_shixuns.rb b/db/migrate/20190910062710_create_course_stage_shixuns.rb deleted file mode 100644 index 04512c7da..000000000 --- a/db/migrate/20190910062710_create_course_stage_shixuns.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateCourseStageShixuns < ActiveRecord::Migration[5.2] - def change - create_table :course_stage_shixuns do |t| - t.references :course, index: true - t.references :course_stage, index: true - t.references :shixun, index: true - t.integer :position - - t.timestamps - end - end -end diff --git a/db/migrate/20190910063345_migrate_course_stages.rb b/db/migrate/20190910063345_migrate_course_stages.rb deleted file mode 100644 index 0aae05103..000000000 --- a/db/migrate/20190910063345_migrate_course_stages.rb +++ /dev/null @@ -1,14 +0,0 @@ -class MigrateCourseStages < ActiveRecord::Migration[5.2] - def change - Course.where(excellent: 1).each do |course| - if course.subject - course.subject.stages.each do |stage| - new_stage = CourseStage.create!(course_id: course.id, name: stage.name, description: stage.description, position: stage.position) - stage.stage_shixuns.each do |stage_shixun| - CourseStageShixun.create!(course_id: course.id, course_stage_id: new_stage.id, shixun_id: stage_shixun.shixun_id, position: stage_shixun.position) - end - end - end - end - end -end diff --git a/db/migrate/20190911020749_migrate_shixun_student_work.rb b/db/migrate/20190911020749_migrate_shixun_student_work.rb deleted file mode 100644 index 54474c544..000000000 --- a/db/migrate/20190911020749_migrate_shixun_student_work.rb +++ /dev/null @@ -1,18 +0,0 @@ -class MigrateShixunStudentWork < ActiveRecord::Migration[5.2] - def change - homework_commons = HomeworkCommon.where(homework_type: 4).where("created_at > '2019-07-01 00:00:00'") - attrs = %i[homework_common_id user_id created_at updated_at] - StudentWork.bulk_insert(*attrs) do |worker| - homework_commons.each do |homework| - course = homework.course - if course && homework.student_works.count != course.students.count - course.students.each do |student| - next if StudentWork.where(homework_common_id: homework.id, user_id: student.user_id).any? - same_attrs = {user_id: student.user_id} - worker.add same_attrs.merge(homework_common_id: homework.id) - end - end - end - end - end -end diff --git a/db/migrate/20190911074019_add_code_edit_permission_for_shixun.rb b/db/migrate/20190911074019_add_code_edit_permission_for_shixun.rb deleted file mode 100644 index 801713e0e..000000000 --- a/db/migrate/20190911074019_add_code_edit_permission_for_shixun.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCodeEditPermissionForShixun < ActiveRecord::Migration[5.2] - def change - - add_column :shixuns, :code_edit_permission, :boolean, default: false - end -end diff --git a/db/migrate/20190911080150_change_ec_course_supports.rb b/db/migrate/20190911080150_change_ec_course_supports.rb deleted file mode 100644 index 07c3a536d..000000000 --- a/db/migrate/20190911080150_change_ec_course_supports.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ChangeEcCourseSupports < ActiveRecord::Migration[5.2] - def change - add_column :ec_course_supports, :ec_graduation_subitem_id, :integer, index: true - - execute <<-SQL - UPDATE ec_course_supports ecs SET ec_graduation_subitem_id = ( - SELECT ec_graduation_subitem_id FROM ec_graduation_subitem_courses egsc WHERE egsc.ec_course_support_id = ecs.id - ) - SQL - end -end diff --git a/db/migrate/20190911103449_migrate_grade_index.rb b/db/migrate/20190911103449_migrate_grade_index.rb deleted file mode 100644 index 0128619fa..000000000 --- a/db/migrate/20190911103449_migrate_grade_index.rb +++ /dev/null @@ -1,7 +0,0 @@ -class MigrateGradeIndex < ActiveRecord::Migration[5.2] - def change - remove_index :grades, [:user_id, :container_id] - add_index :grades, [:container_id, :container_type] - add_index :grades, [:user_id] - end -end diff --git a/db/migrate/20190917024120_migrate_graduation_task_comment_status.rb b/db/migrate/20190917024120_migrate_graduation_task_comment_status.rb deleted file mode 100644 index 3b3a3fccc..000000000 --- a/db/migrate/20190917024120_migrate_graduation_task_comment_status.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateGraduationTaskCommentStatus < ActiveRecord::Migration[5.2] - def change - GraduationTask.where(cross_comment: true, comment_status: 0).update_all(comment_status: 2) - end -end diff --git a/db/migrate/20190920073337_migrate_user_extension_index.rb b/db/migrate/20190920073337_migrate_user_extension_index.rb deleted file mode 100644 index 1d333bd99..000000000 --- a/db/migrate/20190920073337_migrate_user_extension_index.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MigrateUserExtensionIndex < ActiveRecord::Migration[5.2] - def change - remove_index :user_extensions, :school_id - add_index :user_extensions, [:school_id, :user_id] - end -end diff --git a/db/migrate/20190921010411_add_course_member_to_subjects.rb b/db/migrate/20190921010411_add_course_member_to_subjects.rb deleted file mode 100644 index 76df05604..000000000 --- a/db/migrate/20190921010411_add_course_member_to_subjects.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCourseMemberToSubjects < ActiveRecord::Migration[5.2] - def change - add_column :subjects, :student_count, :integer, :default => 0 - add_column :subjects, :participant_count, :integer, :default => 0 - end -end diff --git a/db/migrate/20190921015840_create_subject_appointments.rb b/db/migrate/20190921015840_create_subject_appointments.rb deleted file mode 100644 index 68c924de7..000000000 --- a/db/migrate/20190921015840_create_subject_appointments.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateSubjectAppointments < ActiveRecord::Migration[5.2] - def change - create_table :subject_appointments do |t| - t.references :subject, index: true - t.references :user, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20190923094220_add_update_user_id_to_graduation_works.rb b/db/migrate/20190923094220_add_update_user_id_to_graduation_works.rb deleted file mode 100644 index 718c6adde..000000000 --- a/db/migrate/20190923094220_add_update_user_id_to_graduation_works.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddUpdateUserIdToGraduationWorks < ActiveRecord::Migration[5.2] - def change - add_column :graduation_works, :update_user_id, :integer - GraduationWork.update_all("update_user_id = commit_user_id") - end -end diff --git a/db/migrate/20190926024819_add_library_tag_data.rb b/db/migrate/20190926024819_add_library_tag_data.rb deleted file mode 100644 index b2b40bbf5..000000000 --- a/db/migrate/20190926024819_add_library_tag_data.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddLibraryTagData < ActiveRecord::Migration[5.2] - def up - execute 'INSERT INTO library_tags(id, name) VALUES(4, "高校案例")' - end - - def down - execute 'DELETE FROM library_tags WHERE id = 4 and name = "高校案例"' - end -end diff --git a/db/migrate/20190927091948_change_user_p02389416_exercise.rb b/db/migrate/20190927091948_change_user_p02389416_exercise.rb deleted file mode 100644 index c4026f75b..000000000 --- a/db/migrate/20190927091948_change_user_p02389416_exercise.rb +++ /dev/null @@ -1,33 +0,0 @@ -class ChangeUserP02389416Exercise < ActiveRecord::Migration[5.2] - def change - puts "====> start_to_create user exercise_answer" - - #分别为第8,11,14,15,16,20,21,26 - # 分数分别为:2分,2分,5分,2分,2分,2分,2分,2分 合计19分 - question_ids = [37411,37414,37417,37418,37419,37423,37424,37429] - choice_ids = [117788,117797,117806,117809,117811,117816,117818,117828] - question_scores = [2,2,5,2,2,2,2,2] - question_ids.each_with_index do |q, index| - ex_exercise_user = ExerciseAnswer.where(user_id: 45442, exercise_question_id: q, exercise_choice_id: choice_ids[index]) - if ex_exercise_user.exists? - ex_exercise_user.first.update_attribute(:score,question_scores[index]) - else - ExerciseAnswer.create(user_id: 45442, exercise_question_id: q, exercise_choice_id: choice_ids[index], score: question_scores[index]) - end - end - ex_user = ExerciseUser.where(user_id: 45442, exercise_id: 2561)&.first - if ex_user.present? - if ex_user.score > 65 || ex_user.objective_score > 65 - ex_user.update_attributes(score: 65, objective_score: 65) - else - obj_score = ex_user.objective_score.to_i + 19 - total_score = ex_user.score.to_i + 19 - - ex_user.update_attributes(score: total_score, objective_score: obj_score) - end - - end - - puts "====> end_to_create user exercise_answer" - end -end diff --git a/db/migrate/20190930020534_migrate_forum_name.rb b/db/migrate/20190930020534_migrate_forum_name.rb deleted file mode 100644 index 102d8c9a0..000000000 --- a/db/migrate/20190930020534_migrate_forum_name.rb +++ /dev/null @@ -1,9 +0,0 @@ -class MigrateForumName < ActiveRecord::Migration[5.2] - def change - forum = Forum.find_by(id: 16) - if forum.present? - forum.update_attributes(name: "通知公告") - forum.memos.destroy_all - end - end -end diff --git a/db/migrate/20190930032241_create_diff_records.rb b/db/migrate/20190930032241_create_diff_records.rb deleted file mode 100644 index 3e02e0a2b..000000000 --- a/db/migrate/20190930032241_create_diff_records.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateDiffRecords < ActiveRecord::Migration[5.2] - def change - create_table :diff_records do |t| - t.references :user - t.references :container, polymorphic: true - t.string :column_name - - t.timestamps - end - end -end diff --git a/db/migrate/20190930032255_create_diff_record_contents.rb b/db/migrate/20190930032255_create_diff_record_contents.rb deleted file mode 100644 index f3d56b8b2..000000000 --- a/db/migrate/20190930032255_create_diff_record_contents.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateDiffRecordContents < ActiveRecord::Migration[5.2] - def change - create_table :diff_record_contents do |t| - t.references :diff_record - - t.text :content - end - end -end diff --git a/db/migrate/20191007010405_resort_portal_image_data.rb b/db/migrate/20191007010405_resort_portal_image_data.rb deleted file mode 100644 index 665b48466..000000000 --- a/db/migrate/20191007010405_resort_portal_image_data.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ResortPortalImageData < ActiveRecord::Migration[5.2] - def change - PortalImage.order(position: :asc).each_with_index do |image, index| - image.update!(position: index + 1) - end - end -end diff --git a/db/migrate/20191010011844_create_laboratories.rb b/db/migrate/20191010011844_create_laboratories.rb deleted file mode 100644 index 3dfb442f0..000000000 --- a/db/migrate/20191010011844_create_laboratories.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateLaboratories < ActiveRecord::Migration[5.2] - def change - create_table :laboratories do |t| - t.references :school - t.string :identifier - - t.timestamps - - t.index :identifier, unique: true - end - end -end diff --git a/db/migrate/20191010012226_create_laboratory_users.rb b/db/migrate/20191010012226_create_laboratory_users.rb deleted file mode 100644 index 1b7ae762d..000000000 --- a/db/migrate/20191010012226_create_laboratory_users.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateLaboratoryUsers < ActiveRecord::Migration[5.2] - def change - create_table :laboratory_users do |t| - t.references :laboratory - t.references :user - end - end -end diff --git a/db/migrate/20191010063403_create_laboratory_settings.rb b/db/migrate/20191010063403_create_laboratory_settings.rb deleted file mode 100644 index 7f0a5f015..000000000 --- a/db/migrate/20191010063403_create_laboratory_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateLaboratorySettings < ActiveRecord::Migration[5.2] - def change - create_table :laboratory_settings do |t| - t.references :laboratory - - t.text :config - end - end -end diff --git a/db/migrate/20191011025619_init_edu_coder_laboratory.rb b/db/migrate/20191011025619_init_edu_coder_laboratory.rb deleted file mode 100644 index 831ca3985..000000000 --- a/db/migrate/20191011025619_init_edu_coder_laboratory.rb +++ /dev/null @@ -1,22 +0,0 @@ -class InitEduCoderLaboratory < ActiveRecord::Migration[5.2] - def change - ActiveRecord::Base.transaction do - laboratory = Laboratory.create!(id: 1, identifier: 'www') - setting = laboratory.build_laboratory_setting - footer = %Q{ - - } - config = setting.class.default_config.merge(name: 'EduCoder', footer: footer) - setting.config = config - setting.save! - end - end -end diff --git a/db/migrate/20191011030441_add_commit_method_to_exercise_user.rb b/db/migrate/20191011030441_add_commit_method_to_exercise_user.rb deleted file mode 100644 index 060e5eb5f..000000000 --- a/db/migrate/20191011030441_add_commit_method_to_exercise_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCommitMethodToExerciseUser < ActiveRecord::Migration[5.2] - def change - add_column :exercise_users, :commit_method, :integer, :default => 0 - end -end diff --git a/db/migrate/20191014061301_migrate_course_atta.rb b/db/migrate/20191014061301_migrate_course_atta.rb deleted file mode 100644 index 04d085c0d..000000000 --- a/db/migrate/20191014061301_migrate_course_atta.rb +++ /dev/null @@ -1,7 +0,0 @@ -class MigrateCourseAtta < ActiveRecord::Migration[5.2] - def change - add_column :attachments, :delay_publish, :boolean, default: 0 - - Attachment.where(container_type: "Course").where(is_publish: 0).where("publish_time > '#{(Time.now).strftime("%Y-%m-%d %H:%M:%S")}'").update_all(delay_publish: 1) - end -end diff --git a/db/migrate/20191015013924_add_new_column_to_competitions.rb b/db/migrate/20191015013924_add_new_column_to_competitions.rb deleted file mode 100644 index 616a46059..000000000 --- a/db/migrate/20191015013924_add_new_column_to_competitions.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddNewColumnToCompetitions < ActiveRecord::Migration[5.2] - def change - add_column :competitions, :bonus, :integer, default: 0 - add_column :competitions, :mode, :integer, default: 0 - end -end diff --git a/db/migrate/20191015015723_create_competition_mode_settings.rb b/db/migrate/20191015015723_create_competition_mode_settings.rb deleted file mode 100644 index 5d170eeab..000000000 --- a/db/migrate/20191015015723_create_competition_mode_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateCompetitionModeSettings < ActiveRecord::Migration[5.2] - def change - create_table :competition_mode_settings do |t| - t.references :course - t.datetime :start_time - t.datetime :end_time - - t.timestamps - end - end -end diff --git a/db/migrate/20191016070842_add_description_to_competitions.rb b/db/migrate/20191016070842_add_description_to_competitions.rb deleted file mode 100644 index 268d7b8fc..000000000 --- a/db/migrate/20191016070842_add_description_to_competitions.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddDescriptionToCompetitions < ActiveRecord::Migration[5.2] - def change - add_column :competitions, :description, :text - add_column :competitions, :introduction, :text - end -end diff --git a/db/migrate/20191016075036_add_laboratory_id_to_portal_images.rb b/db/migrate/20191016075036_add_laboratory_id_to_portal_images.rb deleted file mode 100644 index af818756c..000000000 --- a/db/migrate/20191016075036_add_laboratory_id_to_portal_images.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddLaboratoryIdToPortalImages < ActiveRecord::Migration[5.2] - def change - add_column :portal_images, :laboratory_id, :bigint - add_index :portal_images, :laboratory_id - - execute 'UPDATE portal_images SET laboratory_id = 1' - end -end diff --git a/db/migrate/20191017024643_add_extra_to_open_users.rb b/db/migrate/20191017024643_add_extra_to_open_users.rb deleted file mode 100644 index b2e38c427..000000000 --- a/db/migrate/20191017024643_add_extra_to_open_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddExtraToOpenUsers < ActiveRecord::Migration[5.2] - def change - add_column :open_users, :extra, :text - end -end diff --git a/db/migrate/20191017063840_add_competition_id_to_mode_setting.rb b/db/migrate/20191017063840_add_competition_id_to_mode_setting.rb deleted file mode 100644 index ef68d395b..000000000 --- a/db/migrate/20191017063840_add_competition_id_to_mode_setting.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddCompetitionIdToModeSetting < ActiveRecord::Migration[5.2] - def change - add_column :competition_mode_settings, :competition_id, :integer - - add_index :competition_mode_settings, :competition_id - end -end diff --git a/db/migrate/20191017092449_migrate_competition_score.rb b/db/migrate/20191017092449_migrate_competition_score.rb deleted file mode 100644 index 095f403c5..000000000 --- a/db/migrate/20191017092449_migrate_competition_score.rb +++ /dev/null @@ -1,29 +0,0 @@ -class MigrateCompetitionScore < ActiveRecord::Migration[5.2] - def change - CompetitionModule.where(name: "排行榜", hidden: 0).each do |com_module| - competition = com_module.competition - if competition.present? - puts competition.id - if competition.identifier == 'hn' || competition.identifier == 'gcc-task-2019' - p_rate = 0.2 - f_rate = 0.8 - else - p_rate = 0.15 - f_rate = 0.85 - end - pre_stage = competition.competition_stages.where(:name => "预赛").first - final_stage = competition.competition_stages.where(:name => "决赛").first - - competition.competition_teams.each do |team| - f_score = team.competition_scores.where(:competition_stage_id => final_stage.try(:id)).first - # 预赛记录 - p_score = team.competition_scores.where(:competition_stage_id => pre_stage.try(:id)).first - s_score = (f_score.try(:score).to_f * f_rate + p_score.try(:score).to_f * p_rate).try(:round, 2) - s_spend_time = f_score.try(:cost_time).to_i + p_score.try(:cost_time).to_i - CompetitionScore.create(:user_id => team.user_id, :competition_team_id => team.id, :competition_id => competition.id, - :competition_stage_id => 0, :score => s_score, :cost_time => s_spend_time) - end - end - end - end -end diff --git a/db/migrate/20191018015007_create_shixun_reviews.rb b/db/migrate/20191018015007_create_shixun_reviews.rb deleted file mode 100644 index 2349e72f4..000000000 --- a/db/migrate/20191018015007_create_shixun_reviews.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateShixunReviews < ActiveRecord::Migration[5.2] - def change - create_table :shixun_reviews do |t| - t.references :user - t.references :shixun - t.string :evaluate_content - t.integer :status - t.string :review_type - t.timestamps - end - end -end diff --git a/db/migrate/20191018022821_create_competition_awards.rb b/db/migrate/20191018022821_create_competition_awards.rb deleted file mode 100644 index 9da6068ce..000000000 --- a/db/migrate/20191018022821_create_competition_awards.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateCompetitionAwards < ActiveRecord::Migration[5.2] - def change - create_table :competition_awards do |t| - t.references :competition, index: true - t.string :name - t.integer :num, default: 0 - t.integer :award_type, default: 0 - - t.timestamps - end - end -end diff --git a/db/migrate/20191018030029_add_rate_to_competition_stage.rb b/db/migrate/20191018030029_add_rate_to_competition_stage.rb deleted file mode 100644 index 6e819cc17..000000000 --- a/db/migrate/20191018030029_add_rate_to_competition_stage.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRateToCompetitionStage < ActiveRecord::Migration[5.2] - def change - add_column :competition_stages, :rate, :float, default: 1.0 - end -end diff --git a/db/migrate/20191019075105_create_module_settings.rb b/db/migrate/20191019075105_create_module_settings.rb deleted file mode 100644 index 85e3ddb9f..000000000 --- a/db/migrate/20191019075105_create_module_settings.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateModuleSettings < ActiveRecord::Migration[5.2] - def change - create_table :module_settings do |t| - t.string :module_type - t.string :property - - t.timestamps - end - - add_index :module_settings, :module_type - end -end diff --git a/db/migrate/20191019082903_change_column_competition_stage.rb b/db/migrate/20191019082903_change_column_competition_stage.rb deleted file mode 100644 index a9942ec08..000000000 --- a/db/migrate/20191019082903_change_column_competition_stage.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeColumnCompetitionStage < ActiveRecord::Migration[5.2] - def change - rename_column :competition_stages, :rate, :score_rate - end -end diff --git a/db/migrate/20191021141738_migrate_exercise_challenge_score.rb b/db/migrate/20191021141738_migrate_exercise_challenge_score.rb deleted file mode 100644 index 6d67398db..000000000 --- a/db/migrate/20191021141738_migrate_exercise_challenge_score.rb +++ /dev/null @@ -1,25 +0,0 @@ -class MigrateExerciseChallengeScore < ActiveRecord::Migration[5.2] - include ExercisesHelper - def change - exercise = Exercise.find_by(id: 2734) - if exercise - exercise.exercise_users.where("start_at is not null").each do |exercise_user| - if exercise_user.end_at.nil? - calculate_score = calculate_student_score(exercise, exercise_user.user)[:total_score] - subjective_score = exercise_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3) - puts exercise_user.id - else - calculate_score = ExerciseShixunAnswer.where(user_id: exercise_user.user_id, exercise_question_id: exercise.exercise_questions.pluck(:id)).pluck(:score).sum - subjective_score = exercise_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score) if total_score > exercise_user.score - puts exercise_user.id - end - end - end - end -end diff --git a/db/migrate/20191021150220_migrate_exercise_answer_score.rb b/db/migrate/20191021150220_migrate_exercise_answer_score.rb deleted file mode 100644 index aa209bc4a..000000000 --- a/db/migrate/20191021150220_migrate_exercise_answer_score.rb +++ /dev/null @@ -1,110 +0,0 @@ -class MigrateExerciseAnswerScore < ActiveRecord::Migration[5.2] - def challenge_path(path) - cha_path = path.present? ? path.split(";") : [] - cha_path.reject(&:blank?)[0].try(:strip) - end - - # 版本库文件内容,带转码 - def git_fle_content(repo_path, path) - begin - Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}") - - content = GitService.file_content(repo_path: repo_path, path: path) - - Rails.logger.info("git file content: content is #{content}") - decode_content = nil - if content.present? - content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass - - content = Base64.decode64(content) - cd = CharDet.detect(content) - Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" - # 字符编码问题,GB18030编码识别率不行 - decode_content = - if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8 - content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '}) - else - content.force_encoding('UTF-8') - end - end - - decode_content - - rescue Exception => e - Rails.logger.error(e.message) - raise Educoder::TipException.new("文档内容获取异常") - end - end - - def calculate_student_score(exercise,user) - score5 = 0.0 #实训题 - exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers,:exercise_shixun_challenges) - exercise_questions.each do |q| - if q.question_type == 5 - q.exercise_shixun_challenges.each do |exercise_cha| - game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡 - if game.present? - exercise_cha_score = 0.0 - answer_status = 0 - # if game.status == 2 && game.final_score >= 0 - if game.final_score > 0 && game.end_time < exercise.end_time - exercise_cha_score = game.real_score(exercise_cha.question_score) - # exercise_cha_score = exercise_cha.question_score #每一关卡的得分 - answer_status = 1 - end - ex_shixun_answer_content = exercise_cha.exercise_shixun_answers.where(user_id:user.id,exercise_question_id:q.id) - code = nil - if exercise_cha.challenge&.path.present? - cha_path = challenge_path(exercise_cha.challenge&.path) - game_challenge = game.game_codes.search_challenge_path(cha_path)&.first - if game_challenge.present? - game_code = game_challenge - code = game_code.try(:new_code) - else - begin - code = git_fle_content(game.myshixun.repo_path,cha_path) - rescue - code = "" - end - end - end - if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 - ### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改 - sx_option = { - :exercise_question_id => q.id, - :exercise_shixun_challenge_id => exercise_cha.id, - :user_id => user.id, - :score => exercise_cha_score.round(1), - :answer_text => code, - :status => answer_status - } - ExerciseShixunAnswer.create!(sx_option) - else - ex_shixun_answer_content.first.update_attributes!(score:exercise_cha_score.round(1),answer_text:code,status:answer_status) - end - score5 += exercise_cha_score - else - score5 += 0.0 - end - end - end - end - score5 - end - - def change - user_ids = [111887, 111892, 111883, 111880] - exercise = Exercise.find_by(id: 2734) - if exercise - exercise_users = exercise.exercise_users.where(user_id: user_ids) - exercise_users.each do |exercise_user| - calculate_score = calculate_student_score(exercise, exercise_user.user) - subjective_score = exercise_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score) - puts exercise_user.id - end - end - end -end diff --git a/db/migrate/20191021154016_migrate_2734_exercise_answer_score.rb b/db/migrate/20191021154016_migrate_2734_exercise_answer_score.rb deleted file mode 100644 index 344233dd1..000000000 --- a/db/migrate/20191021154016_migrate_2734_exercise_answer_score.rb +++ /dev/null @@ -1,113 +0,0 @@ -class Migrate2734ExerciseAnswerScore < ActiveRecord::Migration[5.2] - def challenge_path(path) - cha_path = path.present? ? path.split(";") : [] - cha_path.reject(&:blank?)[0].try(:strip) - end - - # 版本库文件内容,带转码 - def git_fle_content(repo_path, path) - begin - Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}") - - content = GitService.file_content(repo_path: repo_path, path: path) - - Rails.logger.info("git file content: content is #{content}") - decode_content = nil - if content.present? - content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass - - content = Base64.decode64(content) - cd = CharDet.detect(content) - Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" - # 字符编码问题,GB18030编码识别率不行 - decode_content = - if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8 - content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '}) - else - content.force_encoding('UTF-8') - end - end - - decode_content - - rescue Exception => e - Rails.logger.error(e.message) - raise Educoder::TipException.new("文档内容获取异常") - end - end - - def calculate_student_score(exercise,user) - score5 = 0.0 #实训题 - exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers,:exercise_shixun_challenges) - exercise_questions.each do |q| - if q.question_type == 5 - q.exercise_shixun_challenges.each do |exercise_cha| - game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡 - if game.present? - exercise_cha_score = 0.0 - answer_status = 0 - # if game.status == 2 && game.final_score >= 0 - if game.final_score > 0 && game.end_time < exercise.end_time - exercise_cha_score = game.real_score(exercise_cha.question_score) - # exercise_cha_score = exercise_cha.question_score #每一关卡的得分 - answer_status = 1 - end - ex_shixun_answer_content = exercise_cha.exercise_shixun_answers.where(user_id:user.id,exercise_question_id:q.id) - code = nil - if exercise_cha.challenge&.path.present? - cha_path = challenge_path(exercise_cha.challenge&.path) - game_challenge = game.game_codes.search_challenge_path(cha_path)&.first - if game_challenge.present? - game_code = game_challenge - code = game_code.try(:new_code) - else - begin - code = git_fle_content(game.myshixun.repo_path,cha_path) - rescue - code = "" - end - end - end - if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 - ### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改 - sx_option = { - :exercise_question_id => q.id, - :exercise_shixun_challenge_id => exercise_cha.id, - :user_id => user.id, - :score => exercise_cha_score.round(1), - :answer_text => code, - :status => answer_status - } - ExerciseShixunAnswer.create!(sx_option) - else - ex_shixun_answer_content.first.update_attributes!(score:exercise_cha_score.round(1),answer_text:code,status:answer_status) - end - score5 += exercise_cha_score - else - score5 += 0.0 - end - end - end - end - score5 - end - - def change - exercise = Exercise.find_by(id: 2734) - if exercise - exercise_users = exercise.exercise_users.where("start_at is not null") - exercise_users.each do |exercise_user| - calculate_score = calculate_student_score(exercise, exercise_user.user) - subjective_score = exercise_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - if exercise_user.end_at.nil? - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3) - else - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score) - end - puts exercise_user.id - end - end - end -end diff --git a/db/migrate/20191022003750_create_weapp_settings.rb b/db/migrate/20191022003750_create_weapp_settings.rb deleted file mode 100644 index 20b3d5879..000000000 --- a/db/migrate/20191022003750_create_weapp_settings.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateWeappSettings < ActiveRecord::Migration[5.2] - def change - create_table :weapp_settings do |t| - t.string :type - t.string :link - t.boolean :online, default: false - t.integer :position, default: 0 - - t.timestamps - end - end -end diff --git a/db/migrate/20191022030127_migrate_competition_score_stage_id.rb b/db/migrate/20191022030127_migrate_competition_score_stage_id.rb deleted file mode 100644 index 0eefbac48..000000000 --- a/db/migrate/20191022030127_migrate_competition_score_stage_id.rb +++ /dev/null @@ -1,7 +0,0 @@ -class MigrateCompetitionScoreStageId < ActiveRecord::Migration[5.2] - def change - change_column_default :competition_scores, :competition_stage_id, 0 - - CompetitionScore.where("competition_stage_id is null").update_all(competition_stage_id: 0) - end -end diff --git a/db/migrate/20191022075223_migrate_competition_mode_default.rb b/db/migrate/20191022075223_migrate_competition_mode_default.rb deleted file mode 100644 index d61d4aa68..000000000 --- a/db/migrate/20191022075223_migrate_competition_mode_default.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MigrateCompetitionModeDefault < ActiveRecord::Migration[5.2] - def change - change_column_default :competitions, :mode, from: 0, to: 1 - Competition.all.update_all(mode: 1) - end -end diff --git a/db/migrate/20191022100044_add_awards_count_to_competition.rb b/db/migrate/20191022100044_add_awards_count_to_competition.rb deleted file mode 100644 index ef6657ae6..000000000 --- a/db/migrate/20191022100044_add_awards_count_to_competition.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAwardsCountToCompetition < ActiveRecord::Migration[5.2] - def change - add_column :competitions, :awards_count, :integer, default: 0 - end -end diff --git a/db/migrate/20191023074837_migrate_competition_module_type.rb b/db/migrate/20191023074837_migrate_competition_module_type.rb deleted file mode 100644 index c98c5797d..000000000 --- a/db/migrate/20191023074837_migrate_competition_module_type.rb +++ /dev/null @@ -1,28 +0,0 @@ -class MigrateCompetitionModuleType < ActiveRecord::Migration[5.2] - def change - add_column :competition_modules, :module_type, :string - - Competition.all.each do |competition| - competition.competition_modules.each do |com_module| - mod_type = "" - case com_module.name - when '首页' - mod_type = "home" - when '报名' - mod_type = "enroll" - when '通知公告' - mod_type = "inform" - when '参赛手册' - mod_type = "manual" - when '排行榜' - mod_type = "chart" - when '资料下载' - mod_type = "resource" - else - mod_type = "md" - end - com_module.update_attributes!(module_type: mod_type) - end - end - end -end diff --git a/db/migrate/20191024055404_migrate_com_module_resource.rb b/db/migrate/20191024055404_migrate_com_module_resource.rb deleted file mode 100644 index f8625b2bc..000000000 --- a/db/migrate/20191024055404_migrate_com_module_resource.rb +++ /dev/null @@ -1,26 +0,0 @@ -class MigrateComModuleResource < ActiveRecord::Migration[5.2] - def change - Competition.all.each do |competition| - competition.competition_modules.each do |com_module| - mod_type = "" - case com_module.name.strip - when '首页' - mod_type = "home" - when '报名' - mod_type = "enroll" - when '通知公告' - mod_type = "inform" - when '参赛手册' - mod_type = "manual" - when '排行榜' - mod_type = "chart" - when '资料下载' - mod_type = "resource" - else - mod_type = "md" - end - com_module.update_attributes!(module_type: mod_type) - end - end - end -end diff --git a/db/migrate/20191024075134_migrate_competition_module_manual.rb b/db/migrate/20191024075134_migrate_competition_module_manual.rb deleted file mode 100644 index 3a2f16cff..000000000 --- a/db/migrate/20191024075134_migrate_competition_module_manual.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateCompetitionModuleManual < ActiveRecord::Migration[5.2] - def change - CompetitionModule.where(module_type: "manual").update_all(module_type: "md") - end -end diff --git a/db/migrate/20191024083706_migrate_competition_module_content.rb b/db/migrate/20191024083706_migrate_competition_module_content.rb deleted file mode 100644 index 72d023a38..000000000 --- a/db/migrate/20191024083706_migrate_competition_module_content.rb +++ /dev/null @@ -1,17 +0,0 @@ -class MigrateCompetitionModuleContent < ActiveRecord::Migration[5.2] - def change - Competition.all.each do |competition| - competition.informs.each do |inform| - if inform.status == 1 - com_module = competition.competition_modules.find_by(module_type: "inform") - elsif inform.status == 2 - com_module = competition.competition_modules.find_by(name: "参赛手册") - end - if com_module - new_md = CompetitionModuleMdContent.create!(competition_module_id: com_module.id, content: inform.description, name: inform.name) - Attachment.where(container_id: inform.id, container_type: "Inform").update_all(container_id: new_md.id, container_type: "CompetitionModuleMdContent") - end - end - end - end -end diff --git a/db/migrate/20191024090740_migrate_competition_chart_rules.rb b/db/migrate/20191024090740_migrate_competition_chart_rules.rb deleted file mode 100644 index bff749e23..000000000 --- a/db/migrate/20191024090740_migrate_competition_chart_rules.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateCompetitionChartRules < ActiveRecord::Migration[5.2] - def change - add_column :competition_module_md_contents, :competition_stage_id, :integer, default: 0 - end -end diff --git a/db/migrate/20191024105504_create_competition_schools.rb b/db/migrate/20191024105504_create_competition_schools.rb deleted file mode 100644 index 27a425abc..000000000 --- a/db/migrate/20191024105504_create_competition_schools.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateCompetitionSchools < ActiveRecord::Migration[5.2] - def change - create_table :competition_schools do |t| - t.references :competition, index: true - t.references :school, index: true - t.string :source - - t.timestamps - end - end -end diff --git a/db/migrate/20191025012950_add_column_to_stage_sections.rb b/db/migrate/20191025012950_add_column_to_stage_sections.rb deleted file mode 100644 index 5eb96aea9..000000000 --- a/db/migrate/20191025012950_add_column_to_stage_sections.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddColumnToStageSections < ActiveRecord::Migration[5.2] - def change - add_column :competition_stage_sections, :mission_count, :integer, default: 0 - add_column :competition_stage_sections, :score_source, :integer, default: 0 - - add_column :competition_entries, :shixun_identifier, :string - end -end diff --git a/db/migrate/20191026110116_migrate_chart_rule.rb b/db/migrate/20191026110116_migrate_chart_rule.rb deleted file mode 100644 index 05331e90d..000000000 --- a/db/migrate/20191026110116_migrate_chart_rule.rb +++ /dev/null @@ -1,12 +0,0 @@ -class MigrateChartRule < ActiveRecord::Migration[5.2] - def change - ChartRule.all.each do |rule| - if rule.competition - com_module = rule.competition.competition_modules.find_by(module_type: "chart") - if com_module && !com_module.competition_module_md_contents.exists?(competition_stage_id: rule.competition_stage_id ? rule.competition_stage_id : 0) - CompetitionModuleMdContent.create!(content: rule.content, competition_module_id: com_module.id, competition_stage_id: rule.competition_stage_id ? rule.competition_stage_id : 0) - end - end - end - end -end diff --git a/db/migrate/20191028025241_re_counter_course_groups.rb b/db/migrate/20191028025241_re_counter_course_groups.rb deleted file mode 100644 index 02bd1fe77..000000000 --- a/db/migrate/20191028025241_re_counter_course_groups.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ReCounterCourseGroups < ActiveRecord::Migration[5.2] - def change - CourseGroup.find_each do |group| - CourseGroup.reset_counters(group.id, :course_members_count) - end - end -end diff --git a/db/migrate/20191029003245_create_competition_managers.rb b/db/migrate/20191029003245_create_competition_managers.rb deleted file mode 100644 index 047ebcbe9..000000000 --- a/db/migrate/20191029003245_create_competition_managers.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateCompetitionManagers < ActiveRecord::Migration[5.2] - def change - create_table :competition_managers do |t| - t.references :user - t.references :competition - - t.timestamps - end - end -end diff --git a/db/migrate/20191029011040_add_statistics_to_course_module.rb b/db/migrate/20191029011040_add_statistics_to_course_module.rb deleted file mode 100644 index 3babbcdbf..000000000 --- a/db/migrate/20191029011040_add_statistics_to_course_module.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddStatisticsToCourseModule < ActiveRecord::Migration[5.2] - def change - Course.includes(:course_modules).all.each do |course| - CourseModule.create!(course_id: course.id, module_type: "statistics", hidden:0, module_name: "统计", position: course.course_modules.pluck(:position).max + 1) - end - end -end diff --git a/db/migrate/20191029065244_init_trustie_config.rb b/db/migrate/20191029065244_init_trustie_config.rb deleted file mode 100644 index 24ec7a245..000000000 --- a/db/migrate/20191029065244_init_trustie_config.rb +++ /dev/null @@ -1,8 +0,0 @@ -class InitTrustieConfig < ActiveRecord::Migration[5.2] - def change - hash = {"trustie_api_token" => "", "trustie_api_url" => ""} - hash.each { |key, value| - EduSetting.find_or_create_by(name: key, value: value) - } - end -end diff --git a/db/migrate/20191029084344_add_total_score_to_homework_commons.rb b/db/migrate/20191029084344_add_total_score_to_homework_commons.rb deleted file mode 100644 index 1fefdde34..000000000 --- a/db/migrate/20191029084344_add_total_score_to_homework_commons.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTotalScoreToHomeworkCommons < ActiveRecord::Migration[5.2] - def change - add_column :homework_commons, :total_score, :float, default: 100 - end -end diff --git a/db/migrate/20191030005223_init_competition_certificate_module_data.rb b/db/migrate/20191030005223_init_competition_certificate_module_data.rb deleted file mode 100644 index 75eedbd86..000000000 --- a/db/migrate/20191030005223_init_competition_certificate_module_data.rb +++ /dev/null @@ -1,10 +0,0 @@ -class InitCompetitionCertificateModuleData < ActiveRecord::Migration[5.2] - def change - Competition.find_each do |competition| - competition.competition_modules.where(module_type: 'certificate').delete_all - - position = competition.competition_modules.maximum(:position) + 1 - competition.competition_modules.create(module_type: 'certificate', position: position, name: '获奖证书', hidden: true) - end - end -end diff --git a/db/migrate/20191030013802_create_competition_prizes.rb b/db/migrate/20191030013802_create_competition_prizes.rb deleted file mode 100644 index bafacf22d..000000000 --- a/db/migrate/20191030013802_create_competition_prizes.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateCompetitionPrizes < ActiveRecord::Migration[5.2] - def change - create_table :competition_prizes do |t| - t.references :competition - - t.string :name - t.string :category - t.integer :num - - t.timestamps - end - end -end diff --git a/db/migrate/20191030055341_create_competition_prize_users.rb b/db/migrate/20191030055341_create_competition_prize_users.rb deleted file mode 100644 index ab1e31144..000000000 --- a/db/migrate/20191030055341_create_competition_prize_users.rb +++ /dev/null @@ -1,20 +0,0 @@ -class CreateCompetitionPrizeUsers < ActiveRecord::Migration[5.2] - def change - create_table :competition_prize_users do |t| - t.references :competition - t.references :competition_team - t.references :competition_prize - t.references :user - t.references :approver - - t.string :status - t.integer :rank - t.boolean :leader, default: false - t.text :extra - - t.datetime :approved_at - - t.timestamps - end - end -end diff --git a/db/migrate/20191030062150_create_exercise_user_scores.rb b/db/migrate/20191030062150_create_exercise_user_scores.rb deleted file mode 100644 index 911a8a3a5..000000000 --- a/db/migrate/20191030062150_create_exercise_user_scores.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateExerciseUserScores < ActiveRecord::Migration[5.2] - def change - create_table :exercise_user_scores do |t| - t.references :exercise, index: true - t.references :exercise_user, index: true - t.float :score - t.text :comment - t.references :user, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20191104033349_create_game_answers.rb b/db/migrate/20191104033349_create_game_answers.rb deleted file mode 100644 index 211a0c29d..000000000 --- a/db/migrate/20191104033349_create_game_answers.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateGameAnswers < ActiveRecord::Migration[5.2] - def change - create_table :game_answers do |t| - t.references :challenge_answer - t.references :user - t.references :game - t.datetime :view_time - - t.timestamps - end - - end -end diff --git a/db/migrate/20191104055038_add_index_for_game_answers.rb b/db/migrate/20191104055038_add_index_for_game_answers.rb deleted file mode 100644 index 7cd59c6ee..000000000 --- a/db/migrate/20191104055038_add_index_for_game_answers.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexForGameAnswers < ActiveRecord::Migration[5.2] - def change - add_index :game_answers, [:challenge_answer_id, :user_id], :unique => true - end -end diff --git a/db/migrate/20191104063136_add_team_title_to_subjects.rb b/db/migrate/20191104063136_add_team_title_to_subjects.rb deleted file mode 100644 index d515a800a..000000000 --- a/db/migrate/20191104063136_add_team_title_to_subjects.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTeamTitleToSubjects < ActiveRecord::Migration[5.2] - def change - add_column :subjects, :team_title, :string, default: "教学团队" - end -end diff --git a/db/migrate/20191104080912_add_email_notify_to_course.rb b/db/migrate/20191104080912_add_email_notify_to_course.rb deleted file mode 100644 index 5a817781c..000000000 --- a/db/migrate/20191104080912_add_email_notify_to_course.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEmailNotifyToCourse < ActiveRecord::Migration[5.2] - def change - add_column :courses, :email_notify, :boolean, default: 0 - end -end diff --git a/db/migrate/20191104132649_migrate_2796_exercise_score.rb b/db/migrate/20191104132649_migrate_2796_exercise_score.rb deleted file mode 100644 index 375116e94..000000000 --- a/db/migrate/20191104132649_migrate_2796_exercise_score.rb +++ /dev/null @@ -1,60 +0,0 @@ -class Migrate2796ExerciseScore < ActiveRecord::Migration[5.2] - def calculate_student_score(exercise,user) - score1 = 0.0 #实训题 - exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers) - exercise_questions.each do |q| - answers_content = q.exercise_answers.where(user_id: user.id) #学生的答案 - if q.question_type <= 2 #为选择题或判断题时 - if answers_content.present? #学生有回答时 - answer_choice_array = [] - answers_content.each do |a| - answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 - end - user_answer_content = answer_choice_array.sort - standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 - - #TODO: 旧版多选题的标准答案是放在一个里面的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) - if q.question_type == 1 && standard_answer.size == 1 - standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort - end - - if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 - if standard_answer.size > 0 - q_score_1 = q.question_score - # q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 - else - q_score_1 = 0.0 - end - answers_content.update_all(:score => q_score_1) - score1 = score1 + q.question_score - else - answers_content.update_all(:score => -1.0) - score1 += 0.0 - end - else - score1 += 0.0 - end - end - end - score1 - end - - def change - exercise = Exercise.find_by(id: 2796) - if exercise - exercise_users = exercise.exercise_users.where("start_at is not null and commit_status = 0") - exercise_users.each do |exercise_user| - calculate_score = calculate_student_score(exercise, exercise_user.user) - subjective_score = exercise_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - if exercise_user.end_at.nil? - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3) - else - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score) - end - puts exercise_user.id - end - end - end -end diff --git a/db/migrate/20191105093740_create_trustie_hackathons.rb b/db/migrate/20191105093740_create_trustie_hackathons.rb deleted file mode 100644 index 4e806d346..000000000 --- a/db/migrate/20191105093740_create_trustie_hackathons.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTrustieHackathons < ActiveRecord::Migration[5.2] - def change - create_table :trustie_hackathons do |t| - t.string :name - t.string :description - t.integer :trustie_hacks_count, default: 0 - t.timestamps - end - end -end diff --git a/db/migrate/20191105093919_create_trustie_hacks.rb b/db/migrate/20191105093919_create_trustie_hacks.rb deleted file mode 100644 index d4f65516e..000000000 --- a/db/migrate/20191105093919_create_trustie_hacks.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateTrustieHacks < ActiveRecord::Migration[5.2] - def change - create_table :trustie_hacks do |t| - t.string :name - t.string :description - t.references :user - t.integer :hack_users_count, default: 0 - t.timestamps - end - end -end diff --git a/db/migrate/20191105094146_create_hack_users.rb b/db/migrate/20191105094146_create_hack_users.rb deleted file mode 100644 index 2ef654b5b..000000000 --- a/db/migrate/20191105094146_create_hack_users.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateHackUsers < ActiveRecord::Migration[5.2] - def change - create_table :hack_users do |t| - t.references :user - t.references :trustie_hack - t.timestamps - end - end -end diff --git a/db/migrate/20191106015717_create_partner_manager_groups.rb b/db/migrate/20191106015717_create_partner_manager_groups.rb deleted file mode 100644 index 282c9a11e..000000000 --- a/db/migrate/20191106015717_create_partner_manager_groups.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreatePartnerManagerGroups < ActiveRecord::Migration[5.2] - def change - create_table :partner_manager_groups do |t| - t.references :partner - t.string :name - t.boolean :admin, default: false - - t.timestamps - end - - add_reference :customers, :partner_manager_group - end -end diff --git a/db/migrate/20191106020241_create_partner_managers.rb b/db/migrate/20191106020241_create_partner_managers.rb deleted file mode 100644 index e033ba199..000000000 --- a/db/migrate/20191106020241_create_partner_managers.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePartnerManagers < ActiveRecord::Migration[5.2] - def change - create_table :partner_managers do |t| - t.references :user - t.references :partner - t.references :partner_manager_group - - t.timestamps - end - end -end diff --git a/db/migrate/20191106020505_transfer_partner_manager_data.rb b/db/migrate/20191106020505_transfer_partner_manager_data.rb deleted file mode 100644 index cb297dc32..000000000 --- a/db/migrate/20191106020505_transfer_partner_manager_data.rb +++ /dev/null @@ -1,14 +0,0 @@ -class TransferPartnerManagerData < ActiveRecord::Migration[5.2] - def change - ActiveRecord::Base.transaction do - Partner.find_each do |partner| - manager_group = partner.partner_manager_groups.find_or_create_by(name: '管理者', admin: true) - - user_ids = User.where(partner_id: partner.id).pluck(:id) - PartnerManager.bulk_insert(*%i[user_id partner_id partner_manager_group_id created_at updated_at]) do |worker| - user_ids.each { |user_id| worker.add(user_id: user_id, partner_id: partner.id, partner_manager_group_id: manager_group.id) } - end - end - end - end -end diff --git a/db/migrate/20191106021452_remove_partner_id_from_users.rb b/db/migrate/20191106021452_remove_partner_id_from_users.rb deleted file mode 100644 index a306eda2d..000000000 --- a/db/migrate/20191106021452_remove_partner_id_from_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemovePartnerIdFromUsers < ActiveRecord::Migration[5.2] - def change - remove_reference :users, :partner - end -end diff --git a/db/migrate/20191106034825_add_trustie_hackathon_id_for_trustie_hacks.rb b/db/migrate/20191106034825_add_trustie_hackathon_id_for_trustie_hacks.rb deleted file mode 100644 index 0c2619ec7..000000000 --- a/db/migrate/20191106034825_add_trustie_hackathon_id_for_trustie_hacks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTrustieHackathonIdForTrustieHacks < ActiveRecord::Migration[5.2] - def change - add_column :trustie_hacks, :trustie_hackathon_id, :integer - add_index :trustie_hacks, :trustie_hackathon_id - end -end diff --git a/db/migrate/20191106055638_migrate_2808_exercise_score.rb b/db/migrate/20191106055638_migrate_2808_exercise_score.rb deleted file mode 100644 index ebf09e148..000000000 --- a/db/migrate/20191106055638_migrate_2808_exercise_score.rb +++ /dev/null @@ -1,111 +0,0 @@ -class Migrate2808ExerciseScore < ActiveRecord::Migration[5.2] - def challenge_path(path) - cha_path = path.present? ? path.split(";") : [] - cha_path.reject(&:blank?)[0].try(:strip) - end - - # 版本库文件内容,带转码 - def git_fle_content(repo_path, path) - begin - Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}") - - content = GitService.file_content(repo_path: repo_path, path: path) - - Rails.logger.info("git file content: content is #{content}") - decode_content = nil - if content.present? - content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass - - content = Base64.decode64(content) - cd = CharDet.detect(content) - Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" - # 字符编码问题,GB18030编码识别率不行 - decode_content = - if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8 - content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '}) - else - content.force_encoding('UTF-8') - end - end - - decode_content - - rescue Exception => e - Rails.logger.error(e.message) - raise Educoder::TipException.new("文档内容获取异常") - end - end - - def calculate_student_score(exercise,user) - score5 = 0.0 #实训题 - exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers,:exercise_shixun_challenges) - exercise_questions.each do |q| - if q.question_type == 5 - q.exercise_shixun_challenges.each do |exercise_cha| - game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡 - if game.present? - exercise_cha_score = 0.0 - answer_status = 0 - # if game.status == 2 && game.final_score >= 0 - if game.final_score > 0 && game.end_time < exercise.end_time - exercise_cha_score = game.real_score(exercise_cha.question_score) - # exercise_cha_score = exercise_cha.question_score #每一关卡的得分 - answer_status = 1 - end - ex_shixun_answer_content = exercise_cha.exercise_shixun_answers.where(user_id:user.id,exercise_question_id:q.id) - code = nil - if exercise_cha.challenge&.path.present? - cha_path = challenge_path(exercise_cha.challenge&.path) - game_challenge = game.game_codes.search_challenge_path(cha_path)&.first - if game_challenge.present? - game_code = game_challenge - code = game_code.try(:new_code) - else - begin - code = git_fle_content(game.myshixun.repo_path,cha_path) - rescue - code = "" - end - end - end - if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 - ### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改 - sx_option = { - :exercise_question_id => q.id, - :exercise_shixun_challenge_id => exercise_cha.id, - :user_id => user.id, - :score => exercise_cha_score.round(1), - :answer_text => code, - :status => answer_status - } - ExerciseShixunAnswer.create!(sx_option) - else - ex_shixun_answer_content.first.update_attributes!(score:exercise_cha_score.round(1),answer_text:code,status:answer_status) - end - score5 += exercise_cha_score - else - score5 += 0.0 - end - end - end - end - score5 - end - - def change - exercise = Exercise.find_by(id: 2808) - if exercise - exercise_users = exercise.exercise_users.where("start_at is not null and commit_status = 0") - exercise_users.each do |exercise_user| - calculate_score = calculate_student_score(exercise, exercise_user.user) - subjective_score = exercise_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - if exercise_user.end_at.nil? - exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3) - end - puts exercise_user.id - end - end - end -end diff --git a/db/migrate/20191106061342_add_uniq_index_for_hack_users.rb b/db/migrate/20191106061342_add_uniq_index_for_hack_users.rb deleted file mode 100644 index 6d1924d92..000000000 --- a/db/migrate/20191106061342_add_uniq_index_for_hack_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUniqIndexForHackUsers < ActiveRecord::Migration[5.2] - def change - add_index :hack_users, [:user_id, :trustie_hack_id], unique: true - end -end diff --git a/db/migrate/20191106070243_create_laboratory_shixuns.rb b/db/migrate/20191106070243_create_laboratory_shixuns.rb deleted file mode 100644 index 7f2e4fa02..000000000 --- a/db/migrate/20191106070243_create_laboratory_shixuns.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateLaboratoryShixuns < ActiveRecord::Migration[5.2] - def change - create_table :laboratory_shixuns do |t| - t.references :laboratory - t.references :shixun - - t.boolean :ownership, default: false - t.boolean :homepage, default: false - - t.timestamps - end - end -end diff --git a/db/migrate/20191106094429_add_position_for_informs.rb b/db/migrate/20191106094429_add_position_for_informs.rb deleted file mode 100644 index 3065081f2..000000000 --- a/db/migrate/20191106094429_add_position_for_informs.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddPositionForInforms < ActiveRecord::Migration[5.2] - def change - add_column :informs, :position, :integer, :default => 1 - - course_ids = Inform.where(container_type: 'Course').pluck(:container_id).uniq - courses = Course.where(id: course_ids) - - courses.find_each do |course| - next if course.informs.count == 1 - informs = course.informs.order("created_at asc") - informs.each_with_index do |inform, index| - inform.update_attribute(:position, index+1) - end - end - - end -end diff --git a/db/migrate/20191107023418_create_laboratory_subjects.rb b/db/migrate/20191107023418_create_laboratory_subjects.rb deleted file mode 100644 index ea916f897..000000000 --- a/db/migrate/20191107023418_create_laboratory_subjects.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateLaboratorySubjects < ActiveRecord::Migration[5.2] - def change - create_table :laboratory_subjects do |t| - t.references :laboratory - t.references :subject - - t.boolean :ownership, default: false - t.boolean :homepage, default: false - - t.timestamps - end - end -end diff --git a/db/migrate/20191107062552_add_email_notify_to_messages.rb b/db/migrate/20191107062552_add_email_notify_to_messages.rb deleted file mode 100644 index 2ec6f20e4..000000000 --- a/db/migrate/20191107062552_add_email_notify_to_messages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEmailNotifyToMessages < ActiveRecord::Migration[5.2] - def change - add_column :messages, :email_notify, :boolean, default: 0 - end -end diff --git a/db/migrate/20191107093428_add_column_to_exercise_user_score.rb b/db/migrate/20191107093428_add_column_to_exercise_user_score.rb deleted file mode 100644 index 892252987..000000000 --- a/db/migrate/20191107093428_add_column_to_exercise_user_score.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddColumnToExerciseUserScore < ActiveRecord::Migration[5.2] - def change - add_column :exercise_user_scores, :subjective_score, :float, default: 0 - add_column :exercise_user_scores, :objective_score, :float, default: 0 - end -end diff --git a/db/migrate/20191108070703_modify_descriotion_limit_for_hacks.rb b/db/migrate/20191108070703_modify_descriotion_limit_for_hacks.rb deleted file mode 100644 index 9168dbd2a..000000000 --- a/db/migrate/20191108070703_modify_descriotion_limit_for_hacks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ModifyDescriotionLimitForHacks < ActiveRecord::Migration[5.2] - def change - change_column :trustie_hackathons, :description, :text - change_column :trustie_hacks, :description, :text - end -end diff --git a/db/migrate/20191111082252_create_hacks.rb b/db/migrate/20191111082252_create_hacks.rb deleted file mode 100644 index c9508319e..000000000 --- a/db/migrate/20191111082252_create_hacks.rb +++ /dev/null @@ -1,20 +0,0 @@ -class CreateHacks < ActiveRecord::Migration[5.2] - def change - create_table :hacks do |t| - t.string :name - t.integer :difficult - t.integer :category - t.integer :status, default: 0 - t.boolean :open_or_not, default: true - t.integer :time_limit - t.integer :memory_limit - t.string :identifier - t.references :user - t.text :description - - t.timestamps - end - - add_index :hacks, :identifier, unique: true - end -end diff --git a/db/migrate/20191111083528_create_hack_codes.rb b/db/migrate/20191111083528_create_hack_codes.rb deleted file mode 100644 index 7322a8de8..000000000 --- a/db/migrate/20191111083528_create_hack_codes.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateHackCodes < ActiveRecord::Migration[5.2] - def change - create_table :hack_codes do |t| - t.references :hack - t.text :code - t.string :language - - t.timestamps - end - end -end diff --git a/db/migrate/20191111100954_create_hack_sets.rb b/db/migrate/20191111100954_create_hack_sets.rb deleted file mode 100644 index e4d710137..000000000 --- a/db/migrate/20191111100954_create_hack_sets.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateHackSets < ActiveRecord::Migration[5.2] - def change - create_table :hack_sets do |t| - t.references :hack - t.text :input - t.text :output - t.integer :position - - t.timestamps - end - add_index :hack_sets, [:hack_id, :position], unique: true - end -end diff --git a/db/migrate/20191111101536_create_hack_user_codes.rb b/db/migrate/20191111101536_create_hack_user_codes.rb deleted file mode 100644 index 3aeded9a6..000000000 --- a/db/migrate/20191111101536_create_hack_user_codes.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CreateHackUserCodes < ActiveRecord::Migration[5.2] - def change - create_table :hack_user_codes do |t| - t.references :user - t.references :hack - t.text :code - t.text :output - t.text :error_msg - t.integer :error_line - t.integer :position - t.integer :status, default: 0 - t.integer :query_index - t.timestamps - end - - add_index :hack_user_codes, [:user_id, :hack_id, :query_index], unique: true - end -end diff --git a/db/migrate/20191112010611_create_hack_user_lastest_codes.rb b/db/migrate/20191112010611_create_hack_user_lastest_codes.rb deleted file mode 100644 index 9c5227a54..000000000 --- a/db/migrate/20191112010611_create_hack_user_lastest_codes.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateHackUserLastestCodes < ActiveRecord::Migration[5.2] - def change - create_table :hack_user_lastest_codes do |t| - t.references :user - t.references :hack - t.text :code - - t.timestamps - end - add_index :hack_user_lastest_codes, [:user_id, :hack_id], unique: true - end -end diff --git a/db/migrate/20191112012007_create_hack_user_debugs.rb b/db/migrate/20191112012007_create_hack_user_debugs.rb deleted file mode 100644 index 8027c3dc6..000000000 --- a/db/migrate/20191112012007_create_hack_user_debugs.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateHackUserDebugs < ActiveRecord::Migration[5.2] - def change - create_table :hack_user_debugs do |t| - t.references :user - t.references :hack - t.text :output - t.text :input - t.text :error_msg - t.integer :error_line - - t.timestamps - end - end -end diff --git a/db/migrate/20191112023111_add_defualt_for_hacks.rb b/db/migrate/20191112023111_add_defualt_for_hacks.rb deleted file mode 100644 index 41c1a71fa..000000000 --- a/db/migrate/20191112023111_add_defualt_for_hacks.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddDefualtForHacks < ActiveRecord::Migration[5.2] - def change - change_column :hacks, :status, :integer, :default => 0 - change_column :hacks, :open_or_not, :boolean, :default => true - change_column :hack_user_codes, :status, :integer, :default => 0 - end -end diff --git a/db/migrate/20191112100418_migrate_gcc_project_team.rb b/db/migrate/20191112100418_migrate_gcc_project_team.rb deleted file mode 100644 index 633f25c62..000000000 --- a/db/migrate/20191112100418_migrate_gcc_project_team.rb +++ /dev/null @@ -1,25 +0,0 @@ -class MigrateGccProjectTeam < ActiveRecord::Migration[5.2] - def change - competition = Competition.find_by(id: 8) - if competition - competition.competition_teams.destroy_all - all_login = [['mu2pwryse', 'pljq3f9xp', 'pfx7gfmiz'], ['p9rs7xtfl', 'prx72s8uc', 'plezci23p', 'pjysrikw7'], ['m40352189', 'p05394287'], - ['m9ozhx83t', 'p05296348'], ['p35490268', 'p48921607', 'p24019738'], ['p29165708', 'm43960821']] - all_login.each do |user_login| - leader = User.find_by(login: user_login.first) - next if leader.blank? - team = CompetitionTeam.create!(name: "#{leader.real_name}组", user_id: leader.id, competition_id: 8) - team.generate_invite_code - team.save! - team.team_members.create!(user_id: leader.id, competition_id: competition.id, role: 1, is_teacher: 0) - - user_login.each_with_index do |user_login, index| - if index > 0 - user = User.find_by(login: user_login) - team.team_members.create!(user_id: user.id, competition_id: competition.id, role: 2, is_teacher: 0) - end - end - end - end - end -end diff --git a/db/migrate/20191112100820_add_score_for_hacks.rb b/db/migrate/20191112100820_add_score_for_hacks.rb deleted file mode 100644 index b4a3657f7..000000000 --- a/db/migrate/20191112100820_add_score_for_hacks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddScoreForHacks < ActiveRecord::Migration[5.2] - def change - add_column :hacks, :score, :integer - end -end diff --git a/db/migrate/20191113013258_gcc_course_competition_rank_data.rb b/db/migrate/20191113013258_gcc_course_competition_rank_data.rb deleted file mode 100644 index 344d8061c..000000000 --- a/db/migrate/20191113013258_gcc_course_competition_rank_data.rb +++ /dev/null @@ -1,9 +0,0 @@ -class GccCourseCompetitionRankData < ActiveRecord::Migration[5.2] - def change - competition = Competition.find_by(identifier: 'gcc-course-2019') - stage = competition.competition_stages.first - return if competition.blank? || stage.blank? - - competition.competition_scores.update_all(competition_stage_id: stage.id) - end -end diff --git a/db/migrate/20191113061866_add_status_end_time_for_hack_user_lastest_code.rb b/db/migrate/20191113061866_add_status_end_time_for_hack_user_lastest_code.rb deleted file mode 100644 index fb8fe8a61..000000000 --- a/db/migrate/20191113061866_add_status_end_time_for_hack_user_lastest_code.rb +++ /dev/null @@ -1,27 +0,0 @@ -class AddStatusEndTimeForHackUserLastestCode < ActiveRecord::Migration[5.2] - def change - add_column :hack_user_lastest_codes, :passed, :boolean, :default => false - add_column :hack_user_lastest_codes, :pass_time, :timestamp - add_column :hack_user_lastest_codes, :identifier, :string - add_column :hack_user_lastest_codes, :language, :string - add_column :hack_user_debugs, :hack_user_lastest_code_id, :integer - add_column :hacks, :hack_user_lastest_codes_count, :integer, :default => 0 - add_column :hacks, :pass_num, :integer, :default => 0 - add_column :hacks, :submit_num, :integer, :default => 0 - add_column :hack_user_codes, :input, :text - add_index :hack_user_lastest_codes, :user_id, name: "user_index" - add_index :hack_user_lastest_codes, :hack_id, name: "hack_index" - add_index :hack_user_lastest_codes, :identifier, unique: true - add_index :hack_user_debugs, :hack_user_lastest_code_id, unique: true - add_column :hack_user_lastest_codes, :submit_status, :integer, :default => 0 - add_column :hack_user_lastest_codes, :status, :integer - add_column :hack_user_lastest_codes, :passed_time, :timestamp - add_column :hack_user_debugs, :status, :integer - - add_column :hack_user_codes, :execute_time, :integer - add_column :hack_user_codes, :execute_memory, :integer - add_column :hack_user_debugs, :execute_time, :integer - add_column :hack_user_debugs, :execute_memory, :integer - - end -end diff --git a/db/migrate/20191114073028_add_sticky_to_course_members.rb b/db/migrate/20191114073028_add_sticky_to_course_members.rb deleted file mode 100644 index d61b9df66..000000000 --- a/db/migrate/20191114073028_add_sticky_to_course_members.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddStickyToCourseMembers < ActiveRecord::Migration[5.2] - def change - add_column :course_members, :sticky, :boolean, default: 0 - add_column :course_members, :sticky_time, :datetime - end -end diff --git a/db/migrate/20191115011229_add_laboratory_id_to_courses.rb b/db/migrate/20191115011229_add_laboratory_id_to_courses.rb deleted file mode 100644 index 4ac60026f..000000000 --- a/db/migrate/20191115011229_add_laboratory_id_to_courses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLaboratoryIdToCourses < ActiveRecord::Migration[5.2] - def change - add_reference :courses, :laboratory, null: true - end -end diff --git a/db/migrate/20191115012535_add_laboratory_id_to_competitions.rb b/db/migrate/20191115012535_add_laboratory_id_to_competitions.rb deleted file mode 100644 index 0d88e92d7..000000000 --- a/db/migrate/20191115012535_add_laboratory_id_to_competitions.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLaboratoryIdToCompetitions < ActiveRecord::Migration[5.2] - def change - add_reference :competitions, :laboratory - end -end diff --git a/db/migrate/20191115053209_add_laboratory_id_to_users.rb b/db/migrate/20191115053209_add_laboratory_id_to_users.rb deleted file mode 100644 index 3e02a8e17..000000000 --- a/db/migrate/20191115053209_add_laboratory_id_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLaboratoryIdToUsers < ActiveRecord::Migration[5.2] - def change - add_reference :users, :laboratory - end -end diff --git a/db/migrate/20191115060527_add_copy_from_for_subjects.rb b/db/migrate/20191115060527_add_copy_from_for_subjects.rb deleted file mode 100644 index 41c282cc4..000000000 --- a/db/migrate/20191115060527_add_copy_from_for_subjects.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCopyFromForSubjects < ActiveRecord::Migration[5.2] - def change - add_column :subjects, :copy_subject_id, :integer - end -end diff --git a/db/migrate/20191115070508_add_laboratory_id_to_libraries.rb b/db/migrate/20191115070508_add_laboratory_id_to_libraries.rb deleted file mode 100644 index f067908fc..000000000 --- a/db/migrate/20191115070508_add_laboratory_id_to_libraries.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLaboratoryIdToLibraries < ActiveRecord::Migration[5.2] - def change - add_reference :libraries, :laboratory - end -end diff --git a/db/migrate/20191115070841_transfer_laboratory_data.rb b/db/migrate/20191115070841_transfer_laboratory_data.rb deleted file mode 100644 index 4812ade30..000000000 --- a/db/migrate/20191115070841_transfer_laboratory_data.rb +++ /dev/null @@ -1,7 +0,0 @@ -class TransferLaboratoryData < ActiveRecord::Migration[5.2] - def change - Course.where(laboratory_id: nil).update_all(laboratory_id: 1) - Competition.where(laboratory_id: nil).update_all(laboratory_id: 1) - Library.where(laboratory_id: nil).update_all(laboratory_id: 1) - end -end diff --git a/db/migrate/20191115121529_add_laborary_id_for_shixun.rb b/db/migrate/20191115121529_add_laborary_id_for_shixun.rb deleted file mode 100644 index ea67d19d4..000000000 --- a/db/migrate/20191115121529_add_laborary_id_for_shixun.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLaboraryIdForShixun < ActiveRecord::Migration[5.2] - def change - add_column :shixuns, :laboratory_id, :integer - end -end diff --git a/db/migrate/20191118113842_add_hack_user_lastest_code_id_for_hack_user_code.rb b/db/migrate/20191118113842_add_hack_user_lastest_code_id_for_hack_user_code.rb deleted file mode 100644 index a3602d402..000000000 --- a/db/migrate/20191118113842_add_hack_user_lastest_code_id_for_hack_user_code.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddHackUserLastestCodeIdForHackUserCode < ActiveRecord::Migration[5.2] - def change - add_column :hack_user_codes, :hack_user_lastest_code_id, :integer - add_index :hack_user_codes, :hack_user_lastest_code_id - - end -end diff --git a/db/migrate/20191119064245_add_sync_course_to_laboratory_settings.rb b/db/migrate/20191119064245_add_sync_course_to_laboratory_settings.rb deleted file mode 100644 index f11b501f0..000000000 --- a/db/migrate/20191119064245_add_sync_course_to_laboratory_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddSyncCourseToLaboratorySettings < ActiveRecord::Migration[5.2] - def change - add_column :laboratories, :sync_course, :boolean, default: 0 - end -end diff --git a/db/migrate/20191120012538_remove_pass_time_for_hack_user_lastest_codes.rb b/db/migrate/20191120012538_remove_pass_time_for_hack_user_lastest_codes.rb deleted file mode 100644 index 48063b9a2..000000000 --- a/db/migrate/20191120012538_remove_pass_time_for_hack_user_lastest_codes.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RemovePassTimeForHackUserLastestCodes < ActiveRecord::Migration[5.2] - def change - remove_column :hack_user_lastest_codes, :pass_time - add_column :hack_user_codes, :expected_output, :text - end -end diff --git a/db/migrate/20191120080224_migrate_eff_score_default.rb b/db/migrate/20191120080224_migrate_eff_score_default.rb deleted file mode 100644 index 0561eb646..000000000 --- a/db/migrate/20191120080224_migrate_eff_score_default.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MigrateEffScoreDefault < ActiveRecord::Migration[5.2] - def change - change_column :homework_commons, :eff_score, :float, default: 0 - end -end diff --git a/db/migrate/20191120123353_add_code_forhack_user_debugs.rb b/db/migrate/20191120123353_add_code_forhack_user_debugs.rb deleted file mode 100644 index d3285f26b..000000000 --- a/db/migrate/20191120123353_add_code_forhack_user_debugs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCodeForhackUserDebugs < ActiveRecord::Migration[5.2] - def change - add_column :hack_user_debugs, :code, :text - end -end diff --git a/db/migrate/20191121025552_modify_execute_time_for_hack_user_code.rb b/db/migrate/20191121025552_modify_execute_time_for_hack_user_code.rb deleted file mode 100644 index c66e13a03..000000000 --- a/db/migrate/20191121025552_modify_execute_time_for_hack_user_code.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ModifyExecuteTimeForHackUserCode < ActiveRecord::Migration[5.2] - def change - change_column :hack_user_debugs, :execute_time, :float - change_column :hack_user_codes, :execute_time, :float - end -end diff --git a/db/migrate/20191129064841_add_sync_shixun_subject_to_laboratory.rb b/db/migrate/20191129064841_add_sync_shixun_subject_to_laboratory.rb deleted file mode 100644 index 698e0d9f3..000000000 --- a/db/migrate/20191129064841_add_sync_shixun_subject_to_laboratory.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddSyncShixunSubjectToLaboratory < ActiveRecord::Migration[5.2] - def change - add_column :laboratories, :sync_subject, :boolean, default: 0 - add_column :laboratories, :sync_shixun, :boolean, default: 0 - end -end diff --git a/db/migrate/20191203032557_add_uniq_index_to_exercise_answer.rb b/db/migrate/20191203032557_add_uniq_index_to_exercise_answer.rb deleted file mode 100644 index 8104d336a..000000000 --- a/db/migrate/20191203032557_add_uniq_index_to_exercise_answer.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddUniqIndexToExerciseAnswer < ActiveRecord::Migration[5.2] - def change - # remove_index :exercise_answers, column: [:exercise_question_id, :user_id] - # - # change_column_default :exercise_answers, :exercise_choice_id, from: nil, to: -1 - # ExerciseAnswer.where(exercise_choice_id: nil).update_all(exercise_choice_id: -1) - - # sql = %Q(delete from exercise_answers where (exercise_question_id, user_id, exercise_choice_id) in - # (select * from (select exercise_question_id, user_id, exercise_choice_id from exercise_answers group by exercise_question_id, user_id, exercise_choice_id having count(*) > 1) a) - # and id not in (select * from (select min(id) from exercise_answers group by exercise_question_id, user_id, exercise_choice_id having count(*) > 1 order by id) b)) - # ActiveRecord::Base.connection.execute sql - # - # add_index :exercise_answers, [:exercise_question_id, :user_id, :exercise_choice_id], name: 'exercise_choice_index', unique: true - - - end -end diff --git a/db/migrate/20191203040140_add_uniq_index_to_poll_votes.rb b/db/migrate/20191203040140_add_uniq_index_to_poll_votes.rb deleted file mode 100644 index 971e74b9e..000000000 --- a/db/migrate/20191203040140_add_uniq_index_to_poll_votes.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddUniqIndexToPollVotes < ActiveRecord::Migration[5.2] - def change - # remove_index :poll_votes, column: [:poll_question_id, :user_id] - # - # change_column_default :poll_votes, :poll_question_id, from: nil, to: -1 - # PollVote.where(poll_answer_id: nil).update_all(poll_answer_id: -1) - # - # sql = %Q(delete from poll_votes where (poll_question_id, user_id, poll_answer_id) in - # (select * from (select poll_question_id, user_id, poll_answer_id from poll_votes group by poll_question_id, user_id, poll_answer_id having count(*) > 1) a) - # and id not in (select * from (select min(id) from poll_votes group by poll_question_id, user_id, poll_answer_id having count(*) > 1 order by id) b)) - # ActiveRecord::Base.connection.execute sql - # - # add_index :poll_votes, [:poll_question_id, :user_id, :poll_answer_id], name: 'poll_answer_index', unique: true - - end -end diff --git a/db/migrate/20191203122643_add_index_to_exercise_answers.rb b/db/migrate/20191203122643_add_index_to_exercise_answers.rb deleted file mode 100644 index 16647f2ac..000000000 --- a/db/migrate/20191203122643_add_index_to_exercise_answers.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToExerciseAnswers < ActiveRecord::Migration[5.2] - def change - add_index :exercise_answers, [:exercise_question_id, :user_id], name: "index_on_question_id_user_id" - end -end diff --git a/db/migrate/20191203124903_add_index_to_exercise_choice.rb b/db/migrate/20191203124903_add_index_to_exercise_choice.rb deleted file mode 100644 index 1babae48d..000000000 --- a/db/migrate/20191203124903_add_index_to_exercise_choice.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddIndexToExerciseChoice < ActiveRecord::Migration[5.2] - def change - change_column_default :exercise_answers, :exercise_choice_id, from: nil, to: -1 - ExerciseAnswer.where(exercise_choice_id: nil).update_all(exercise_choice_id: -1) - - sql = %Q(delete from exercise_answers where (exercise_question_id, user_id, exercise_choice_id) in - (select * from (select exercise_question_id, user_id, exercise_choice_id from exercise_answers group by exercise_question_id, user_id, exercise_choice_id having count(*) > 1) a) - and id not in (select * from (select min(id) from exercise_answers group by exercise_question_id, user_id, exercise_choice_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - - add_index :exercise_answers, [:exercise_question_id, :user_id, :exercise_choice_id], name: 'exercise_choice_index', unique: true - - remove_index :exercise_answers, name: :index_on_question_id_user_id - - end -end diff --git a/db/migrate/20191203124938_add_index_to_poll_answer.rb b/db/migrate/20191203124938_add_index_to_poll_answer.rb deleted file mode 100644 index 66319c14e..000000000 --- a/db/migrate/20191203124938_add_index_to_poll_answer.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddIndexToPollAnswer < ActiveRecord::Migration[5.2] - def change - remove_index :poll_votes, column: [:poll_question_id, :user_id] - - change_column_default :poll_votes, :poll_question_id, from: nil, to: -1 - PollVote.where(poll_answer_id: nil).update_all(poll_answer_id: -1) - - sql = %Q(delete from poll_votes where (poll_question_id, user_id, poll_answer_id) in - (select * from (select poll_question_id, user_id, poll_answer_id from poll_votes group by poll_question_id, user_id, poll_answer_id having count(*) > 1) a) - and id not in (select * from (select min(id) from poll_votes group by poll_question_id, user_id, poll_answer_id having count(*) > 1 order by id) b)) - ActiveRecord::Base.connection.execute sql - - add_index :poll_votes, [:poll_question_id, :user_id, :poll_answer_id], name: 'poll_answer_index', unique: true - end -end