diff --git a/controllers/ProjectController.php b/controllers/ProjectController.php index 3b70f3f..af5ddfd 100644 --- a/controllers/ProjectController.php +++ b/controllers/ProjectController.php @@ -3425,8 +3425,8 @@ public function actionUserStatistics() $user=Userw::getCurrentUser(); $uid=$user['id']; $username=explode('@',$user['username'])[0]; - $usage_owner=Project::userStatisticsOwner($uid); - $usage_participant=Project::userStatisticsParticipant($uid); + $usage_owner=Project::userStatisticsOwner($uid, $user['username']); + $usage_participant=Project::userStatisticsParticipant($uid, $user['username']); return $this->render('user_statistics', ['usage_participant'=>$usage_participant,'usage_owner'=>$usage_owner, 'username'=>$username]); } diff --git a/models/Project.php b/models/Project.php index 2aa346c..a7745af 100644 --- a/models/Project.php +++ b/models/Project.php @@ -671,7 +671,7 @@ public static function getMaximumActiveAcceptedProjects($project_type, $requeste return $max_per_role[$requested_role]; } - public static function userStatisticsParticipant($uid) + public static function userStatisticsParticipant($uid, $username) { $query=new Query; @@ -894,6 +894,63 @@ public static function userStatisticsParticipant($uid) ->andWhere("$uid = ANY(pr.user_list)") ->andWhere(['<>','pr.submitted_by',$uid]) ->count(); + + $query=new Query; + $active_notebooks=$query->select(['pr.id']) + ->from('project_request as pr') + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->where(['IN','pr.status',[1,2]]) + ->andWhere(['>','pr.end_date','NOW()']) + ->andWhere("$uid = ANY(pr.user_list)") + ->andWhere(['<>','pr.submitted_by',$uid]) + ->count(); + + $query=new Query; + $expired_notebooks=$query->select(['pr.id']) + ->from('project_request as pr') + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->where(['IN','pr.status',[1,2]]) + ->andWhere(['<=','pr.end_date','NOW()']) + ->andWhere("$uid = ANY(pr.user_list)") + ->andWhere(['<>','pr.submitted_by',$uid]) + ->count(); + + $query=new Query; + $total_notebooks=$query->select(['pr.id']) + ->from('project_request as pr') + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->where(['IN','pr.status',[1,2]]) + ->andWhere("$uid = ANY(pr.user_list)") + ->andWhere(['<>','pr.submitted_by',$uid]) + ->count(); + + $query=new Query; + $active_servers=$query->select(['s.id']) + ->from('project_request as pr') + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->innerJoin('jupyter_server as s','pr.name=s.project') + ->where(['s.created_by'=>$username]) + ->andwhere(['IN','pr.status',[1,2]]) + ->andWhere(['s.active'=>'t']) + ->andWhere("$uid = ANY(pr.user_list)") + ->andWhere(['<>','pr.submitted_by',$uid]) + ->count(); + + $query=new Query; + $inactive_servers=$query->select(['s.id']) + ->from('project_request as pr') + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->innerJoin('jupyter_server as s','pr.name=s.project') + ->andwhere(['IN','pr.status',[1,2]]) + ->where(['s.created_by'=>$username]) + ->andWhere(['s.active'=>'f']) + ->andWhere("$uid = ANY(pr.user_list)") + ->andWhere(['<>','pr.submitted_by',$uid]) + ->count(); + + $total_servers=$active_servers+$inactive_servers; + + $final=[ @@ -931,13 +988,19 @@ public static function userStatisticsParticipant($uid) 'number_volumes_machines'=>$volumes_machines['number'], 'size_storage_service'=>$volumes_service['total']/1024.0, 'size_storage_machines'=>$volumes_machines['total']/1024.0, + 'active_notebooks'=>$active_notebooks, + 'expired_notebooks'=>$expired_notebooks, + 'total_notebooks'=>$total_notebooks, + 'active_servers'=>$active_servers, + 'inactive_servers'=>$inactive_servers, + 'total_servers'=>$total_servers, ]; return $final; } - public static function userStatisticsOwner($uid) + public static function userStatisticsOwner($uid, $username) { $query=new Query; @@ -1148,6 +1211,54 @@ public static function userStatisticsOwner($uid) ->andWhere(['pr.submitted_by'=>$uid]) ->count(); + $query=new Query; + $active_notebooks=$query->select(['p.id']) + ->from('project_request as pr') + ->innerJoin('project as p', 'p.latest_project_request_id=pr.id' ) + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->where(['IN','pr.status',[1,2]]) + ->andWhere(['>','pr.end_date','NOW()']) + ->andWhere(['pr.submitted_by'=>$uid]) + ->count(); + + $query=new Query; + + $expired_notebooks=$query->select(['p.id']) + ->from('project_request as pr') + ->innerJoin('project as p', 'p.latest_project_request_id=pr.id' ) + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->where(['IN','pr.status',[1,2]]) + ->andWhere(['<','pr.end_date','NOW()']) + ->andWhere(['pr.submitted_by'=>$uid]) + ->count(); + + $query=new Query; + + $total_notebooks=$query->select(['p.id']) + ->from('project_request as pr') + ->innerJoin('project as p', 'p.latest_project_request_id=pr.id' ) + ->innerJoin('jupyter_request_n as o','o.request_id=pr.id') + ->where(['IN','pr.status',[1,2]]) + ->andWhere(['pr.submitted_by'=>$uid]) + ->count(); + + $query=new Query; + $active_servers=$query->select(['s.id']) + ->from('jupyter_server as s') + ->where(['s.created_by'=>$username]) + ->andWhere(['s.active'=>'t']) + ->count(); + + $query=new Query; + $inactive_servers=$query->select(['s.id']) + ->from('jupyter_server as s') + ->where(['s.created_by'=>$username]) + ->andWhere(['s.active'=>'f']) + ->count(); + + $total_servers=$active_servers+$inactive_servers; + + $final=[ 'active_services'=>$active_services, 'expired_services'=>$expired_services, @@ -1183,6 +1294,12 @@ public static function userStatisticsOwner($uid) 'number_volumes_machines'=>$volumes_machines['number'], 'size_storage_service'=>$volumes_service['total']/1024.0, 'size_storage_machines'=>$volumes_machines['total']/1024.0, + 'active_notebooks'=>$active_notebooks, + 'expired_notebooks'=>$expired_notebooks, + 'total_notebooks'=>$total_notebooks, + 'active_servers'=>$active_servers, + 'inactive_servers'=>$inactive_servers, + 'total_servers'=>$total_servers, ]; diff --git a/views/project/user_statistics.php b/views/project/user_statistics.php index 6c2ddb8..068d8d7 100644 --- a/views/project/user_statistics.php +++ b/views/project/user_statistics.php @@ -11,9 +11,10 @@ use yii\helpers\Html; use yii\widgets\LinkPager; -$this->title="Statistics for user $username"; +echo Html::CssFile('@web/css/project/index.css'); +$this->registerCssFile("@web/css/project/index.css"); -echo Html::cssFile('@web/css/project/project_details.css'); +$this->title="Statistics for user $username"; $back_icon=''; /* @@ -32,261 +33,241 @@
 
-

24/7 services (as Owner)

-
+

24/7 services

+ +
+ + + + + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + +
As ownerAs participant
Active projectsActive projects
Expired projectsExpired projects
Total projectsTotal projects
Active VMsActive VMs
Total VMsTotal VMs
Active used virtual CPUsActive used virtual CPUs
Active used RAM (GB)Total used virtual CPUs
Total used virtual CPUsActive used RAM(GB)
Total used RAM (GB)Total used RAM(GB)
-

24/7 services (as Participant)

-
+
 
+ +

On-demand computation machines

+ +
+ + + + + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + +
As ownerAs participant
Active projectsActive projects
Expired projectsExpired projects
Total projectsTotal projects
Active VMsActive VMs
Total VMsTotal VMs
Active used virtual CPUsActive used virtual CPUs
Active used RAM (GB)Total used virtual CPUs
Total used virtual CPUsActive used RAM(GB)
Total used RAM (GB)Total used RAM(GB)
-

On-demand computation machines (as Owner)

-
+
 
+ +

On-demand batch computations

+ +
- - - - - - - - - + - - - - - - - - - - - - - - + + + + + - - + + + - - + + + - - + + + - +
Active projects
Expired projects
Total projects
Active VMs
Total VMs
Active used virtual CPUsAs ownerAs participant
Active used RAM (GB)Active projects
Total used virtual CPUsExpired projects
Total used RAM (GB)Total projects
-

On-demand computation machines (as Participant)

-
+
 
+ +

On-demand notebooks

+ +
- - - - - - - - - + - - + + + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - +
Active projects
Expired projects
Total projectsAs ownerAs participant
Active VMsActive projects
Total VMsExpired projects
Active used virtual CPUsTotal projects
Active used RAM (GB)Active servers
Total used virtual CPUsDeleted servers
Total used RAM (GB)Total servers
+
 
-

On-demand batch computations (as Owner)

-
- - - - - - - - - - - - - - - - -
Active projects
Expired projects
Total projects
-
+

Storage volumes

-

On-demand batch computations (as Participant)

-
+
- - - - - - + - - + + + - - - - - -
Active projects
Expired projectsAs ownerAs participant
Total projects
-
- -

Storage volumes (as Owner)

-
- + - - + + + - - + + + - - + + +
Total projects ( for 24/7 service, for on-demand compute machines)Total projects ( for 24/7 service, for on-demand compute machines) ( for 24/7 service, for on-demand compute machines)
Total volumes ( for 24/7 service, for on-demand compute machines)Total volumes ( for 24/7 service, for on-demand compute machines) ( for 24/7 service, for on-demand compute machines)
Total used storage (TB) TB ( TB for 24/7 service, TB for compute machines)Total used storage (TB) TB ( TB for 24/7 service, TB for compute machines) TB ( TB for 24/7 service, TB for compute machines)
-

Storage volumes (as Participant)

-
- - - - - - - - - - - - - - - -
Total projects ( for 24/7 service, for on-demand compute machines)
Total volumes ( for 24/7 service, for on-demand compute machines)
Total used storage (TB) TB ( TB for 24/7 service, TB for compute machines)
-
diff --git a/web/css/project/index.css b/web/css/project/index.css index 8f2135d..fe49c0a 100644 --- a/web/css/project/index.css +++ b/web/css/project/index.css @@ -12,7 +12,6 @@ } - .bronze-user {