-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsu_lb.php
96 lines (89 loc) · 2.68 KB
/
su_lb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
require_once('../inc/su.inc');
function ec_total($a, $b) {
return $a[1]->ec_total < $b[1]->ec_total;
}
function ec_avg($a, $b) {
return $a[1]->ec_avg < $b[1]->ec_avg;
}
function time_total($a, $b) {
return $a[1]->time_total < $b[1]->time_total;
}
function time_avg($a, $b) {
return $a[1]->time_avg < $b[1]->time_avg;
}
function sort_heading($sort, $col_sort, $title) {
if ($sort == $col_sort) {
return "<u>$title</u>";
} else {
return sprintf('<a href=su_lb.php?sort=%s>%s</a>',
$col_sort, $title
);
}
}
function main($sort) {
$user = get_logged_in_user();
$users = BoincUser::enum('donated>0');
$x = [];
foreach ($users as $user) {
$a = get_work_info($user->id);
if (!$a) continue;
$x[] = [$user, $a];
}
usort($x, $sort);
page_head('Leading contributors');
text_start(800);
echo '
<p>
The volunteers who have contributes the most
computing to Science United are listed below.
<p>
Volunteers are shown only if they have
<a href=su_lb_intro.php>opted in</a>;
you are encouraged to do so.
<p>
';
echo "<style> .rt { text-align: right; } </style>";
start_table('table-striped');
row_heading_array(
[
'Volunteer',
'Work graphs',
sort_heading($sort, 'ec_total', 'Total TFLOPs'),
sort_heading($sort, 'ec_avg', 'Recent TFLOPs per day'),
//sort_heading($sort, 'time_total', 'Total processor time (days)'),
//sort_heading($sort, 'time_avg', 'Recent processor time (days per day)')
],
//['class=bg-primary', '', '', '', ''], 'bg-primary rt'
['class=bg-primary', 'class=bg-primary', '', ''], 'bg-primary rt'
);
$i = 0;
foreach ($x as [$user, $a]) {
$i++;
row_array(
[
sprintf(
'%d. <a href=su_show_user.php?userid=%d>%s</a>',
$i, $user->id, $user->name
),
sprintf(
'<a href=su_graph2.php?userid=%d&what=ec&ndays=365>View</a>',
$user->id
),
number_format(ec_to_tflops($a->ec_total), 2),
number_format(ec_to_tflops($a->ec_avg), 2),
//number_format($a->time_total/86400, 2),
//number_format($a->time_avg/86400,2)
],
//['', 'class=rt', 'class=rt', 'class=rt', 'class=rt']
['', '', 'class=rt', 'class=rt']
);
}
end_table();
text_end();
page_tail();
}
$sort = get_str('sort', true);
if (!$sort) $sort = 'ec_avg';
main($sort);
?>