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

r458:df535657f72c - - 6 files changed: 77 inserted, 15 deleted

@@ -159,7 +159,6
159 159 #stat summary
160 160 range =65
161 161 @histogram = { data: Array.new(range,0), summary: {} }
162 - @histogram[:data] = Array.new(range,0)
163 162 user = Hash.new(0)
164 163 @submissions.find_each do |sub|
165 164 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
@@ -111,7 +111,6
111 111
112 112 range =65
113 113 @histogram = { data: Array.new(range,0), summary: {} }
114 - @histogram[:data] = Array.new(range,0)
115 114 @summary = {count: 0, solve: 0, attempt: 0}
116 115 user = Hash.new(0)
117 116 Submission.where(problem_id: @problem.id).find_each do |sub|
@@ -111,7 +111,25
111 111
112 112 def profile
113 113 @user = User.find(params[:id])
114 - @submission = Submission.where(user_id: params[:id]).all
114 + @submission = Submission.includes(:problem).where(user_id: params[:id])
115 +
116 + range = 120
117 + @histogram = { data: Array.new(range,0), summary: {} }
118 + @summary = {count: 0, solve: 0, attempt: 0}
119 + problem = Hash.new(0)
120 +
121 + @submission.find_each do |sub|
122 + #histogram
123 + d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
124 + @histogram[:data][d.to_i] += 1 if d < range
125 +
126 + @summary[:count] += 1
127 + problem[sub.problem] = [problem[sub.problem], (sub.points >= sub.problem.full_score) ? 1 : 0].max
128 + end
129 +
130 + @histogram[:summary][:max] = [@histogram[:data].max,1].max
131 + @summary[:attempt] = problem.count
132 + problem.each_value { |v| @summary[:solve] += 1 if v == 1 }
115 133 end
116 134
117 135 protected
@@ -18,7 +18,7
18 18 font-size:5px;
19 19 }
20 20
21 - %div{style: "position: relative; width: #{graph_width}px; height: 150px; background-color:#fff;" }
21 + %div{style: "position: relative; width: #{graph_width}px; height: 125px; background-color:#fff;" }
22 22 //draw background
23 23 - histogram[:data].each_index do |i|
24 24 - height = histogram[:data][i] * graph_height / histogram[:summary][:max]
@@ -1,8 +1,39
1 + - content_for :header do
2 + = javascript_include_tag 'local_jquery'
3 +
4 + :javascript
5 + $(document).ready( function() {
6 + $("#mem_remark").hover( function() {
7 + $("#mem_remark_box").show();
8 + }, function() {
9 + $("#mem_remark_box").hide();
10 + });
11 + });
12 + alert("hahaha");
1 13 :css
2 14 .hof_user { color: orangered; font-style: italic; }
3 15 .hof_language { color: green; font-style: italic; }
4 16 .hof_value { color: deeppink;font-style: italic; }
5 17 .info_param { font-weight: bold;text-align: right; }
18 + .tooltip {
19 + font-family: Verdana,sans-serif;
20 + font-weight: normal;
21 + text-align: left;
22 + font-size: 1.0em;
23 + color: black;
24 + line-height: 1.1;
25 + display: none;
26 + min-width: 20em;
27 + position: absolute;
28 + left: 25px;
29 + bottom: 5px;
30 + border: 1px solid;
31 + padding: 5px;
32 + background-color: #FFF;
33 + word-wrap: break-word;
34 + z-index: 9999;
35 + overflow: auto;
36 + }
6 37
7 38 %h1 (#{Problem.find(params[:id]).name}) #{Problem.find(params[:id]).full_name}
8 39
@@ -30,7 +61,13
30 61 = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id])
31 62
32 63 %tr{class: cycle('info-even','info-odd')}
33 - %td.info_param Best Memory Usage
64 + %td.info_param
65 + Best Memory Usage
66 + %sup{ id: "mem_remark", style: "position:relative; color: blue;"}
67 + [?]
68 + %span.tooltip#mem_remark_box
69 + This counts only for submission with 100% score.
70 + Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...)
34 71 %td
35 72 by #{link_to @best[:memory][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]}
36 73 using <span class="hof_language">#{@best[:memory][:lang]}</span>
@@ -56,11 +93,6
56 93 at submission
57 94 = link_to("#" + @best[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:first][:sub_id])
58 95
59 -
60 - %p
61 - This counts only for submission with 100% score <br/>
62 - Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...)
63 -
64 96 - if @best
65 97 %h2 By language
66 98
@@ -1,9 +1,9
1 1 - content_for :header do
2 2 = javascript_include_tag 'local_jquery'
3 3
4 - %script{:type=>"text/javascript"}
4 + :javascript
5 5 $(function () {
6 - $('#submission_table').tablesorter({widgets: ['zebra']});
6 + $('#submission_table').tablesorter({widgets: ['zebra']});
7 7 });
8 8
9 9 :css
@@ -11,16 +11,30
11 11 font-family: Droid Sans Mono,Consolas, monospace, mono, Courier New, Courier;
12 12 }
13 13
14 - %h1= @user.full_name + ' Profile'
14 + %h1= @user.full_name
15 15
16 - %h2 Basic info
17 16 <b>Login:</b> #{@user.login} <br/>
18 17 <b>Full name:</b> #{@user.full_name} <br />
19 18
20 19
21 20 %h2 Problem Stat
21 + %table.info
22 + %thead
23 + %tr.info-head
24 + %th Stat
25 + %th Value
26 + %tbody
27 + %tr{class: cycle('info-even','info-odd')}
28 + %td.info_param Submissions
29 + %td= @summary[:count]
30 + %tr{class: cycle('info-even','info-odd')}
31 + %td.info_param Solved/Attempted Problem
32 + %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
22 33
23 - %h2 Submissions
34 + %h2 Submission History
35 +
36 + =render partial: 'application/bar_graph', locals: {histogram: @histogram, param: {bar_width: 7}}
37 +
24 38
25 39 %table.tablesorter-cafe#submission_table
26 40 %thead
You need to be logged in to leave comments. Login now