Description:
merge
Commit status:
[Not Reviewed]
References:
merge algo
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r466:b99651140f6d - - 3 files changed: 2 inserted, 2 deleted

@@ -97,48 +97,49
97 # get selected problems or the default
97 # get selected problems or the default
98 if params[:id]
98 if params[:id]
99 begin
99 begin
100 @problem = Problem.available.find(params[:id])
100 @problem = Problem.available.find(params[:id])
101 rescue
101 rescue
102 redirect_to action: :problem_hof
102 redirect_to action: :problem_hof
103 flash[:notice] = 'Error: submissions for that problem are not viewable.'
103 flash[:notice] = 'Error: submissions for that problem are not viewable.'
104 return
104 return
105 end
105 end
106 end
106 end
107
107
108 return unless @problem
108 return unless @problem
109
109
110 @by_lang = {} #aggregrate by language
110 @by_lang = {} #aggregrate by language
111
111
112 range =65
112 range =65
113 @histogram = { data: Array.new(range,0), summary: {} }
113 @histogram = { data: Array.new(range,0), summary: {} }
114 @summary = {count: 0, solve: 0, attempt: 0}
114 @summary = {count: 0, solve: 0, attempt: 0}
115 user = Hash.new(0)
115 user = Hash.new(0)
116 Submission.where(problem_id: @problem.id).find_each do |sub|
116 Submission.where(problem_id: @problem.id).find_each do |sub|
117 #histogram
117 #histogram
118 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
118 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
119 @histogram[:data][d.to_i] += 1 if d < range
119 @histogram[:data][d.to_i] += 1 if d < range
120
120
121 + next unless sub.points
121 @summary[:count] += 1
122 @summary[:count] += 1
122 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
123 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
123
124
124 lang = Language.find_by_id(sub.language_id)
125 lang = Language.find_by_id(sub.language_id)
125 next unless lang
126 next unless lang
126 next unless sub.points >= @problem.full_score
127 next unless sub.points >= @problem.full_score
127
128
128 #initialize
129 #initialize
129 unless @by_lang.has_key?(lang.pretty_name)
130 unless @by_lang.has_key?(lang.pretty_name)
130 @by_lang[lang.pretty_name] = {
131 @by_lang[lang.pretty_name] = {
131 runtime: { avail: false, value: 2**30-1 },
132 runtime: { avail: false, value: 2**30-1 },
132 memory: { avail: false, value: 2**30-1 },
133 memory: { avail: false, value: 2**30-1 },
133 length: { avail: false, value: 2**30-1 },
134 length: { avail: false, value: 2**30-1 },
134 first: { avail: false, value: DateTime.new(3000,1,1) }
135 first: { avail: false, value: DateTime.new(3000,1,1) }
135 }
136 }
136 end
137 end
137
138
138 if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value]
139 if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value]
139 @by_lang[lang.pretty_name][:runtime] = { avail: true, user_id: sub.user_id, value: sub.max_runtime, sub_id: sub.id }
140 @by_lang[lang.pretty_name][:runtime] = { avail: true, user_id: sub.user_id, value: sub.max_runtime, sub_id: sub.id }
140 end
141 end
141
142
142 if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value]
143 if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value]
143 @by_lang[lang.pretty_name][:memory] = { avail: true, user_id: sub.user_id, value: sub.peak_memory, sub_id: sub.id }
144 @by_lang[lang.pretty_name][:memory] = { avail: true, user_id: sub.user_id, value: sub.peak_memory, sub_id: sub.id }
144 end
145 end
@@ -218,30 +218,29
218 end
218 end
219
219
220 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
220 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
221
221
222 create_table "user_contest_stats", :force => true do |t|
222 create_table "user_contest_stats", :force => true do |t|
223 t.integer "user_id"
223 t.integer "user_id"
224 t.datetime "started_at"
224 t.datetime "started_at"
225 t.datetime "created_at", :null => false
225 t.datetime "created_at", :null => false
226 t.datetime "updated_at", :null => false
226 t.datetime "updated_at", :null => false
227 t.boolean "forced_logout"
227 t.boolean "forced_logout"
228 end
228 end
229
229
230 create_table "users", :force => true do |t|
230 create_table "users", :force => true do |t|
231 t.string "login", :limit => 50
231 t.string "login", :limit => 50
232 t.string "full_name"
232 t.string "full_name"
233 t.string "hashed_password"
233 t.string "hashed_password"
234 t.string "salt", :limit => 5
234 t.string "salt", :limit => 5
235 t.string "alias"
235 t.string "alias"
236 t.string "email"
236 t.string "email"
237 t.integer "site_id"
237 t.integer "site_id"
238 t.integer "country_id"
238 t.integer "country_id"
239 t.boolean "activated", :default => false
239 t.boolean "activated", :default => false
240 t.datetime "created_at"
240 t.datetime "created_at"
241 t.datetime "updated_at"
241 t.datetime "updated_at"
242 - t.string "section"
243 end
242 end
244
243
245 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
244 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
246
245
247 end
246 end
@@ -79,49 +79,49
79 {
79 {
80 :key => 'system.online_registration.from',
80 :key => 'system.online_registration.from',
81 :value_type => 'string',
81 :value_type => 'string',
82 :default_value => 'your.email@address'
82 :default_value => 'your.email@address'
83 },
83 },
84
84
85 {
85 {
86 :key => 'system.admin_email',
86 :key => 'system.admin_email',
87 :value_type => 'string',
87 :value_type => 'string',
88 :default_value => 'admin@admin.email'
88 :default_value => 'admin@admin.email'
89 },
89 },
90
90
91 {
91 {
92 :key => 'system.user_setting_enabled',
92 :key => 'system.user_setting_enabled',
93 :value_type => 'boolean',
93 :value_type => 'boolean',
94 :default_value => 'true',
94 :default_value => 'true',
95 :description => 'If this option is true, users can change their settings'
95 :description => 'If this option is true, users can change their settings'
96 },
96 },
97
97
98 {
98 {
99 :key => 'system.user_setting_enabled',
99 :key => 'system.user_setting_enabled',
100 :value_type => 'boolean',
100 :value_type => 'boolean',
101 :default_value => 'true',
101 :default_value => 'true',
102 :description => 'If this option is true, users can change their settings'
102 :description => 'If this option is true, users can change their settings'
103 - }
103 + },
104
104
105 # If Configuration['contest.test_request.early_timeout'] is true
105 # If Configuration['contest.test_request.early_timeout'] is true
106 # the user will not be able to use test request at 30 minutes
106 # the user will not be able to use test request at 30 minutes
107 # before the contest ends.
107 # before the contest ends.
108 {
108 {
109 :key => 'contest.test_request.early_timeout',
109 :key => 'contest.test_request.early_timeout',
110 :value_type => 'boolean',
110 :value_type => 'boolean',
111 :default_value => 'false'
111 :default_value => 'false'
112 },
112 },
113
113
114 {
114 {
115 :key => 'system.multicontests',
115 :key => 'system.multicontests',
116 :value_type => 'boolean',
116 :value_type => 'boolean',
117 :default_value => 'false'
117 :default_value => 'false'
118 },
118 },
119
119
120 {
120 {
121 :key => 'contest.confirm_indv_contest_start',
121 :key => 'contest.confirm_indv_contest_start',
122 :value_type => 'boolean',
122 :value_type => 'boolean',
123 :default_value => 'false'
123 :default_value => 'false'
124 },
124 },
125
125
126 {
126 {
127 :key => 'contest.default_contest_name',
127 :key => 'contest.default_contest_name',
You need to be logged in to leave comments. Login now