Description:
fix bug on calculating best of each lanuage
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r438:1c02c7fc8a89 - - 1 file changed: 1 inserted, 1 deleted

@@ -119,71 +119,71
119 119
120 120 if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value]
121 121 @by_lang[lang.pretty_name][:runtime] = {
122 122 avail: true,
123 123 user_id: sub.user_id,
124 124 value: sub.max_runtime,
125 125 sub_id: sub.id
126 126 }
127 127 end
128 128
129 129 if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value]
130 130 @by_lang[lang.pretty_name][:memory] = {
131 131 avail: true,
132 132 user_id: sub.user_id,
133 133 value: sub.peak_memory,
134 134 sub_id: sub.id
135 135 }
136 136 end
137 137
138 138 if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and
139 139 !sub.user.admin?
140 140 @by_lang[lang.pretty_name][:first] = {
141 141 avail: true,
142 142 user_id: sub.user_id,
143 143 value: sub.submitted_at,
144 144 sub_id: sub.id
145 145 }
146 146 end
147 147
148 148 if @by_lang[lang.pretty_name][:length][:value] > sub.effective_code_length
149 149 @by_lang[lang.pretty_name][:length] = {
150 150 avail: true,
151 151 user_id: sub.user_id,
152 152 value: sub.effective_code_length,
153 153 sub_id: sub.id
154 154 }
155 155 end
156 156 end
157 157
158 158 #process user_id
159 159 @by_lang.each do |lang,prop|
160 160 prop.each do |k,v|
161 161 v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)"
162 162 end
163 163 end
164 164
165 165 #sum into best
166 166 if @by_lang and @by_lang.first
167 - @best = @by_lang.first[1]
167 + @best = @by_lang.first[1].clone
168 168 @by_lang.each do |lang,prop|
169 169 if @best[:runtime][:value] >= prop[:runtime][:value]
170 170 @best[:runtime] = prop[:runtime]
171 171 @best[:runtime][:lang] = lang
172 172 end
173 173 if @best[:memory][:value] >= prop[:memory][:value]
174 174 @best[:memory] = prop[:memory]
175 175 @best[:memory][:lang] = lang
176 176 end
177 177 if @best[:length][:value] >= prop[:length][:value]
178 178 @best[:length] = prop[:length]
179 179 @best[:length][:lang] = lang
180 180 end
181 181 if @best[:first][:value] >= prop[:first][:value]
182 182 @best[:first] = prop[:first]
183 183 @best[:first][:lang] = lang
184 184 end
185 185 end
186 186 end
187 187 end
188 188 end
189 189 end
You need to be logged in to leave comments. Login now