Skip to content

Commit

Permalink
afanasy statistics: division by zero checks added, default stat perio…
Browse files Browse the repository at this point in the history
…d is now - (now-48days)
  • Loading branch information
timurhai committed Apr 16, 2021
1 parent f6ee324 commit 9336310
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions afanasy/statistics/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ g_graph_intervals.week = {"seconds":60 * 60 * 24 * 7,"intervals":[ 1 ],"offset

g_args = {};
g_args.action = 'jobs_table';
g_args.time_min = 0;
g_args.time_max = Math.round((new Date()).valueOf() / 1000);
g_args.time_min = g_args.time_max - (60*60 * 24 * 48);
g_args.folder = '/';

g_folders = [];
Expand All @@ -37,8 +37,8 @@ function g_Start( i_data, i_args)
g_Log('Server: ' + JSON.stringify( i_data.server, null,' '));

// Get time min and max:
g_args.time_min = i_data.time.time_min;
g_args.time_max = i_data.time.time_max;
/*g_args.time_min = i_data.time.time_min;
g_args.time_max = i_data.time.time_max;*/


// Initialize folders:
Expand Down
10 changes: 6 additions & 4 deletions afanasy/statistics/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ function init( $i_args, &$o_out)
$dbconn = db_connect();

# Time min and max:
$time = array();
/*$time = array();
$query="SELECT min(time_done) AS time_done FROM jobs WHERE time_done > 0;";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$line = pg_fetch_array( $result, null, PGSQL_ASSOC);
$time['time_min'] = (int)$line["time_done"];
pg_free_result($result);
if( $time['time_min'] == '') $time['time_min'] = 0;
$time['time_max'] = time();
$o_out['time'] = $time;
$o_out['time'] = $time;*/

# Folders:
$query="SELECT min(folder) as folder FROM jobs GROUP BY folder ORDER BY folder;";
Expand Down Expand Up @@ -129,7 +129,8 @@ function get_jobs_folders( $i_args, &$o_out)
}
pg_free_result($sub_result);
$line['fav_service'] = $sub_name;
$line['fav_service_percent'] = $sub_favourite/$sub_total;
if ($sub_total > 0)
$line['fav_service_percent'] = $sub_favourite/$sub_total;

# Get folder favorite user:
$sub_query="
Expand All @@ -156,7 +157,8 @@ function get_jobs_folders( $i_args, &$o_out)
}
pg_free_result($sub_result);
$line['fav_user'] = $sub_name;
$line['fav_user_percent'] = $sub_favourite/$sub_total;
if ($sub_total > 0)
$line['fav_user_percent'] = $sub_favourite/$sub_total;

$o_out['table'][] = $line;
}
Expand Down

0 comments on commit 9336310

Please sign in to comment.