# HG changeset patch # User Nattee Niparnan # Date 2020-04-04 08:37:50 # Node ID 3241620ac7e73339e54707672eeacabe6cbd0419 # Parent 6a311ff470662c1e5758bff16a1c1dd818c334f3 submission stat diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,37 +5,37 @@ ZenTest (~> 4.3) ZenTest (4.11.2) ace-rails-ap (4.2) - actioncable (5.2.3) - actionpack (= 5.2.3) + actioncable (5.2.4.2) + actionpack (= 5.2.4.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) + actionmailer (5.2.4.2) + actionpack (= 5.2.4.2) + actionview (= 5.2.4.2) + activejob (= 5.2.4.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) - rack (~> 2.0) + actionpack (5.2.4.2) + actionview (= 5.2.4.2) + activesupport (= 5.2.4.2) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.3) - activesupport (= 5.2.3) + actionview (5.2.4.2) + activesupport (= 5.2.4.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.3) - activesupport (= 5.2.3) + activejob (5.2.4.2) + activesupport (= 5.2.4.2) globalid (>= 0.3.6) - activemodel (5.2.3) - activesupport (= 5.2.3) - activerecord (5.2.3) - activemodel (= 5.2.3) - activesupport (= 5.2.3) + activemodel (5.2.4.2) + activesupport (= 5.2.4.2) + activerecord (5.2.4.2) + activemodel (= 5.2.4.2) + activesupport (= 5.2.4.2) arel (>= 9.0) activerecord-session_store (1.1.3) actionpack (>= 4.0) @@ -43,26 +43,26 @@ multi_json (~> 1.11, >= 1.11.2) rack (>= 1.5.2, < 3) railties (>= 4.0) - activestorage (5.2.3) - actionpack (= 5.2.3) - activerecord (= 5.2.3) + activestorage (5.2.4.2) + actionpack (= 5.2.4.2) + activerecord (= 5.2.4.2) marcel (~> 0.3.1) - activesupport (5.2.3) + activesupport (5.2.4.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.6.0) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) ansi (1.5.0) arel (9.0.0) - autoprefixer-rails (9.5.1.1) + autoprefixer-rails (9.5.1) execjs best_in_place (3.0.3) actionpack (>= 3.2) railties (>= 3.2) - bindex (0.7.0) - bootsnap (1.4.4) + bindex (0.8.1) + bootsnap (1.4.6) msgpack (~> 1.0) bootstrap-datepicker-rails (1.8.0.1) railties (>= 3.0) @@ -73,21 +73,17 @@ bootstrap-toggle-rails (2.2.1.0) bootstrap3-datetimepicker-rails (4.17.47) momentjs-rails (>= 2.8.1) - builder (3.2.3) + builder (3.2.4) byebug (11.0.1) - capybara (3.25.0) + capybara (3.15.1) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.5) + regexp_parser (~> 1.2) xpath (~> 3.2) - capybara-console (0.0.4) - capybara - rails (>= 3.0) - childprocess (1.0.1) - rake (< 13.0) + childprocess (3.0.0) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -95,18 +91,18 @@ coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.5) - crass (1.0.4) + concurrent-ruby (1.1.6) + crass (1.0.6) dynamic_form (1.1.4) - erubi (1.8.0) + erubi (1.9.0) erubis (2.7.0) execjs (2.7.0) - ffi (1.11.1) + ffi (1.10.0) fuzzy-string-match (1.0.1) RubyInline (>= 3.8.6) globalid (0.4.2) activesupport (>= 4.2.0) - haml (5.1.0) + haml (5.0.4) temple (>= 0.8.0) tilt haml-rails (1.0.0) @@ -120,11 +116,11 @@ haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - i18n (1.6.0) + i18n (1.8.2) concurrent-ruby (~> 1.0) in_place_editing (1.2.0) - jbuilder (2.9.1) - activesupport (>= 4.2.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) jquery-countdown-rails (2.0.2) jquery-datatables-rails (3.4.0) actionpack (>= 3.1) @@ -145,18 +141,18 @@ rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.2.3) + loofah (2.4.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - method_source (0.9.2) - mimemagic (0.3.3) - mini_mime (1.0.1) + method_source (1.0.0) + mimemagic (0.3.4) + mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.11.3) + minitest (5.14.0) minitest-reporters (1.3.6) ansi builder @@ -164,30 +160,30 @@ ruby-progressbar momentjs-rails (2.20.1) railties (>= 3.1) - msgpack (1.3.0) + msgpack (1.3.3) multi_json (1.13.1) mysql2 (0.5.2) - nio4r (2.3.1) - nokogiri (1.10.3) + nio4r (2.5.2) + nokogiri (1.10.9) mini_portile2 (~> 2.4.0) - public_suffix (3.1.1) - puma (4.0.0) + public_suffix (4.0.3) + puma (4.3.3) nio4r (~> 2.0) - rack (2.0.7) + rack (2.2.2) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.3) - actioncable (= 5.2.3) - actionmailer (= 5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) - activemodel (= 5.2.3) - activerecord (= 5.2.3) - activestorage (= 5.2.3) - activesupport (= 5.2.3) + rails (5.2.4.2) + actioncable (= 5.2.4.2) + actionmailer (= 5.2.4.2) + actionpack (= 5.2.4.2) + actionview (= 5.2.4.2) + activejob (= 5.2.4.2) + activemodel (= 5.2.4.2) + activerecord (= 5.2.4.2) + activestorage (= 5.2.4.2) + activesupport (= 5.2.4.2) bundler (>= 1.3.0) - railties (= 5.2.3) + railties (= 5.2.4.2) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.4) actionpack (>= 5.0.1.x) @@ -196,28 +192,28 @@ rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) rails_bootstrap_sortable (2.0.6) momentjs-rails (>= 2.8.3) - railties (5.2.3) - actionpack (= 5.2.3) - activesupport (= 5.2.3) + railties (5.2.4.2) + actionpack (= 5.2.4.2) + activesupport (= 5.2.4.2) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rake (12.3.2) + rake (13.0.1) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) rdiscount (2.2.0.1) - regexp_parser (1.5.1) + regexp_parser (1.7.0) rouge (3.3.0) ruby-progressbar (1.10.0) ruby_dep (1.5.0) ruby_parser (3.13.1) sexp_processor (~> 4.9) - rubyzip (1.2.3) + rubyzip (1.3.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -229,10 +225,9 @@ sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sassc (2.0.1) + sassc (2.2.1) ffi (~> 1.9) - rake - sassc-rails (2.1.1) + sassc-rails (2.1.2) railties (>= 4.0.0) sassc (>= 2.0) sprockets (> 3.0) @@ -240,14 +235,15 @@ tilt select2-rails (4.0.3) thor (~> 0.14) - selenium-webdriver (3.142.3) - childprocess (>= 0.5, < 2.0) - rubyzip (~> 1.2, >= 1.2.2) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) sexp_processor (4.12.0) - simple_form (4.1.0) + simple_form (5.0.2) actionpack (>= 5.0) activemodel (>= 5.0) - spring (2.1.0) + spring (2.0.2) + activesupport (>= 4.2) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) @@ -263,7 +259,7 @@ thor (0.20.3) thread_safe (0.3.6) tilt (2.0.9) - tzinfo (1.2.5) + tzinfo (1.2.7) thread_safe (~> 0.1) uglifier (4.1.20) execjs (>= 0.3.0, < 3) @@ -272,7 +268,7 @@ activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - webdriver (0.1.0) + webdriver (0.5.0) websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) @@ -299,7 +295,6 @@ bootstrap3-datetimepicker-rails byebug capybara (>= 2.15) - capybara-console coffee-rails dynamic_form fuzzy-string-match @@ -338,4 +333,4 @@ yaml_db BUNDLED WITH - 1.17.2 + 1.16.2 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -164,4 +164,65 @@ return true end + #function for datatable ajax query + #return record,total_count,filter_count + def process_query_record(record, + total_count: nil, + select: '', + global_search: [], + no_search: false, + force_order: '', + date_filter: '', date_param_since: 'date_since',date_param_until: 'date_until') + arel_table = record.model.arel_table + + if !no_search && params['search'] + global_value = record.model.sanitize_sql(params['search']['value'].strip.downcase) + if !global_value.blank? + global_value.split.each do |value| + global_where = global_search.map{|f| "LOWER(#{f}) like '%#{value}%'"}.join(' OR ') + record = record.where(global_where) + end + end + + params['columns'].each do |i, col| + if !col['search']['value'].blank? + record = record.where(arel_table[col['name']].lower.matches("%#{col['search']['value'].strip.downcase}%")) + end + end + end + + if !date_filter.blank? + date_since = Time.parse( params[:date_since] ) rescue Time.new(1,1,1) + date_until = Time.parse( params[:date_until] ) rescue Time.zone.now() + date_range = date_since..date_until + record = record.where(date_filter.to_sym => date_range) + end + + if force_order.blank? + if params['order'] + params['order'].each do |i, o| + colName = params['columns'][o['column']]['name'] + colName = "#{record.model.table_name}.#{colName}" if colName.upcase == 'ID' + record = record.order("#{colName} #{o['dir'].casecmp('desc') != 0 ? 'ASC' : 'DESC'}") unless colName.blank? + end + end + else + record = record.order(force_order) + end + + filterCount = record.count(record.model.primary_key) + # if .group() is used, filterCount might be like {id_1: count_1, id_2: count_2, ...} + # so we should count the result again.. + if filterCount.is_a? Hash + filterCount = filterCount.count + end + + record = record.offset(params['start'] || 0).limit(params['length'] || 100) + if (!select.blank?) + record = record.select(select) + end + + return record, total_count || record.model.count, filterCount + end + end diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -142,8 +142,7 @@ end end - def submission_stat - + def submission date_and_time = '%Y-%m-%d %H:%M' begin @since_time = DateTime.strptime(params[:since_datetime],date_and_time) @@ -156,25 +155,22 @@ @until_time = DateTime.new(3000,1,1) end - @submissions = {} - - User.find_each do |user| - @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } } - end + @submissions = Submission + .joins(:problem).joins(:user) + .where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time) + end - Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s| - if @submissions[s.user_id] - if not @submissions[s.user_id][:sub].has_key?(s.problem_id) - a = Problem.find_by_id(s.problem_id) - @submissions[s.user_id][:sub][s.problem_id] = - { prob_name: (a ? a.full_name : '(NULL)'), - sub_ids: [s.id] } - else - @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id - end - @submissions[s.user_id][:count] += 1 - end - end + def submission_query + @submissions = Submission + .joins(:problem).joins(:user) + .where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time) + + @submissions, @recordsTotal, @recordsFiltered = process_query_record( @submissions, + global_search: ['user.login','user.full_name','problem.name','problem.full_name','points'], + date_filter: 'submitted_at', + date_param_since: 'since_datetime', + date_param_until: 'until_datetime', + ) end def problem_hof diff --git a/app/views/report/submission.html.haml b/app/views/report/submission.html.haml new file mode 100644 --- /dev/null +++ b/app/views/report/submission.html.haml @@ -0,0 +1,61 @@ +- content_for :header do + = javascript_include_tag 'local_jquery' + +%h1 Submissions detail + +.row + .col-md-4 + = render partial: 'shared/problem_select' + .col-md-4 + = render partial: 'shared/problem_select' + .col-md-4 + = render partial: 'shared/user_select' + + +.row + .col-12 + %table.table.table-hover.table-condense.datatable + -# + %thead + %tr + %th User + %th Problem + %th Subbmission ID + %th Submit Time + %th Score + %th detail + %tbody + - @submissions.each do |s| + %tr + %td= s.user.login + %td= s.problem.long_name + %td= s.id + %td= s.submitted_at + %td= s.points + %td= s.grader_comment + + +:javascript + $('.datatable').DataTable({ + columns: [ + {title: 'User', data: 'login'}, + {title: 'Problem', data: 'problem.long_name'}, + {title: 'Sub ID', data: 'id'}, + {title: 'Submit at', data: 'submitted_at'}, + {title: 'Points', data: 'points'}, + {title: 'detail', data: 'grader_comment'}, + ], + ajax: { + url: '#{submission_query_report_path}', + type: 'POST', + data: (d) => { + d.since_datetime = '1123' + d.until_datetime = 'xxx' + }, + dataType: 'json', + beforeSend: (request) => { + request.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content')); + }, + }, //end ajax + 'pageLength': 50 + }); diff --git a/app/views/report/submission_query.json.jbuilder b/app/views/report/submission_query.json.jbuilder new file mode 100644 --- /dev/null +++ b/app/views/report/submission_query.json.jbuilder @@ -0,0 +1,15 @@ +json.draw params['draw']&.to_i +json.recordsTotal @recordsTotal +json.recordsFiltered @recordsFiltered +json.data do + json.array! @submissions do |sub| + json.extact! sub, :id, :points, :grader_comment + json.submitted_at sub.submitted_at + json.problem do + json.long_name sub.problem&.long_name + end + json.user do + json.login sub.user&.login + end + end +end diff --git a/app/views/report/submission_stat.html.haml b/app/views/report/submission_stat.html.haml deleted file mode 100644 --- a/app/views/report/submission_stat.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -- content_for :header do - = javascript_include_tag 'local_jquery' - -%script{:type=>"text/javascript"} - $(function () { - $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); - $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); - }); - -%h1 Login status - -=render partial: 'report_menu' -=render partial: 'date_range', locals: {param_text: 'Submission date range:', title: 'Query submission stat in the range' } - -%table.info - %thead - %tr.info-head - %th login - %th full name - %th total submissions - %th submissions - %tbody - - @submissions.each do |user_id,data| - %tr{class: cycle('info-even','info-odd')} - %td= data[:login] - %td= data[:full_name] - %td= data[:count] - %td - - data[:sub].each do |prob_id,sub_data| - = "#{sub_data[:prob_name]}: [" - - st = [] - - sub_data[:sub_ids].each do |id| - - st << link_to(id, controller: 'graders' , action: 'submission', id: id) - = raw st.join ', ' - = ']' - %br/ - diff --git a/app/views/shared/_problem_select.html.haml b/app/views/shared/_problem_select.html.haml new file mode 100644 --- /dev/null +++ b/app/views/shared/_problem_select.html.haml @@ -0,0 +1,10 @@ +.panel.panel-primary + .panel-heading + Problems + .panel-body + %p + Select problem(s) that we wish to know the score. + = label_tag :problem_id, "Problems" + = select_tag 'problem_id[]', + options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},params[:problem_id]), + { class: 'select2 form-control', multiple: "true" } diff --git a/app/views/shared/_user_select.html.haml b/app/views/shared/_user_select.html.haml new file mode 100644 --- /dev/null +++ b/app/views/shared/_user_select.html.haml @@ -0,0 +1,12 @@ +.panel.panel-primary + .panel-heading + Users + .panel-body + .radio + %label + = radio_button_tag 'users', 'all', (params[:users] == "all") + All users + .radio + %label + = radio_button_tag 'users', 'enabled', (params[:users] == "enabled") + Only enabled users diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -152,6 +152,8 @@ post 'cheat_report' get 'cheat_scruntinize' post 'cheat_scruntinize' + get 'submission' + post 'submission_query' end #get 'report/current_score', to: 'report#current_score', as: 'report_current_score' #get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,298 +11,311 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_06_12_102327) do +ActiveRecord::Schema.define(version: 20180612102327) do - create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "author" - t.text "body" - t.boolean "published" + create_table "announcements", force: :cascade do |t| + t.string "author", limit: 255 + t.text "body", limit: 65535 + t.boolean "published" t.datetime "created_at" t.datetime "updated_at" - t.boolean "frontpage", default: false - t.boolean "contest_only", default: false - t.string "title" - t.string "notes" + t.boolean "frontpage", default: false + t.boolean "contest_only", default: false + t.string "title", limit: 255 + t.string "notes", limit: 255 end - create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "title" - t.boolean "enabled" + create_table "contests", force: :cascade do |t| + t.string "title", limit: 255 + t.boolean "enabled" t.datetime "created_at" t.datetime "updated_at" - t.string "name" + t.string "name", limit: 255 end - create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "contest_id" - t.integer "problem_id" + create_table "contests_problems", id: false, force: :cascade do |t| + t.integer "contest_id", limit: 4 + t.integer "problem_id", limit: 4 end - create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "contest_id" - t.integer "user_id" + create_table "contests_users", id: false, force: :cascade do |t| + t.integer "contest_id", limit: 4 + t.integer "user_id", limit: 4 end - create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name" + create_table "countries", force: :cascade do |t| + t.string "name", limit: 255 t.datetime "created_at" t.datetime "updated_at" end - create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.text "body" - t.boolean "markdowned" + create_table "descriptions", force: :cascade do |t| + t.text "body", limit: 65535 + t.boolean "markdowned" t.datetime "created_at" t.datetime "updated_at" end - create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "key" - t.string "value_type" - t.string "value" + create_table "grader_configurations", force: :cascade do |t| + t.string "key", limit: 255 + t.string "value_type", limit: 255 + t.string "value", limit: 255 t.datetime "created_at" t.datetime "updated_at" - t.text "description" + t.text "description", limit: 65535 end - create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "host" - t.integer "pid" - t.string "mode" - t.boolean "active" + create_table "grader_processes", force: :cascade do |t| + t.string "host", limit: 255 + t.integer "pid", limit: 4 + t.string "mode", limit: 255 + t.boolean "active" t.datetime "created_at" t.datetime "updated_at" - t.integer "task_id" - t.string "task_type" - t.boolean "terminated" - t.index ["host", "pid"], name: "index_grader_processes_on_host_and_pid" + t.integer "task_id", limit: 4 + t.string "task_type", limit: 255 + t.boolean "terminated" end - create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name" - t.string "description" + add_index "grader_processes", ["host", "pid"], name: "index_grader_processes_on_host_and_pid", using: :btree + + create_table "groups", force: :cascade do |t| + t.string "name", limit: 255 + t.string "description", limit: 255 end - create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "problem_id", null: false - t.integer "group_id", null: false - t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id" + create_table "groups_problems", id: false, force: :cascade do |t| + t.integer "problem_id", limit: 4, null: false + t.integer "group_id", limit: 4, null: false end - create_table "groups_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "group_id", null: false - t.integer "user_id", null: false - t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id" + add_index "groups_problems", ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id", using: :btree + + create_table "groups_users", id: false, force: :cascade do |t| + t.integer "group_id", limit: 4, null: false + t.integer "user_id", limit: 4, null: false end - create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "user_id" - t.string "ip_address" + add_index "groups_users", ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id", using: :btree + + create_table "heart_beats", force: :cascade do |t| + t.integer "user_id", limit: 4 + t.string "ip_address", limit: 255 t.datetime "created_at" t.datetime "updated_at" - t.string "status" - t.index ["updated_at"], name: "index_heart_beats_on_updated_at" + t.string "status", limit: 255 end - create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name", limit: 10 - t.string "pretty_name" - t.string "ext", limit: 10 - t.string "common_ext" + add_index "heart_beats", ["updated_at"], name: "index_heart_beats_on_updated_at", using: :btree + + create_table "languages", force: :cascade do |t| + t.string "name", limit: 10 + t.string "pretty_name", limit: 255 + t.string "ext", limit: 10 + t.string "common_ext", limit: 255 end - create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "user_id" - t.string "ip_address" + create_table "logins", force: :cascade do |t| + t.integer "user_id", limit: 4 + t.string "ip_address", limit: 255 t.datetime "created_at" t.datetime "updated_at" end - create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "sender_id" - t.integer "receiver_id" - t.integer "replying_message_id" - t.text "body" - t.boolean "replied" + create_table "messages", force: :cascade do |t| + t.integer "sender_id", limit: 4 + t.integer "receiver_id", limit: 4 + t.integer "replying_message_id", limit: 4 + t.text "body", limit: 65535 + t.boolean "replied" t.datetime "created_at" t.datetime "updated_at" end - create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name", limit: 30 - t.string "full_name" - t.integer "full_score" - t.date "date_added" + create_table "problems", force: :cascade do |t| + t.string "name", limit: 30 + t.string "full_name", limit: 255 + t.integer "full_score", limit: 4 + t.date "date_added" t.boolean "available" - t.string "url" - t.integer "description_id" + t.string "url", limit: 255 + t.integer "description_id", limit: 4 t.boolean "test_allowed" t.boolean "output_only" - t.string "description_filename" + t.string "description_filename", limit: 255 t.boolean "view_testcase" end - create_table "problems_tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "problem_id" - t.integer "tag_id" - t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true - t.index ["problem_id"], name: "index_problems_tags_on_problem_id" - t.index ["tag_id"], name: "index_problems_tags_on_tag_id" + create_table "problems_tags", force: :cascade do |t| + t.integer "problem_id", limit: 4 + t.integer "tag_id", limit: 4 end - create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name" - t.string "controller" - t.string "action" + add_index "problems_tags", ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true, using: :btree + add_index "problems_tags", ["problem_id"], name: "index_problems_tags_on_problem_id", using: :btree + add_index "problems_tags", ["tag_id"], name: "index_problems_tags_on_tag_id", using: :btree + + create_table "rights", force: :cascade do |t| + t.string "name", limit: 255 + t.string "controller", limit: 255 + t.string "action", limit: 255 end - create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "right_id" - t.integer "role_id" - t.index ["role_id"], name: "index_rights_roles_on_role_id" + create_table "rights_roles", id: false, force: :cascade do |t| + t.integer "right_id", limit: 4 + t.integer "role_id", limit: 4 end - create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name" + add_index "rights_roles", ["role_id"], name: "index_rights_roles_on_role_id", using: :btree + + create_table "roles", force: :cascade do |t| + t.string "name", limit: 255 end - create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "role_id" - t.integer "user_id" - t.index ["user_id"], name: "index_roles_users_on_user_id" + create_table "roles_users", id: false, force: :cascade do |t| + t.integer "role_id", limit: 4 + t.integer "user_id", limit: 4 end - create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "session_id" - t.text "data" + add_index "roles_users", ["user_id"], name: "index_roles_users_on_user_id", using: :btree + + create_table "sessions", force: :cascade do |t| + t.string "session_id", limit: 255 + t.text "data", limit: 65535 t.datetime "updated_at" - t.index ["session_id"], name: "index_sessions_on_session_id" - t.index ["updated_at"], name: "index_sessions_on_updated_at" end - create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name" - t.boolean "started" + add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree + add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree + + create_table "sites", force: :cascade do |t| + t.string "name", limit: 255 + t.boolean "started" t.datetime "start_time" t.datetime "created_at" t.datetime "updated_at" - t.integer "country_id" - t.string "password" + t.integer "country_id", limit: 4 + t.string "password", limit: 255 end - create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "user_id" - t.integer "submission_id" + create_table "submission_view_logs", force: :cascade do |t| + t.integer "user_id", limit: 4 + t.integer "submission_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" end - create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "user_id" - t.integer "problem_id" - t.integer "language_id" - t.text "source", limit: 16777215 - t.binary "binary" + create_table "submissions", force: :cascade do |t| + t.integer "user_id", limit: 4 + t.integer "problem_id", limit: 4 + t.integer "language_id", limit: 4 + t.text "source", limit: 16777215 + t.binary "binary", limit: 65535 t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message" + t.text "compiler_message", limit: 65535 t.datetime "graded_at" - t.integer "points" - t.text "grader_comment" - t.integer "number" - t.string "source_filename" - t.float "max_runtime" - t.integer "peak_memory" - t.integer "effective_code_length" - t.string "ip_address" - t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true - t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id" + t.integer "points", limit: 4 + t.text "grader_comment", limit: 65535 + t.integer "number", limit: 4 + t.string "source_filename", limit: 255 + t.float "max_runtime", limit: 24 + t.integer "peak_memory", limit: 4 + t.integer "effective_code_length", limit: 4 + t.string "ip_address", limit: 255 end - create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "name", null: false - t.text "description" - t.boolean "public" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + add_index "submissions", ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true, using: :btree + add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id", using: :btree + + create_table "tags", force: :cascade do |t| + t.string "name", limit: 255, null: false + t.text "description", limit: 65535 + t.boolean "public" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "submission_id" + create_table "tasks", force: :cascade do |t| + t.integer "submission_id", limit: 4 t.datetime "created_at" - t.integer "status" + t.integer "status", limit: 4 t.datetime "updated_at" - t.index ["submission_id"], name: "index_tasks_on_submission_id" end - create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "problem_id" - t.text "input", limit: 16777215 - t.text "solution", limit: 16777215 + add_index "tasks", ["submission_id"], name: "index_tasks_on_submission_id", using: :btree + + create_table "test_pairs", force: :cascade do |t| + t.integer "problem_id", limit: 4 + t.text "input", limit: 16777215 + t.text "solution", limit: 16777215 t.datetime "created_at" t.datetime "updated_at" end - create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "user_id" - t.integer "problem_id" - t.integer "submission_id" - t.string "input_file_name" - t.string "output_file_name" - t.string "running_stat" - t.integer "status" + create_table "test_requests", force: :cascade do |t| + t.integer "user_id", limit: 4 + t.integer "problem_id", limit: 4 + t.integer "submission_id", limit: 4 + t.string "input_file_name", limit: 255 + t.string "output_file_name", limit: 255 + t.string "running_stat", limit: 255 + t.integer "status", limit: 4 t.datetime "updated_at" t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message" + t.text "compiler_message", limit: 65535 t.datetime "graded_at" - t.string "grader_comment" + t.string "grader_comment", limit: 255 t.datetime "created_at" - t.float "running_time" - t.string "exit_status" - t.integer "memory_usage" - t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id" + t.float "running_time", limit: 24 + t.string "exit_status", limit: 255 + t.integer "memory_usage", limit: 4 end - create_table "testcases", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "problem_id" - t.integer "num" - t.integer "group" - t.integer "score" - t.text "input", limit: 4294967295 - t.text "sol", limit: 4294967295 + add_index "test_requests", ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id", using: :btree + + create_table "testcases", force: :cascade do |t| + t.integer "problem_id", limit: 4 + t.integer "num", limit: 4 + t.integer "group", limit: 4 + t.integer "score", limit: 4 + t.text "input", limit: 4294967295 + t.text "sol", limit: 4294967295 t.datetime "created_at" t.datetime "updated_at" - t.index ["problem_id"], name: "index_testcases_on_problem_id" end - create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.integer "user_id" + add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id", using: :btree + + create_table "user_contest_stats", force: :cascade do |t| + t.integer "user_id", limit: 4 t.datetime "started_at" t.datetime "created_at" t.datetime "updated_at" - t.boolean "forced_logout" + t.boolean "forced_logout" end - create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| - t.string "login", limit: 50 - t.string "full_name" - t.string "hashed_password" - t.string "salt", limit: 5 - t.string "alias" - t.string "email" - t.integer "site_id" - t.integer "country_id" - t.boolean "activated", default: false + create_table "users", force: :cascade do |t| + t.string "login", limit: 50 + t.string "full_name", limit: 255 + t.string "hashed_password", limit: 255 + t.string "salt", limit: 5 + t.string "alias", limit: 255 + t.string "email", limit: 255 + t.integer "site_id", limit: 4 + t.integer "country_id", limit: 4 + t.boolean "activated", default: false t.datetime "created_at" t.datetime "updated_at" - t.string "section" - t.boolean "enabled", default: true - t.string "remark" - t.string "last_ip" - t.index ["login"], name: "index_users_on_login", unique: true + t.string "section", limit: 255 + t.boolean "enabled", default: true + t.string "remark", limit: 255 + t.string "last_ip", limit: 255 end + add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree + add_foreign_key "problems_tags", "problems" add_foreign_key "problems_tags", "tags" end