Description:
fix exclude admin in report
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r428:06bd0f1beeb4 - - 1 file changed: 2 inserted, 2 deleted
@@ -89,98 +89,98 | |||||
|
89 |
|
89 | ||
|
90 | # get selected problems or the default |
|
90 | # get selected problems or the default |
|
91 | if params[:id] |
|
91 | if params[:id] |
|
92 | begin |
|
92 | begin |
|
93 | @problem = Problem.available.find(params[:id]) |
|
93 | @problem = Problem.available.find(params[:id]) |
|
94 | rescue |
|
94 | rescue |
|
95 | redirect_to action: :problem_hof |
|
95 | redirect_to action: :problem_hof |
|
96 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
96 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
97 | return |
|
97 | return |
|
98 | end |
|
98 | end |
|
99 | end |
|
99 | end |
|
100 |
|
100 | ||
|
101 | if @problem |
|
101 | if @problem |
|
102 | #aggregrate by language |
|
102 | #aggregrate by language |
|
103 | @by_lang = {} |
|
103 | @by_lang = {} |
|
104 | Submission.where(problem_id: @problem.id).find_each do |sub| |
|
104 | Submission.where(problem_id: @problem.id).find_each do |sub| |
|
105 | lang = Language.find_by_id(sub.language_id) |
|
105 | lang = Language.find_by_id(sub.language_id) |
|
106 | next unless lang |
|
106 | next unless lang |
|
107 | next unless sub.points >= @problem.full_score |
|
107 | next unless sub.points >= @problem.full_score |
|
108 |
|
108 | ||
|
109 | #initialize |
|
109 | #initialize |
|
110 | unless @by_lang.has_key?(lang.pretty_name) |
|
110 | unless @by_lang.has_key?(lang.pretty_name) |
|
111 | @by_lang[lang.pretty_name] = { |
|
111 | @by_lang[lang.pretty_name] = { |
|
112 | runtime: { avail: false, value: 2**30-1 }, |
|
112 | runtime: { avail: false, value: 2**30-1 }, |
|
113 | memory: { avail: false, value: 2**30-1 }, |
|
113 | memory: { avail: false, value: 2**30-1 }, |
|
114 | length: { avail: false, value: 2**30-1 }, |
|
114 | length: { avail: false, value: 2**30-1 }, |
|
115 | first: { avail: false, value: DateTime.new(3000,1,1) } |
|
115 | first: { avail: false, value: DateTime.new(3000,1,1) } |
|
116 | } |
|
116 | } |
|
117 | end |
|
117 | end |
|
118 |
|
118 | ||
|
119 | if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value] |
|
119 | if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value] |
|
120 | @by_lang[lang.pretty_name][:runtime] = { |
|
120 | @by_lang[lang.pretty_name][:runtime] = { |
|
121 | avail: true, |
|
121 | avail: true, |
|
122 | user_id: sub.user_id, |
|
122 | user_id: sub.user_id, |
|
123 | value: sub.max_runtime, |
|
123 | value: sub.max_runtime, |
|
124 | sub_id: sub.id |
|
124 | sub_id: sub.id |
|
125 | } |
|
125 | } |
|
126 | end |
|
126 | end |
|
127 |
|
127 | ||
|
128 | if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value] |
|
128 | if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value] |
|
129 | @by_lang[lang.pretty_name][:memory] = { |
|
129 | @by_lang[lang.pretty_name][:memory] = { |
|
130 | avail: true, |
|
130 | avail: true, |
|
131 | user_id: sub.user_id, |
|
131 | user_id: sub.user_id, |
|
132 | value: sub.peak_memory, |
|
132 | value: sub.peak_memory, |
|
133 | sub_id: sub.id |
|
133 | sub_id: sub.id |
|
134 | } |
|
134 | } |
|
135 | end |
|
135 | end |
|
136 |
|
136 | ||
|
137 | - if sub.user.admin? == false and |
|
137 | + if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and |
|
138 | - sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] |
|
138 | + !sub.user.admin? |
|
139 | @by_lang[lang.pretty_name][:first] = { |
|
139 | @by_lang[lang.pretty_name][:first] = { |
|
140 | avail: true, |
|
140 | avail: true, |
|
141 | user_id: sub.user_id, |
|
141 | user_id: sub.user_id, |
|
142 | value: sub.submitted_at, |
|
142 | value: sub.submitted_at, |
|
143 | sub_id: sub.id |
|
143 | sub_id: sub.id |
|
144 | } |
|
144 | } |
|
145 | end |
|
145 | end |
|
146 |
|
146 | ||
|
147 | if @by_lang[lang.pretty_name][:length][:value] > sub.effective_code_length |
|
147 | if @by_lang[lang.pretty_name][:length][:value] > sub.effective_code_length |
|
148 | @by_lang[lang.pretty_name][:length] = { |
|
148 | @by_lang[lang.pretty_name][:length] = { |
|
149 | avail: true, |
|
149 | avail: true, |
|
150 | user_id: sub.user_id, |
|
150 | user_id: sub.user_id, |
|
151 | value: sub.effective_code_length, |
|
151 | value: sub.effective_code_length, |
|
152 | sub_id: sub.id |
|
152 | sub_id: sub.id |
|
153 | } |
|
153 | } |
|
154 | end |
|
154 | end |
|
155 | end |
|
155 | end |
|
156 |
|
156 | ||
|
157 | #process user_id |
|
157 | #process user_id |
|
158 | @by_lang.each do |lang,prop| |
|
158 | @by_lang.each do |lang,prop| |
|
159 | prop.each do |k,v| |
|
159 | prop.each do |k,v| |
|
160 | v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)" |
|
160 | v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)" |
|
161 | end |
|
161 | end |
|
162 | end |
|
162 | end |
|
163 |
|
163 | ||
|
164 | #sum into best |
|
164 | #sum into best |
|
165 | if @by_lang and @by_lang.first |
|
165 | if @by_lang and @by_lang.first |
|
166 | @best = @by_lang.first[1] |
|
166 | @best = @by_lang.first[1] |
|
167 | @by_lang.each do |lang,prop| |
|
167 | @by_lang.each do |lang,prop| |
|
168 | if @best[:runtime][:value] >= prop[:runtime][:value] |
|
168 | if @best[:runtime][:value] >= prop[:runtime][:value] |
|
169 | @best[:runtime] = prop[:runtime] |
|
169 | @best[:runtime] = prop[:runtime] |
|
170 | @best[:runtime][:lang] = lang |
|
170 | @best[:runtime][:lang] = lang |
|
171 | end |
|
171 | end |
|
172 | if @best[:memory][:value] >= prop[:memory][:value] |
|
172 | if @best[:memory][:value] >= prop[:memory][:value] |
|
173 | @best[:memory] = prop[:memory] |
|
173 | @best[:memory] = prop[:memory] |
|
174 | @best[:memory][:lang] = lang |
|
174 | @best[:memory][:lang] = lang |
|
175 | end |
|
175 | end |
|
176 | if @best[:length][:value] >= prop[:length][:value] |
|
176 | if @best[:length][:value] >= prop[:length][:value] |
|
177 | @best[:length] = prop[:length] |
|
177 | @best[:length] = prop[:length] |
|
178 | @best[:length][:lang] = lang |
|
178 | @best[:length][:lang] = lang |
|
179 | end |
|
179 | end |
|
180 | if @best[:first][:value] >= prop[:first][:value] |
|
180 | if @best[:first][:value] >= prop[:first][:value] |
|
181 | @best[:first] = prop[:first] |
|
181 | @best[:first] = prop[:first] |
|
182 | @best[:first][:lang] = lang |
|
182 | @best[:first][:lang] = lang |
|
183 | end |
|
183 | end |
|
184 | end |
|
184 | end |
|
185 | end |
|
185 | end |
|
186 | end |
|
186 | end |
You need to be logged in to leave comments.
Login now