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 owner |
+ As participant |
+
+
- Active projects |
- = $usage_owner['active_services'] ?> |
+ Active projects |
+ = $usage_owner['active_services'] ?> |
+ = $usage_participant['active_services'] ?> |
- Expired projects |
- = $usage_owner['expired_services'] ?> |
+ Expired projects |
+ = $usage_owner['expired_services'] ?> |
+ = $usage_participant['expired_services'] ?> |
- Total projects |
- = $usage_owner['total_services'] ?> |
+ Total projects |
+ = $usage_owner['total_services'] ?> |
+ = $usage_participant['total_services'] ?> |
- Active VMs |
- = $usage_owner['vms_services_active'] ?> |
+ Active VMs |
+ = $usage_owner['vms_services_active'] ?> |
+ = $usage_participant['vms_services_active'] ?> |
- Total VMs |
- = $usage_owner['vms_services_total'] ?> |
+ Total VMs |
+ = $usage_owner['vms_services_total'] ?> |
+ = $usage_participant['vms_services_total'] ?> |
- Active used virtual CPUs |
- = $usage_owner['active_services_cores'] ?> |
+ Active used virtual CPUs |
+ = empty($usage_owner['active_services_cores'])?'0':$usage_owner['active_services_cores'] ?> |
+ = empty($usage_participant['active_services_cores'])?'0':$usage_participant['active_services_cores'] ?> |
- Active used RAM (GB) |
- = $usage_owner['active_services_ram'] ?> |
+ Total used virtual CPUs |
+ = empty($usage_owner['total_services_cores'])?'0':$usage_owner['total_services_cores'] ?> |
+ = empty($usage_participant['total_services_cores'])?'0':$usage_participant['total_services_cores'] ?> |
- Total used virtual CPUs |
- = $usage_owner['total_services_cores'] ?> |
+ Active used RAM(GB) |
+ = empty($usage_owner['active_services_ram'])?'0':$usage_owner['active_services_ram'] ?> |
+ = empty($usage_participant['active_services_ram'])?'0':$usage_participant['active_services_ram'] ?> |
- Total used RAM (GB) |
- = $usage_owner['total_services_ram'] ?> |
+ Total used RAM(GB) |
+ = empty($usage_owner['total_services_ram'])?'0':$usage_owner['total_services_ram'] ?> |
+ = empty($usage_participant['total_services_ram'])?'0':$usage_participant['total_services_ram'] ?> |
-
24/7 services (as Participant)
-
+
+
+
On-demand computation machines
+
+
+
+
+ |
+ As owner |
+ As participant |
+
+
- Active projects |
- = $usage_participant['active_services'] ?> |
+ Active projects |
+ = $usage_owner['active_machines'] ?> |
+ = $usage_participant['active_machines'] ?> |
- Expired projects |
- = $usage_participant['expired_services'] ?> |
+ Expired projects |
+ = $usage_owner['expired_machines'] ?> |
+ = $usage_participant['expired_machines'] ?> |
- Total projects |
- = $usage_participant['total_services'] ?> |
+ Total projects |
+ = $usage_owner['total_machines'] ?> |
+ = $usage_participant['total_machines'] ?> |
- Active VMs |
- = $usage_participant['vms_services_active'] ?> |
+ Active VMs |
+ = $usage_owner['vms_machines_active'] ?> |
+ = $usage_participant['vms_machines_active'] ?> |
- Total VMs |
- = $usage_participant['vms_services_total'] ?> |
+ Total VMs |
+ = $usage_owner['vms_machines_total'] ?> |
+ = $usage_participant['vms_machines_total'] ?> |
- Active used virtual CPUs |
- = $usage_participant['active_services_cores'] ?> |
+ Active used virtual CPUs |
+ = empty($usage_owner['active_machines_cores'])?'0': $usage_owner['active_machines_cores'] ?> |
+ = empty($usage_participant['active_machines_cores'])?'0': $usage_participant['active_machines_cores'] ?> |
- Active used RAM (GB) |
- = $usage_participant['active_services_ram'] ?> |
+ Total used virtual CPUs |
+ = empty($usage_owner['total_machines_cores'])?'0': $usage_owner['total_machines_cores'] ?> |
+ = empty($usage_participant['total_machines_cores'])?'0': $usage_participant['total_machines_cores'] ?> |
- Total used virtual CPUs |
- = $usage_participant['total_services_cores'] ?> |
+ Active used RAM(GB) |
+ = empty($usage_owner['active_machines_ram'])?'0': $usage_owner['active_machines_ram'] ?> |
+ = empty($usage_participant['active_machines_ram'])?'0': $usage_participant['active_machines_ram'] ?> |
- Total used RAM (GB) |
- = $usage_participant['total_services_ram'] ?> |
+ Total used RAM(GB) |
+ = empty($usage_owner['total_machines_ram'])?'0': $usage_owner['total_machines_ram'] ?> |
+ = empty($usage_participant['total_machines_ram'])?'0': $usage_participant['total_machines_ram'] ?> |
-
On-demand computation machines (as Owner)
-
+
+
+
On-demand batch computations
+
+
-
-
- Active projects |
- = $usage_owner['active_machines'] ?> |
-
-
- Expired projects |
- = $usage_owner['expired_machines'] ?> |
-
+
- Total projects |
- = $usage_owner['total_machines'] ?> |
-
-
- Active VMs |
- = $usage_owner['vms_machines_active'] ?> |
-
-
- Total VMs |
- = $usage_owner['vms_machines_total'] ?> |
-
-
- Active used virtual CPUs |
- = empty($usage_owner['active_machines_cores'])?'0': $usage_owner['active_machines_cores'] ?> |
+ |
+ As owner |
+ As participant |
+
+
- Active used RAM (GB) |
- = empty($usage_owner['active_machines_ram'])?'0': $usage_owner['active_machines_ram'] ?> |
+ Active projects |
+ = $usage_owner['active_ondemand'] ?> |
+ = $usage_participant['active_ondemand'] ?> |
- Total used virtual CPUs |
- = empty($usage_owner['total_machines_cores'])?'0': $usage_owner['total_machines_cores'] ?> |
+ Expired projects |
+ = $usage_owner['expired_ondemand'] ?> |
+ = $usage_participant['expired_ondemand'] ?> |
- Total used RAM (GB) |
- = empty($usage_owner['total_machines_ram'])?'0': $usage_owner['total_machines_ram'] ?> |
+ Total projects |
+ = $usage_owner['total_ondemand'] ?> |
+ = $usage_participant['total_ondemand'] ?> |
-
+
-
On-demand computation machines (as Participant)
-
+
+
+
On-demand notebooks
+
+
-
-
- Active projects |
- = $usage_participant['active_machines'] ?> |
-
-
- Expired projects |
- = $usage_participant['expired_machines'] ?> |
-
+
- Total projects |
- = $usage_participant['total_machines'] ?> |
+ |
+ As owner |
+ As participant |
+
+
- Active VMs |
- = $usage_participant['vms_machines_active'] ?> |
+ Active projects |
+ = $usage_owner['active_notebooks'] ?> |
+ = $usage_participant['active_notebooks'] ?> |
- Total VMs |
- = $usage_participant['vms_machines_total'] ?> |
+ Expired projects |
+ = $usage_owner['expired_notebooks'] ?> |
+ = $usage_participant['expired_notebooks'] ?> |
- Active used virtual CPUs |
- = empty($usage_participant['active_machines_cores'])?'0': $usage_participant['active_machines_cores'] ?> |
+ Total projects |
+ = $usage_owner['total_notebooks'] ?> |
+ = $usage_participant['total_notebooks'] ?> |
- Active used RAM (GB) |
- = empty($usage_participant['active_machines_ram'])?'0': $usage_participant['active_machines_ram'] ?> |
+ Active servers |
+ = $usage_owner['active_servers'] ?> |
+ =$usage_participant['active_servers']?> |
- Total used virtual CPUs |
- = empty($usage_participant['total_machines_cores'])?'0': $usage_participant['total_machines_cores'] ?> |
+ Deleted servers |
+ = $usage_owner['inactive_servers'] ?> |
+ =$usage_participant['inactive_servers']?> |
- Total used RAM (GB) |
- = empty($usage_participant['total_machines_ram'])?'0': $usage_participant['total_machines_ram'] ?> |
+ Total servers |
+ = $usage_owner['total_servers'] ?> |
+ =$usage_participant['total_servers']?> |
-
+
+
-
On-demand batch computations (as Owner)
-
-
-
-
-
- Active projects |
- = $usage_owner['active_ondemand'] ?> |
-
-
- Expired projects |
- = $usage_owner['expired_ondemand'] ?> |
-
-
- Total projects |
- = $usage_owner['total_ondemand'] ?> |
-
-
-
-
+
Storage volumes
-
On-demand batch computations (as Participant)
-
+
-
-
-
- Active projects |
- = $usage_participant['active_ondemand'] ?> |
-
+
- Expired projects |
- = $usage_participant['expired_ondemand'] ?> |
+ |
+ As owner |
+ As participant |
-
- Total projects |
- = $usage_participant['total_ondemand'] ?> |
-
-
-
-
-
-
Storage volumes (as Owner)
-
-
+
- Total projects |
- = $usage_owner['total_storage_projects'] ?> (= $usage_owner['number_storage_service_projects']?> for 24/7 service, = $usage_owner['number_storage_machines_projects']?> for on-demand compute machines) |
+ Total projects |
+ = $usage_owner['total_storage_projects'] ?> (= $usage_owner['number_storage_service_projects']?> for 24/7 service, = $usage_owner['number_storage_machines_projects']?> for on-demand compute machines) |
+ = $usage_participant['total_storage_projects'] ?> (= $usage_participant['number_storage_service_projects']?> for 24/7 service, = $usage_participant['number_storage_machines_projects']?> for on-demand compute machines) |
- Total volumes |
- = $usage_owner['total_volumes'] ?> (= $usage_owner['number_volumes_service']?> for 24/7 service, = $usage_owner['number_volumes_machines']?> for on-demand compute machines) |
+ Total volumes |
+ = $usage_owner['total_volumes'] ?> (= $usage_owner['number_volumes_service']?> for 24/7 service, = $usage_owner['number_volumes_machines']?> for on-demand compute machines) |
+ = $usage_participant['total_volumes'] ?> (= $usage_participant['number_volumes_service']?> for 24/7 service, = $usage_participant['number_volumes_machines']?> for on-demand compute machines) |
- Total used storage (TB) |
- = number_format($usage_owner['total_storage_size'],2) ?> TB (= number_format($usage_owner['size_storage_service'],2)?> TB for 24/7 service, = number_format($usage_owner['size_storage_machines'],2)?> TB for compute machines) |
+ Total used storage (TB) |
+ = number_format($usage_owner['total_storage_size'],2) ?> TB (= number_format($usage_owner['size_storage_service'],2)?> TB for 24/7 service, = number_format($usage_owner['size_storage_machines'],2)?> TB for compute machines) |
+ = number_format($usage_participant['total_storage_size'],2) ?> TB (= number_format($usage_participant['size_storage_service'],2)?> TB for 24/7 service, = number_format($usage_participant['size_storage_machines'],2)?> TB for compute machines) |
-
Storage volumes (as Participant)
-
-
-
-
- Total projects |
- = $usage_participant['total_storage_projects'] ?> (= $usage_participant['number_storage_service_projects']?> for 24/7 service, = $usage_participant['number_storage_machines_projects']?> for on-demand compute machines) |
-
-
- Total volumes |
- = $usage_participant['total_volumes'] ?> (= $usage_participant['number_volumes_service']?> for 24/7 service, = $usage_participant['number_volumes_machines']?> for on-demand compute machines) |
-
-
- Total used storage (TB) |
- = number_format($usage_participant['total_storage_size'],2) ?> TB (= number_format($usage_participant['size_storage_service'],2)?> TB for 24/7 service, = number_format($usage_participant['size_storage_machines'],2)?> TB for compute machines) |
-
-