Description:
report only enabled user
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r550:6d57d5eff450 - - 1 file changed: 1 inserted, 1 deleted
@@ -121,49 +121,49 | |||||
|
121 | @user = User.find(params[:id]) |
|
121 | @user = User.find(params[:id]) |
|
122 | end |
|
122 | end |
|
123 |
|
123 | ||
|
124 | def update |
|
124 | def update |
|
125 | @user = User.find(params[:id]) |
|
125 | @user = User.find(params[:id]) |
|
126 | if @user.update_attributes(params[:user]) |
|
126 | if @user.update_attributes(params[:user]) |
|
127 | flash[:notice] = 'User was successfully updated.' |
|
127 | flash[:notice] = 'User was successfully updated.' |
|
128 | redirect_to :action => 'show', :id => @user |
|
128 | redirect_to :action => 'show', :id => @user |
|
129 | else |
|
129 | else |
|
130 | render :action => 'edit' |
|
130 | render :action => 'edit' |
|
131 | end |
|
131 | end |
|
132 | end |
|
132 | end |
|
133 |
|
133 | ||
|
134 | def destroy |
|
134 | def destroy |
|
135 | User.find(params[:id]).destroy |
|
135 | User.find(params[:id]).destroy |
|
136 | redirect_to :action => 'list' |
|
136 | redirect_to :action => 'list' |
|
137 | end |
|
137 | end |
|
138 |
|
138 | ||
|
139 | def user_stat |
|
139 | def user_stat |
|
140 | if params[:commit] == 'download csv' |
|
140 | if params[:commit] == 'download csv' |
|
141 | @problems = Problem.all |
|
141 | @problems = Problem.all |
|
142 | else |
|
142 | else |
|
143 | @problems = Problem.find_available_problems |
|
143 | @problems = Problem.find_available_problems |
|
144 | end |
|
144 | end |
|
145 |
- @users = User. |
|
145 | + @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true) |
|
146 | @scorearray = Array.new |
|
146 | @scorearray = Array.new |
|
147 | @users.each do |u| |
|
147 | @users.each do |u| |
|
148 | ustat = Array.new |
|
148 | ustat = Array.new |
|
149 | ustat[0] = u |
|
149 | ustat[0] = u |
|
150 | @problems.each do |p| |
|
150 | @problems.each do |p| |
|
151 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
151 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
152 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
152 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
153 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
153 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
154 | else |
|
154 | else |
|
155 | ustat << [0,false] |
|
155 | ustat << [0,false] |
|
156 | end |
|
156 | end |
|
157 | end |
|
157 | end |
|
158 | @scorearray << ustat |
|
158 | @scorearray << ustat |
|
159 | end |
|
159 | end |
|
160 | if params[:commit] == 'download csv' then |
|
160 | if params[:commit] == 'download csv' then |
|
161 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
161 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
162 | send_data csv, filename: 'last_score.csv' |
|
162 | send_data csv, filename: 'last_score.csv' |
|
163 | else |
|
163 | else |
|
164 | render template: 'user_admin/user_stat' |
|
164 | render template: 'user_admin/user_stat' |
|
165 | end |
|
165 | end |
|
166 | end |
|
166 | end |
|
167 |
|
167 | ||
|
168 | def user_stat_max |
|
168 | def user_stat_max |
|
169 | if params[:commit] == 'download csv' |
|
169 | if params[:commit] == 'download csv' |
You need to be logged in to leave comments.
Login now