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
@@ -97,97 +97,97 | |||
|
97 | 97 | else |
|
98 | 98 | user = User.new({:login => login, |
|
99 | 99 | :full_name => full_name, |
|
100 | 100 | :password => password, |
|
101 | 101 | :password_confirmation => password, |
|
102 | 102 | :alias => user_alias}) |
|
103 | 103 | end |
|
104 | 104 | user.activated = true |
|
105 | 105 | user.save |
|
106 | 106 | |
|
107 | 107 | if added_random_password |
|
108 | 108 | note << "'#{login}' (+)" |
|
109 | 109 | else |
|
110 | 110 | note << login |
|
111 | 111 | end |
|
112 | 112 | end |
|
113 | 113 | end |
|
114 | 114 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
115 | 115 | ' were successfully created. ' + |
|
116 | 116 | '( (+) - created with random passwords.)' |
|
117 | 117 | redirect_to :action => 'list' |
|
118 | 118 | end |
|
119 | 119 | |
|
120 | 120 | def edit |
|
121 | 121 | @user = User.find(params[:id]) |
|
122 | 122 | end |
|
123 | 123 | |
|
124 | 124 | def update |
|
125 | 125 | @user = User.find(params[:id]) |
|
126 | 126 | if @user.update_attributes(params[:user]) |
|
127 | 127 | flash[:notice] = 'User was successfully updated.' |
|
128 | 128 | redirect_to :action => 'show', :id => @user |
|
129 | 129 | else |
|
130 | 130 | render :action => 'edit' |
|
131 | 131 | end |
|
132 | 132 | end |
|
133 | 133 | |
|
134 | 134 | def destroy |
|
135 | 135 | User.find(params[:id]).destroy |
|
136 | 136 | redirect_to :action => 'list' |
|
137 | 137 | end |
|
138 | 138 | |
|
139 | 139 | def user_stat |
|
140 | 140 | if params[:commit] == 'download csv' |
|
141 | 141 | @problems = Problem.all |
|
142 | 142 | else |
|
143 | 143 | @problems = Problem.find_available_problems |
|
144 | 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 | 146 | @scorearray = Array.new |
|
147 | 147 | @users.each do |u| |
|
148 | 148 | ustat = Array.new |
|
149 | 149 | ustat[0] = u |
|
150 | 150 | @problems.each do |p| |
|
151 | 151 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
152 | 152 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
153 | 153 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
154 | 154 | else |
|
155 | 155 | ustat << [0,false] |
|
156 | 156 | end |
|
157 | 157 | end |
|
158 | 158 | @scorearray << ustat |
|
159 | 159 | end |
|
160 | 160 | if params[:commit] == 'download csv' then |
|
161 | 161 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
162 | 162 | send_data csv, filename: 'last_score.csv' |
|
163 | 163 | else |
|
164 | 164 | render template: 'user_admin/user_stat' |
|
165 | 165 | end |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | 168 | def user_stat_max |
|
169 | 169 | if params[:commit] == 'download csv' |
|
170 | 170 | @problems = Problem.all |
|
171 | 171 | else |
|
172 | 172 | @problems = Problem.find_available_problems |
|
173 | 173 | end |
|
174 | 174 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
175 | 175 | @scorearray = Array.new |
|
176 | 176 | #set up range from param |
|
177 | 177 | since_id = params.fetch(:since_id, 0).to_i |
|
178 | 178 | until_id = params.fetch(:until_id, 0).to_i |
|
179 | 179 | @users.each do |u| |
|
180 | 180 | ustat = Array.new |
|
181 | 181 | ustat[0] = u |
|
182 | 182 | @problems.each do |p| |
|
183 | 183 | max_points = 0 |
|
184 | 184 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
185 | 185 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
186 | 186 | end |
|
187 | 187 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
188 | 188 | end |
|
189 | 189 | @scorearray << ustat |
|
190 | 190 | end |
|
191 | 191 | |
|
192 | 192 | if params[:commit] == 'download csv' then |
|
193 | 193 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
You need to be logged in to leave comments.
Login now