File tree Expand file tree Collapse file tree 6 files changed +78
-1
lines changed Expand file tree Collapse file tree 6 files changed +78
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Shows the various statistics under /stats.
2
+ class StatusController < ApplicationController
3
+
4
+ def index
5
+ authorize! :read_instance_state , nil
6
+ @sandbox_queue_length = Submission . to_be_reprocessed . count
7
+ @unprocessed_submissions_count = Submission . where ( processed : false ) . count
8
+ @submissions_count = Submission . where ( created_at : Time . current . all_day ) . count
9
+ @submissions_count_week = Submission . where ( created_at : Time . current . all_week ) . count
10
+ @sandboxes = RemoteSandbox . all
11
+ end
12
+
13
+ end
Original file line number Diff line number Diff line change @@ -23,7 +23,9 @@ def initialize(user)
23
23
end
24
24
can :access_pghero
25
25
can :read_vm_log , Submission
26
+ can :read_instance_state
26
27
else
28
+ cannot :read_instance_state
27
29
can :read , :all
28
30
29
31
cannot :access_pghero
Original file line number Diff line number Diff line change @@ -107,7 +107,16 @@ def capacity
107
107
rescue
108
108
nil
109
109
end
110
- @capacity || 1
110
+ @capacity || 0
111
+ end
112
+
113
+ def busy_instances
114
+ @busy_instances ||= begin
115
+ get_status [ 'busy_instances' ]
116
+ rescue
117
+ nil
118
+ end
119
+ @busy_instances || 0
111
120
end
112
121
113
122
private
Original file line number Diff line number Diff line change 14
14
<% if current_user . administrator? %>
15
15
< li class ="nav-item "> <%= navigation_link 'Users' , users_path %> </ li >
16
16
< li class ="nav-item "> <%= navigation_link 'Course templates' , course_templates_path %> </ li >
17
+ < li class ="nav-item "> <%= navigation_link 'Status' , status_index_path %> </ li >
17
18
<% end %>
18
19
<% end %>
19
20
</ ul >
Original file line number Diff line number Diff line change
1
+ < h1 > Status</ h1 >
2
+
3
+ < p >
4
+ Here is some adminsitrative information about this instance.
5
+ </ p >
6
+
7
+ < h2 > Submissions</ h2 >
8
+
9
+ < table class ="table ">
10
+ < tbody >
11
+ < tr >
12
+ < th scope ="row "> Submission queue </ th scope="row">
13
+ < td > <%= @sandbox_queue_length %> </ td >
14
+ </ tr >
15
+ < tr >
16
+ < th scope ="row "> Submissions, processing not complete</ th >
17
+ < td > <%= @unprocessed_submissions_count %> </ td >
18
+ </ tr >
19
+ < tr >
20
+ < th scope ="row "> Submissions today</ th >
21
+ < td > <%= @submissions_count %> </ td >
22
+ </ tr >
23
+ < tr >
24
+ < th scope ="row "> Submissions this week</ th >
25
+ < td > <%= @submissions_count_week %> </ td >
26
+ </ tr >
27
+ </ tbody >
28
+ </ table >
29
+
30
+
31
+ < h2 > Sandboxes</ h2 >
32
+
33
+ < table class ="table ">
34
+ < thead >
35
+ < tr >
36
+ < th > Name</ th >
37
+ < th > Busy instances</ th >
38
+ < th > Capacity</ th >
39
+ </ tr >
40
+ </ thead >
41
+ < tbody >
42
+ <% @sandboxes . each do |sandbox | %>
43
+ < tr >
44
+ < td > <%= sandbox . baseurl %> </ td >
45
+ < td > <%= sandbox . busy_instances %> </ td >
46
+ < td > <%= sandbox . capacity %> </ td >
47
+ </ tr >
48
+ <% end %>
49
+ </ tbody >
50
+ </ table >
Original file line number Diff line number Diff line change 286
286
287
287
resource :feedback_replies , only : [ :create ]
288
288
289
+ resources :status , only : [ :index ]
290
+
289
291
if SiteSetting . value ( 'pghero_enabled' )
290
292
constraints CanAccessPgHero do
291
293
mount PgHero ::Engine , at : 'pghero'
You can’t perform that action at this time.
0 commit comments