diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index 45fc6c6cc..104bfdab9 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -7,6 +7,8 @@ class StatisticsController < ApplicationController def index if params[:sub_category_id].present? @statistics = Statistic.where(:sub_category_id => params[:sub_category_id]) + @statistics = Statistic.find_by_sql("SELECT statistics.*, (select sum(filesize) from attachments where attachments.container_type='Statistic' and + attachments.container_id = statistics.id group by attachments.container_id) as size from statistics where sub_category_id = #{params[:sub_category_id]} order by #{params[:type]} #{params[:order]}") else @statistics = Statistic.all end diff --git a/app/models/statistic.rb b/app/models/statistic.rb index ed51f21ed..2302bd37c 100644 --- a/app/models/statistic.rb +++ b/app/models/statistic.rb @@ -2,6 +2,8 @@ class Statistic < ActiveRecord::Base attr_accessible :description, :name, :status, :user_id, :main_category_id, :sub_category_id acts_as_attachable + validates_presence_of :main_category_id + def creator User.find self.user_id end diff --git a/db/schema.rb b/db/schema.rb index 11d616f42..700a413bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20180207065530) do +ActiveRecord::Schema.define(:version => 20180208073155) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -90,11 +90,10 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "container_id" t.string "container_type" t.integer "dealer_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "status", :limit => 1, :default => 0 t.text "apply_reason" - t.boolean "certification", :default => false end create_table "apply_add_departments", :force => true do |t| @@ -164,9 +163,8 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.string "remarks" t.integer "dealer" t.datetime "deal_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "is_delete", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "apply_user_authentications", ["user_id"], :name => "index_apply_user_authentications_on_user_id" @@ -987,9 +985,8 @@ ActiveRecord::Schema.define(:version => 20180207065530) do create_table "departments", :force => true do |t| t.string "name" t.integer "school_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "is_auth", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "departments", ["school_id"], :name => "index_departments_on_school_id" @@ -1017,7 +1014,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "challenge_id" - t.integer "reward" end add_index "discusses", ["user_id"], :name => "index_discusses_on_user_id" @@ -1086,22 +1082,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - create_table "evaluate_records", :force => true do |t| - t.integer "user_id" - t.integer "shixun_id" - t.integer "game_id" - t.integer "consume_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "file_update" - t.float "git_pull" - t.float "create_pod" - t.float "pod_execute" - t.float "student_work" - t.float "test_cases" - t.float "retry" - end - create_table "exercise_answers", :force => true do |t| t.integer "user_id" t.integer "exercise_question_id" @@ -1112,54 +1092,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "score", :default => -1 end - create_table "exercise_bank_choices", :force => true do |t| - t.integer "exercise_bank_question_id" - t.text "choice_text" - t.integer "choice_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "exercise_bank_choices", ["exercise_bank_question_id"], :name => "index_exercise_bank_choices_on_exercise_bank_question_id" - - create_table "exercise_bank_questions", :force => true do |t| - t.text "question_title" - t.integer "question_type" - t.integer "question_number" - t.integer "question_score" - t.integer "exercise_bank_id" - t.integer "max_choices" - t.integer "min_choices" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "exercise_bank_questions", ["exercise_bank_id"], :name => "index_exercise_bank_questions_on_exercise_bank_id" - - create_table "exercise_bank_standard_answers", :force => true do |t| - t.integer "exercise_bank_question_id" - t.integer "exercise_bank_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_banks", :force => true do |t| - t.string "name" - t.text "description" - t.integer "user_id" - t.boolean "is_public" - t.integer "quotes" - t.integer "container_id" - t.string "container_type" - t.integer "course_list_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "exercise_banks", ["course_list_id"], :name => "index_exercise_banks_on_course_list_id" - add_index "exercise_banks", ["user_id"], :name => "index_exercise_banks_on_user_id" - create_table "exercise_choices", :force => true do |t| t.integer "exercise_question_id" t.text "choice_text" @@ -1207,17 +1139,13 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "exercise_status" t.integer "user_id" t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "publish_time" t.datetime "end_time" t.integer "show_result" t.integer "question_random", :default => 0 t.integer "choice_random", :default => 0 - t.boolean "is_public", :default => false - t.boolean "score_open", :default => true - t.boolean "answer_open", :default => true - t.integer "exercise_bank_id" end create_table "experiences", :force => true do |t| @@ -1307,7 +1235,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.string "path" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.text "current_code", :limit => 2147483647 end create_table "game_outputs", :force => true do |t| @@ -1322,27 +1249,19 @@ ActiveRecord::Schema.define(:version => 20180207065530) do create_table "games", :force => true do |t| t.integer "myshixun_id" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "status", :default => 0 t.integer "final_score", :default => 0 t.integer "challenge_id" t.datetime "open_time" t.string "identifier" - t.boolean "answer_open", :default => false + t.boolean "answer_open" t.datetime "end_time" t.integer "retry_status", :default => 0 t.string "resubmit_identifier" end - create_table "gitlab_urls", :force => true do |t| - t.integer "myshixun_id" - t.string "url" - t.string "myshixun_identifier" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "grades", :force => true do |t| t.integer "user_id" t.integer "container_id" @@ -1465,7 +1384,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.boolean "allow_late", :default => true t.datetime "late_time" t.boolean "work_public", :default => true - t.text "explanation" end add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" @@ -1501,11 +1419,10 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "no_anon_penalty", :default => 1 t.integer "appeal_penalty", :default => 0 t.integer "ta_mode", :default => 1 + t.datetime "appeal_time" t.float "te_proportion", :default => 1.0 t.boolean "final_mode", :default => false - t.datetime "appeal_time" t.boolean "answer_open_evaluation", :default => false - t.boolean "shixun_evaluation", :default => false end create_table "homework_detail_programings", :force => true do |t| @@ -1569,19 +1486,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.datetime "updated_at", :null => false end - create_table "ii", :force => true do |t| - t.integer "project_id" - t.string "author_login" - t.string "rep_identifier" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sonar_version", :default => 0 - t.string "path" - t.string "branch" - t.string "language" - t.string "sonar_name" - end - create_table "import_students", :force => true do |t| t.string "name" t.string "student_number" @@ -1808,6 +1712,7 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "course_id", :default => -1 t.integer "course_group_id", :default => 0 t.integer "is_collect", :default => 1 + t.integer "import_student_id" end add_index "members", ["course_id"], :name => "index_members_on_course_id" @@ -1829,20 +1734,19 @@ ActiveRecord::Schema.define(:version => 20180207065530) do add_index "memo_messages", ["user_id", "forum_id", "created_at"], :name => "index_memo_messages_on_user_id_and_forum_id_and_created_at" create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false + t.integer "forum_id", :null => false t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 2147483647, :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 + t.string "subject", :null => false + t.text "content", :null => false + t.integer "author_id", :null => false + t.integer "replies_count", :default => 0 t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count", :default => 0 t.integer "root_id" - t.integer "reward" end add_index "memos", ["root_id"], :name => "index_memos_on_root_id" @@ -1859,22 +1763,22 @@ ActiveRecord::Schema.define(:version => 20180207065530) do add_index "message_alls", ["user_id", "message_id", "created_at"], :name => "index_message_alls_on_user_id_and_message_id_and_created_at" create_table "messages", :force => true do |t| - t.integer "board_id", :null => false + t.integer "board_id", :null => false t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content", :limit => 2147483647 + t.string "subject", :default => "", :null => false + t.text "content" t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false + t.integer "replies_count", :default => 0, :null => false t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 t.integer "reply_id" t.integer "quotes" - t.integer "status", :default => 0 + t.integer "status", :default => 0 t.integer "root_id" - t.integer "visits", :default => 0 + t.integer "visits", :default => 0 end add_index "messages", ["author_id"], :name => "index_messages_on_author_id" @@ -1932,21 +1836,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do add_index "mirror_update_records", ["mirror_repository_id"], :name => "index_mirror_update_records_on_mirror_repository_id" add_index "mirror_update_records", ["user_id"], :name => "index_mirror_update_records_on_user_id" - create_table "mul_tests", :force => true do |t| - t.integer "container_id" - t.string "container_type" - t.string "action" - t.integer "time" - t.integer "status", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "language" - t.integer "num" - t.string "indentifier" - t.string "name" - t.integer "shixun_id" - end - create_table "myshixun_members", :force => true do |t| t.integer "myshixun_id" t.integer "user_id" @@ -1963,18 +1852,13 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "user_id" t.integer "gpid" t.integer "visits", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "status", :default => 0 t.string "identifier" t.string "commit_id" - t.datetime "modify_time" - t.datetime "reset_time" - t.boolean "system_tip", :default => false end - add_index "myshixuns", ["user_id", "shixun_id"], :name => "index_myshixuns_on_user_id_and_shixun_id", :unique => true - create_table "news", :force => true do |t| t.integer "project_id" t.string "title", :limit => 60, :default => "", :null => false @@ -2215,11 +2099,8 @@ ActiveRecord::Schema.define(:version => 20180207065530) do create_table "poll_users", :force => true do |t| t.integer "user_id" t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "commit_status", :default => 0 - t.datetime "start_at" - t.datetime "end_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "poll_votes", :force => true do |t| @@ -2234,20 +2115,24 @@ ActiveRecord::Schema.define(:version => 20180207065530) do create_table "polls", :force => true do |t| t.string "polls_name" t.string "polls_type" - t.integer "course_id" + t.integer "polls_group_id" t.integer "polls_status" t.integer "user_id" - t.datetime "publish_time" - t.datetime "end_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "published_at" + t.datetime "closed_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "polls_description" t.integer "show_result", :default => 1 - t.integer "exercise_bank_id" - t.boolean "is_public", :default => false end - add_index "polls", ["course_id"], :name => "index_polls_on_course_id" + create_table "pr_paths", :force => true do |t| + t.integer "project_id" + t.integer "gitlab_project_id" + t.string "path" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end create_table "praise_tread_caches", :force => true do |t| t.integer "object_id", :null => false @@ -2409,18 +2294,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do add_index "queries", ["project_id"], :name => "index_queries_on_project_id" add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - create_table "question_banks", :force => true do |t| - t.text "name" - t.integer "container_id" - t.string "container_type" - t.integer "quotes" - t.integer "user_id" - t.boolean "is_public" - t.integer "course_list_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "reference_materials", :force => true do |t| t.string "book" t.string "editor" @@ -2492,6 +2365,15 @@ ActiveRecord::Schema.define(:version => 20180207065530) do add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" + create_table "repository_paths", :force => true do |t| + t.string "path" + t.integer "myshixun_id" + t.integer "user_id" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "resource_banks", :force => true do |t| t.integer "course_id" t.integer "attachment_id" @@ -2551,7 +2433,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.string "city" t.string "address" t.boolean "auto_users_trial", :default => false - t.string "shool_code" end create_table "secdomains", :force => true do |t| @@ -2676,10 +2557,12 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "changeset_num" t.integer "status", :default => 0 t.string "language" - t.boolean "authentication", :default => false t.string "identifier" + t.boolean "authentication", :default => false t.integer "myshixun_count", :default => 0 + t.string "exec_path" t.text "propaedeutics", :limit => 2147483647 + t.integer "is_updated", :default => 0 t.boolean "webssh", :default => false t.integer "trainee", :default => 1 t.integer "major_id" @@ -2687,9 +2570,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.boolean "hidden", :default => false t.integer "fork_from" t.boolean "can_copy", :default => false - t.datetime "modify_time" - t.datetime "reset_time" - t.datetime "publish_time" end create_table "softapplications", :force => true do |t| @@ -2767,6 +2647,7 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.datetime "updated_at", :null => false t.integer "main_category_id" t.integer "sub_category_id" + t.integer "size", :default => 0 end create_table "student_work_projects", :force => true do |t| @@ -2823,7 +2704,6 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.text "late_reason" t.integer "group_id", :default => 0 t.integer "myshixun_id" - t.datetime "update_time" end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" @@ -3025,19 +2905,15 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "position" end - create_table "tidings", :force => true do |t| + create_table "tests", :force => true do |t| t.integer "user_id" - t.integer "trigger_user_id" - t.integer "container_id" - t.string "container_type" - t.integer "parent_container_id" - t.string "parent_container_type" - t.integer "belong_container_id" - t.string "belong_container_type" - t.integer "status" - t.boolean "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "username" + t.integer "change_id" + t.string "pr_path" + t.integer "project_id" + t.integer "gpid" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "time_entries", :force => true do |t| @@ -3088,7 +2964,7 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.datetime "updated_at", :null => false t.integer "author_id" t.integer "status", :limit => 1, :default => 0 - t.integer "position", :limit => 1, :default => 0 + t.integer "position", :limit => 1 t.integer "result", :default => 0 end @@ -3274,6 +3150,37 @@ ActiveRecord::Schema.define(:version => 20180207065530) do t.integer "authentication_id" end + create_table "users_copy", :force => true do |t| + t.string "login", :default => "", :null => false + t.string "hashed_password", :limit => 40, :default => "", :null => false + t.string "firstname", :limit => 30, :default => "", :null => false + t.string "lastname", :default => "", :null => false + t.string "mail", :limit => 60, :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "status", :default => 1, :null => false + t.datetime "last_login_on" + t.string "language", :limit => 5, :default => "" + t.integer "auth_source_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "type" + t.string "identity_url" + t.string "mail_notification", :default => "", :null => false + t.string "salt", :limit => 64 + t.integer "gid" + t.integer "visits", :default => 0 + t.integer "excellent_teacher", :default => 0 + t.integer "excellent_student", :default => 0 + t.string "phone" + t.boolean "authentication", :default => false + t.integer "grade" + t.integer "experience", :default => 0 + end + + add_index "users_copy", ["auth_source_id"], :name => "index_users_on_auth_source_id" + add_index "users_copy", ["id", "type"], :name => "index_users_on_id_and_type" + add_index "users_copy", ["type"], :name => "index_users_on_type" + create_table "verification_codes", :force => true do |t| t.string "code" t.integer "code_type"