Commit 12b96285 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

run / project / analysis use storage_size field instead of listing all files

parent d5160b97
......@@ -232,14 +232,13 @@ class tx_nG6_eid {
} else if ($type == 'get_size') {
$ids = trim(t3lib_div::_GP('ids'));
$view = trim(t3lib_div::_GP('view'));
$data_folder = trim(t3lib_div::_GP('data_folder'));
$tab_ids = explode(",",$ids);
$full_size = 0;
foreach($tab_ids as $id => $value) {
if ($view == "run") {
$full_size += tx_nG6_db::get_run_size($value, $data_folder, true);
$full_size += tx_nG6_db::get_run_size($value, true);
} else if ($view == "project") {
$full_size += tx_nG6_db::get_project_size($value, $data_folder, true);
$full_size += tx_nG6_db::get_project_size($value, true);
}
}
print tx_nG6_utils::get_octet_string_representation($full_size);
......
......@@ -136,7 +136,7 @@ class tx_nG6_db {
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$current_size += tx_nG6_db::get_run_size($res_row['run_id'], $data_folder, $get_analyzes);
$current_size += tx_nG6_db::get_run_size($res_row['run_id'], $get_analyzes);
}
// get all project analysis the usergroup can access to
......@@ -158,7 +158,7 @@ class tx_nG6_db {
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$current_size += tx_nG6_db::get_analysis_size($res_row['analyze_id'], $data_folder);
$current_size += tx_nG6_db::get_analysis_size($res_row['analyze_id']);
}
}
......@@ -823,19 +823,19 @@ class tx_nG6_db {
* @param string $data_folder the data folder
* @param boolean $get_analyzes get analyzes size ?
*/
function get_project_size($p_id, $data_folder, $get_analyzes=false) {
function get_project_size($p_id, $get_analyzes=false) {
$full_size = 0;
// All runs
$project_runs = tx_nG6_db::get_project_runs($p_id);
foreach($project_runs as $run_id => $run_values) {
$full_size += tx_nG6_db::get_run_size($run_values['id'], $data_folder, $get_analyzes);
$full_size += tx_nG6_db::get_run_size($run_values['id'], $get_analyzes);
}
if ($get_analyzes) {
// All analysis
$project_analysis = tx_nG6_db::get_project_analysis($p_id);
foreach($project_analysis as $analyse_id => $analyze_values) {
$full_size += tx_nG6_db::get_analysis_size($analyze_values['id'], $data_folder);
$full_size += tx_nG6_db::get_analysis_size($analyze_values['id']);
}
}
return $full_size;
......@@ -935,6 +935,7 @@ class tx_nG6_db {
'tx_nG6_run.full_seq_size, '.
'tx_nG6_run.hidden AS run_hidden, '.
'tx_nG6_run.nb_sequences, '.
'tx_nG6_run.storage_size, '.
'tx_nG6_run.date AS run_date',
'FROM' => 'fe_rights '.
'INNER JOIN tx_nG6_project ON tx_nG6_project.uid=fe_rights.project_id '.
......@@ -958,6 +959,7 @@ class tx_nG6_db {
'hidden' => $row['run_hidden'],
'species' => $row['run_species'],
'nb_sequences' => $row['nb_sequences'],
'storage_size' => intval($row['storage_size']),
'full_seq_size' => $row['full_seq_size'],
'date' => $row['run_date'],
'data_nature' => $row['run_data_nature'],
......@@ -1174,21 +1176,18 @@ class tx_nG6_db {
* @param string $data_folder the data folder
* @param boolean $get_analyzes get analyzes size ?
*/
function get_run_size($r_id, $data_folder, $get_analyzes=false) {
function get_run_size($r_id, $get_analyzes=false) {
$full_size = 0;
if($get_analyzes){
$run_analysis = tx_nG6_db::get_run_analysis($r_id);
foreach($run_analysis as $analyse_id => $analyze_values) {
$full_size += tx_nG6_db::get_analysis_size($analyze_values['id'], $data_folder);
$full_size += tx_nG6_db::get_analysis_size($analyze_values['id']);
}
}
// Then select the run
$my_run = tx_nG6_db::select_run($r_id);
foreach(scandir($data_folder.$my_run['directory']) as $file) {
if (is_file($data_folder.$my_run['directory']."/".$file)) {
$full_size += filesize($data_folder.$my_run['directory']."/".$file);
}
}
$full_size += $my_run['storage_size'];
return $full_size;
}
......@@ -1311,6 +1310,7 @@ class tx_nG6_db {
'tx_nG6_analyze.description AS analyze_description, '.
'tx_nG6_analyze.version AS analyze_version, '.
'tx_nG6_analyze.is_editable AS analyze_is_editable, '.
'tx_nG6_analyze.storage_size AS analyze_storage_size, '.
'tx_nG6_analyze.parent_uid AS analyze_parent_uid ',
'FROM' => 'tx_nG6_project '.
'INNER JOIN tx_nG6_project_analyze ON tx_nG6_project.uid = tx_nG6_project_analyze.project_id '.
......@@ -1340,6 +1340,7 @@ class tx_nG6_db {
'description' => $row['analyze_description'],
'parent_id' => $row['analyze_parent_uid'],
'software' => $row['analyze_software'],
'storage_size' => intval($row['analyze_storage_size']),
'version' => $row['analyze_version'],
'is_editable' => $row['analyze_is_editable']
);
......@@ -1361,6 +1362,7 @@ class tx_nG6_db {
'tx_nG6_analyze.version AS analyze_version, '.
'tx_nG6_analyze.description AS analyze_description,'.
'tx_nG6_analyze.is_editable AS analyze_is_editable,'.
'tx_nG6_analyze.storage_size AS analyze_storage_size, '.
'tx_nG6_analyze.parent_uid AS analyze_parent_uid ',
'FROM' => 'tx_nG6_project '.
'INNER JOIN tx_nG6_project_run ON tx_nG6_project_run.project_id = tx_nG6_project.uid '.
......@@ -1389,6 +1391,7 @@ class tx_nG6_db {
'software' => $row['analyze_software'],
'parent_id' => $row['analyze_parent_uid'],
'version' => $row['analyze_version'],
'storage_size' => intval($row['analyze_storage_size']),
'is_editable' => $row['analyze_is_editable']
);
}
......@@ -1436,16 +1439,10 @@ class tx_nG6_db {
* @param string $a_id the analysis id to return the size
* @param string $data_folder the data folder
*/
function get_analysis_size($a_id, $data_folder) {
function get_analysis_size($a_id) {
// First select the analyse
$my_analysis = tx_nG6_db::select_analyse($a_id);
$full_size = 0;
foreach(scandir($data_folder.$my_analysis['directory']) as $file) {
if (is_file($data_folder.$my_analysis['directory']."/".$file)) {
$full_size += filesize($data_folder.$my_analysis['directory']."/".$file);
}
}
return $full_size;
return $my_analysis['storage_size'];
}
/**
......
......@@ -306,7 +306,7 @@ class tx_nG6_pi1 extends tslib_pibase {
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
$smarty->assign('analyse', $analyse);
$analysis_size = tx_nG6_db::get_analysis_size($this->piVars['analyze_id'], $this->conf['data']);
$analysis_size = tx_nG6_db::get_analysis_size($this->piVars['analyze_id']);
$smarty->assign('analyse_size', tx_nG6_utils::get_octet_string_representation($analysis_size));
$smarty->assign('data_folder', $this->conf["data"]);
......
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