Commit f7582c32 authored by Celine Noirot's avatar Celine Noirot
Browse files

Add 2 years purge data (version alpha) with graphique evolution

parent 8369a8e8
...@@ -525,17 +525,17 @@ class tx_nG6_db { ...@@ -525,17 +525,17 @@ class tx_nG6_db {
return $final_results; return $final_results;
} }
function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $cumulate) { function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $cumulate) {
error_log(date(DATE_RFC2822) . " entrée dans select_storage_evolution\n",3,"/save/ng6-test/src/nG6/ui/nG6/testMM.log");
if ($by == "organism" || $by == "location") { if ($by == "organism" || $by == "location") {
$by = "tx_nG6_".$by; $by = "tx_nG6_".$by;
} }
$storage_unit = "full_seq_size"; $storage_unit = "full_seq_size";
if ($octet) { if ($octet) {
$storage_unit = "storage_size"; $storage_unit = "storage_size";
} }
$from = "" ; $from = "" ;
$where = "fe_groups.".$by." IN ('".implode("', '", $values)."')" ; $where = "fe_groups.".$by." IN ('".implode("', '", $values)."')" ;
if ($role == "create_user") { if ($role == "create_user") {
$from = 'tx_nG6_project ' $from = 'tx_nG6_project '
.' INNER JOIN tx_nG6_project_run ON tx_nG6_project_run.project_id= tx_nG6_project.uid' .' INNER JOIN tx_nG6_project_run ON tx_nG6_project_run.project_id= tx_nG6_project.uid'
...@@ -563,8 +563,6 @@ function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $c ...@@ -563,8 +563,6 @@ function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $c
$results = array(); $results = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
error_log("select_storage_evolution recup runs ".$res_row["crdate"]." - ".$res_row[$storage_unit] ."\n",3,"/save/ng6-test/src/nG6/ui/nG6/testMM.log");
$analyses_size = 0; $analyses_size = 0;
$analyses_size_purged = 0; $analyses_size_purged = 0;
if ($get_analyzes && $octet) { if ($get_analyzes && $octet) {
...@@ -576,19 +574,15 @@ function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $c ...@@ -576,19 +574,15 @@ function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $c
} }
if( array_key_exists( $res_row["crdate"], $results) ) { if( array_key_exists( $res_row["crdate"], $results) ) {
$results[$res_row["crdate"]] += array($res_row[$storage_unit] + $analyses_size, $res_row["purged_size"] + $analyses_size_purged); $results[$res_row["crdate"]][0] += $res_row[$storage_unit] + $analyses_size;
$results[$res_row["crdate"]][1] += $res_row["purged_size"] + $analyses_size_purged;
} else { } else {
$results[$res_row["crdate"]] = array($res_row[$storage_unit] + $analyses_size, $res_row["purged_size"] + $analyses_size_purged); $results[$res_row["crdate"]] = array($res_row[$storage_unit] + $analyses_size, $res_row["purged_size"] + $analyses_size_purged);
} }
} }
$final_results = array(); $final_results = array();
foreach($results as $group_key => $group_values) { foreach($results as $group_key => $group_values) {
//error_log("select_storage_evolution ".$group_key." - ".$group_values[0]." - ".$group_values[1] ."\n",3,"/save/ng6-test/src/nG6/ui/nG6/testMM.log");
if ($group_values[1] > 0){
error_log("select_storage_evolution purged ".$group_key." - ".$group_values[0]." - ".$group_values[1] ."\n",3,"/save/ng6-test/src/nG6/ui/nG6/testMM.log");
}
if ($cumulate && count($final_results) > 0) { if ($cumulate && count($final_results) > 0) {
$final_results[] = array( $group_key, $group_values[0] + $final_results[count($final_results)-1][1],$group_values[0] + $group_values[1] + $final_results[count($final_results)-1][2]); $final_results[] = array( $group_key, $group_values[0] + $final_results[count($final_results)-1][1],$group_values[0] + $group_values[1] + $final_results[count($final_results)-1][2]);
} else { } else {
...@@ -598,7 +592,7 @@ function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $c ...@@ -598,7 +592,7 @@ function select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $c
} }
return $final_results; return $final_results;
} }
/** /**
* Add a comment to the comment table * Add a comment to the comment table
* @param unknown $table_name * @param unknown $table_name
......
...@@ -695,15 +695,13 @@ function drawDataEvolution(stat_tables){ ...@@ -695,15 +695,13 @@ function drawDataEvolution(stat_tables){
real_group = $group_by.attr('id').split('_')[1], real_group = $group_by.attr('id').split('_')[1],
role = $("input[type=radio][name=users_to_consider]:checked").val(), role = $("input[type=radio][name=users_to_consider]:checked").val(),
values = getDatatableCheckedValue(stat_tables), values = getDatatableCheckedValue(stat_tables),
bases = $("#chk_display_bases").attr("checked") == "checked" ? "1" : "0", bases = $("#chk_display_bases")[0].checked ? "1" : "0",
analysis = $("#chk_includes_analyses").attr("checked") == "checked" ? "1" : "0", analysis = $("#chk_includes_analyses")[0].checked ? "1" : "0",
cumulate = $("#chk_cumulate")[0].checked ? "1" : "0" ; cumulate = $("#chk_cumulate")[0].checked ? "1" : "0" ;
$.ajax({ $.ajax({
url: "index.php?eID=tx_nG6&type=data_evolution&by="+group_by+"&role="+role+"&cumulate="+cumulate+"&get_analyzes="+analysis+"&bases="+bases+"&values="+values.join(","), url: "index.php?eID=tx_nG6&type=data_evolution&by="+group_by+"&role="+role+"&cumulate="+cumulate+"&get_analyzes="+analysis+"&bases="+bases+"&values="+values.join(","),
dataType: 'json', dataType: 'json',
success: function(val, status, xhr) { success: function(val, status, xhr) {
// reformat the data with values to integer // reformat the data with values to integer
var val_stored = []; var val_stored = [];
var val_purged = []; var val_purged = [];
...@@ -716,105 +714,58 @@ function drawDataEvolution(stat_tables){ ...@@ -716,105 +714,58 @@ function drawDataEvolution(stat_tables){
seriesData = [ seriesData = [
{ {
type:"line", type:"line",
name: "data storage size", name: "Size of data still stored",
data: val_stored, data: val_stored,
tooltip: {
valueSuffix: ' octets'
},
color: "green" color: "green"
},{ },{
type:"line", type:"line",
name: "data purged size", name: "Size of data (stored + purged)",
data: val_purged, yAxis: 1, data: val_purged,
tooltip: { color: "blue",
valueSuffix: ' octets' dashStyle: 'dash'
},
color: "blue"
} }
] ]
chart = new Highcharts.StockChart({ chart = new Highcharts.StockChart({
chart: { chart: {
renderTo: 'highcharts_graph', renderTo: 'highcharts_graph',
zoomType: 'xy'
}, },
rangeSelector: { rangeSelector: {
selected: 4 selected: 4
}, },
yAxis: [ yAxis: [
{ {
gridLineWidth: 1,
title: { title: {
text: 'Data stored', text: 'Size of data still stored',
style: { style: {
color: "green" color: "green"
} }
}, },
min: 0, min: 0
labels: {
formatter: function() {
if ($("#chk_display_bases").attr("checked") == "checked") {
return get_base_string_representation(this.value, 0);
} else {
return get_octet_string_representation(this.value, 0);
}
},
style: {
color: "green"
}
}
// ,
// plotLines: [{
// value: 0,
// width: 2,
// color: 'silver'
// }]
}, },
{ {
gridLineWidth: 0, gridLineWidth: 1,
title: { title: {
text: 'Data purged', text: 'Size of data (stored + purged)',
style: { style: {
color: "blue" color: "blue"
} }
}, },
min: 0, min: 0
labels: {
formatter: function() {
if ($("#chk_display_bases").attr("checked") == "checked") {
return get_base_string_representation(this.value, 0);
} else {
return get_octet_string_representation(this.value, 0);
}
},
style: {
color: "blue"
}
}
// ,
// plotLines: [{
// value: 0,
// width: 2,
// color: 'black'
// }]
, opposite: true}, , opposite: true},
], ],
tooltip: { tooltip: {
shared: true, formatter: function() {
// formatter: function() { var toolTipTxt = '<b>'+ Highcharts.dateFormat('%B %Y', this.x) + ":" +'</b>';
// var s = Highcharts.dateFormat('%B %Y', this.x) + ":"; $.each(this.points, function(i, point) {
// $.each(this.points, function(i, point) { toolTipTxt += '<br/><span style="color:'+ point.series.color +'"> ' + point.series.name + ': ' + get_octet_string_representation(point.y, 2)+'</span>';
// if ($("#chk_display_bases").attr("checked") == "checked") { });
// s += '<strong>'+ get_base_string_representation(point.y, 2) +'</strong>'; return toolTipTxt;
// } else { } ,shared: true,
// s += '<strong>'+ get_octet_string_representation(point.y, 2) +'</strong>';
// }
//
// });
// return s;
// }
}, },
credits: { enabled: false }, credits: { enabled: false },
series: seriesData, series: seriesData,
...@@ -828,7 +779,7 @@ function drawDataEvolution(stat_tables){ ...@@ -828,7 +779,7 @@ function drawDataEvolution(stat_tables){
function initStatMenuDataTables () { function initStatMenuDataTables () {
var stat_tables = {}; var stat_tables = {};
stat_tables["laboratories"] = $("#data_table_laboratories").DataTable({ stat_tables["laboratories"] = $("#data_table_laboratories").DataTable({
"language": { "language": {
"info": 'Showing _START_ to _END_ of _MAX_ entries <strong><small id="nb_selected_span"></small></strong>' "info": 'Showing _START_ to _END_ of _MAX_ entries <strong><small id="nb_selected_span"></small></strong>'
...@@ -861,14 +812,6 @@ function initStatMenuDataTables () { ...@@ -861,14 +812,6 @@ function initStatMenuDataTables () {
null, null,
null] null]
}); });
stat_tables["obsolete"] = $("#data_table_obsolete").DataTable({
"language": {
"info": 'Showing _START_ to _END_ of _MAX_ entries <strong><small id="nb_selected_span"></small></strong>'},
"order": [[ 1, "asc" ]],
"columns": [
{ "orderable": false },
null,null,null,null,null,null,null,null,null,null,null]
});
$("#data_table_laboratories, #data_table_organizations, #data_table_locations ").on( 'draw.dt', function () { $("#data_table_laboratories, #data_table_organizations, #data_table_locations ").on( 'draw.dt', function () {
var $table = $('div[id^=wrapper_datatable]:visible'), var $table = $('div[id^=wrapper_datatable]:visible'),
...@@ -885,6 +828,7 @@ function initStatMenuDataTables () { ...@@ -885,6 +828,7 @@ function initStatMenuDataTables () {
}); });
$.each(stat_tables,function(idx, table){ $.each(stat_tables,function(idx, table){
//console.log(table);
table.draw(); table.draw();
}); });
......
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