Commit 03e68a06 authored by Gerald Salin's avatar Gerald Salin
Browse files

Add administration purged view

parent 41bfe84b
......@@ -50,6 +50,139 @@ class tx_nG6_db {
}
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery ($table, 'uid='.$id, array($field => $value));
}
/**
* All retention data for projet
*
* @param string $project_id
* @return table with obsoletes projects, runs, analyzes and users
*/
function select_retention_data_for_projects($project_id) {
# select runs
$queryWHERE_ANDproject = '';
if (isset($project_id)){
$queryWHERE_ANDproject = "AND tx_nG6_project.uid=$project_id";
}
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid as Project_id , tx_nG6_project.name AS Project_name, count( DISTINCT tx_nG6_run.uid ) AS Nb_run, sum( tx_nG6_run.storage_size /1000000000 ) AS sum_run_storage, sum(tx_nG6_run.purged_size/1000000000) AS sum_run_purged, tx_nG6_run.data_state AS Run_State',
'FROM' => 'tx_nG6_run '
.'INNER JOIN tx_nG6_project_run ON tx_nG6_project_run.run_id = tx_nG6_run.uid '
.'INNER JOIN tx_nG6_project ON tx_nG6_project.uid = tx_nG6_project_run.project_id ',
'WHERE' => 'DATEDIFF( FROM_UNIXTIME( tx_nG6_run.retention_date ) , now( ) ) <0 '
.$queryWHERE_ANDproject,
'GROUPBY' => 'tx_nG6_project.uid,tx_nG6_run.data_state',
'ORDERBY' => '',
'LIMIT' => ''
);
$by_project = array() ;
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if (!isset ($by_project[$res_row['Project_id']])) {
$by_project[$res_row['Project_id']]= array(
'project_id' => $res_row['Project_id'],
'project_name' => $res_row['Project_name'],
'state' => array( $res_row['Run_State'] => array ('nb_run' => $res_row['Nb_run'], 'size_run' =>$res_row['sum_run_storage']+$res_row['sum_run_purged'])));
}
else
{
$by_project[$res_row['Project_id']]['state'][$res_row['Run_State']] = array ('nb_run' => $res_row['Nb_run'], 'size_run' =>$res_row['sum_run_storage']+$res_row['sum_run_purged']);
}
}
# select runs-analyzes
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid as Project_id , tx_nG6_project.name AS Project_name, count( DISTINCT tx_nG6_analyze.uid ) AS Nb_analyze, sum( tx_nG6_analyze.storage_size /1000000000 ) AS sum_analyze_storage, sum(tx_nG6_analyze.purged_size/1000000000) AS sum_analyze_purged, tx_nG6_analyze.data_state AS Analyze_State',
'FROM' => 'tx_nG6_run '
.'INNER JOIN tx_nG6_project_run ON tx_nG6_project_run.run_id = tx_nG6_run.uid '
.'INNER JOIN tx_nG6_project ON tx_nG6_project.uid = tx_nG6_project_run.project_id '
.'INNER JOIN tx_nG6_run_analyze ON tx_nG6_run_analyze.run_id = tx_nG6_run.uid '
.'INNER JOIN tx_nG6_analyze ON tx_nG6_run_analyze.analyze_id = tx_nG6_analyze.uid',
'WHERE' => 'DATEDIFF( FROM_UNIXTIME( tx_nG6_analyze.retention_date ) , now( ) ) <0 '
.$queryWHERE_ANDproject,
'GROUPBY' => 'tx_nG6_run.uid,tx_nG6_analyze.data_state',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if (!isset ($by_project[$res_row['Project_id']])) {
$by_project[$res_row['Project_id']]= array(
'project_id' => $res_row['Project_id'],
'project_name' => $res_row['Project_name'],
'state' => array());
}
if (!isset ($by_project[$res_row['Project_id']]['state'][$res_row['Analyze_State']])){
$by_project[$res_row['Project_id']]['state'][$res_row['Analyze_State']]=array("nb_analyze"=>0, "size_analyze"=>0);
}
$by_project[$res_row['Project_id']]['state'][$res_row['Analyze_State']]['nb_analyze'] +=$res_row['Nb_analyze'];
$by_project[$res_row['Project_id']]['state'][$res_row['Analyze_State']]['size_analyze'] +=$res_row['sum_analyze_storage']+$res_row['sum_analyze_purged'];
}
# select project-analyzes
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid as Project_id , tx_nG6_project.name AS Project_name, count( DISTINCT tx_nG6_analyze.uid ) AS Nb_analyze, sum( tx_nG6_analyze.storage_size /1000000000 ) AS sum_analyze_storage, sum(tx_nG6_analyze.purged_size/1000000000) AS sum_analyze_purged, tx_nG6_analyze.data_state AS Analyze_State',
'FROM' => 'tx_nG6_project '
.'INNER JOIN tx_nG6_project_analyze ON tx_nG6_project_analyze.project_id = tx_nG6_project.uid '
.'INNER JOIN tx_nG6_analyze ON tx_nG6_project_analyze.analyze_id = tx_nG6_analyze.uid',
'WHERE' => 'DATEDIFF( FROM_UNIXTIME( tx_nG6_analyze.retention_date ) , now( ) ) <0 '
.$queryWHERE_ANDproject,
'GROUPBY' => 'tx_nG6_project.uid,tx_nG6_analyze.data_state',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if (!isset ($by_project[$res_row['Project_id']])) {
$by_project[$res_row['Project_id']]= array(
'project_id' => $res_row['Project_id'],
'project_name' => $res_row['Project_name'],
'state' => array( $res_row['Analyze_State'] => array ('nb_analyze' => $res_row['Nb_analyze'], 'size_analyze' =>$res_row['sum_analyze_storage']+$res_row['sum_analyze_purged'])));
}
else
{
$by_project[$res_row['Project_id']]['state'][$res_row['Analyze_State']] ['nb_analyze'] +=$res_row['Nb_analyze'];
$by_project[$res_row['Project_id']]['state'][$res_row['Analyze_State']] ['size_analyze'] +=$res_row['sum_analyze_storage']+$res_row['sum_analyze_purged'];
}
}
#retrieve user per project
$query_for_user = str_replace("AND","",$queryWHERE_ANDproject);
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid AS Project_id, fe_users.username AS user_name, fe_users.email, fe_users.usergroup, fe_rights.right_id',
'FROM' => 'tx_nG6_project '
.'INNER JOIN fe_rights ON fe_rights.project_id = tx_nG6_project.uid '
.'INNER JOIN fe_users ON fe_rights.fe_user_id = fe_users.uid '
.'INNER JOIN fe_groups ON fe_users.usergroup = fe_groups.uid',
'WHERE' => $query_for_user,
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if (!isset ($by_project[$res_row['Project_id']]["users"])) {
$by_project[$res_row['Project_id']]["users"]=array();
}
array_push($by_project[$res_row['Project_id']]["users"],array ('user_name' => $res_row['user_name'], 'email' =>$res_row['email'], 'groups' =>$res_row['usergroup'], 'right' =>$res_row['right_id']));
}
return ($by_project);
}
/**
* Select all project for the current user
......
This diff is collapsed.
......@@ -94,6 +94,7 @@ class tx_nG6_pi6 extends tslib_pibase {
$distribution = tx_nG6_db::select_projects_repartition('create_user', 'title');
$smarty->assign('distribution', $distribution);
$smarty->assign('ng6_admin_users', tx_nG6_db::get_ng6_admin_users() );
$smarty->assign('ng6_purge_projects', tx_nG6_db::select_retention_data_for_projects() );
return $smarty->fetch('administration_view.tpl');
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment