diff options
author | INOPIAE <inopiae@cacert.org> | 2015-01-13 07:19:46 +0100 |
---|---|---|
committer | INOPIAE <inopiae@cacert.org> | 2015-01-13 07:19:46 +0100 |
commit | 22568b513f5e7942718bda57a9ec5650af87b4ca (patch) | |
tree | d100a69b28f3692e15340b7b918fdf806e7e624a | |
parent | d36f9b7fb4b001f51ba5b06806e7913dfd74a74e (diff) | |
download | cacert-devel-22568b513f5e7942718bda57a9ec5650af87b4ca.tar.gz cacert-devel-22568b513f5e7942718bda57a9ec5650af87b4ca.tar.xz cacert-devel-22568b513f5e7942718bda57a9ec5650af87b4ca.zip |
bug 1357: replaced calculation of monthly assurer count with new function
-rwxr-xr-x | scripts/cron/refresh_stats.php | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/scripts/cron/refresh_stats.php b/scripts/cron/refresh_stats.php index 37c6bef..c58e907 100755 --- a/scripts/cron/refresh_stats.php +++ b/scripts/cron/refresh_stats.php @@ -135,44 +135,24 @@ function getDataFromLive() { having sum(`points`) >= 50 and sum(`points`) < 100 ) as `high_points`")); - $stats['assurer_candidates'] = number_format(tc( - "select count(*) as `count` from `users` - where ( - select sum(`points`) from `notary` - where `to`=`users`.`id` - and `deleted` = 0 - ) >= 100 - and not exists( - select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` - where `cp`.`user_id`=`users`.`id` - and `cp`.`variant_id`=`cv`.`id` - and `cv`.`type_id`=1 - )" - )); - - $stats['aussurers_with_test'] = number_format(tc( - "select count(*) as `count` from `users` - where ( - select sum(`points`) from `notary` - where `to`=`users`.`id` - and `deleted` = 0 - ) >= 100 - and exists( - select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` - where `cp`.`user_id`=`users`.`id` - and `cp`.`variant_id`=`cv`.`id` - and `cv`.`type_id`=1 - )" - )); + $startdate = date("Y-m-d", mktime(0, 0, 0, 1, 1, 2002)); + $enddate = date("Y-m-d", mktime(0, 0, 0, 1, 1, date("Y") + 1)); + + $stats['aussurers_with_test'] = number_format(assurer_count($startdate, $enddate,1)); + + $stats['assurer_candidates'] = number_format(assurer_count($startdate, $enddate,0) - $stats['aussurers_with_test']); + $stats['points_issued'] = number_format(tc( "select sum(greatest(`points`, `awarded`)) as `count` from `notary` where `deleted` = 0 and `method` = 'Face to Face Meeting'")); - $totalusers=0; - $totassurers=0; - $totalcerts=0; + $totalcerts = 0; + $totalusers = 0; + $totalcandidates = 0; + $totalassurers = 0; + for($i = 0; $i < 12; $i++) { $first_ts = mktime(0, 0, 0, date("m") - $i, 1, date("Y")); $next_month_ts = mktime(0, 0, 0, date("m") - $i + 1, 1, date("Y")); @@ -222,6 +202,7 @@ function getDataFromLive() { $tmp_arr = array(); $tmp_arr['date'] = date("Y-m", $first_ts); $tmp_arr['new_users'] = number_format($users); + $tmp_arr['new_candidates'] = number_format($candidates); $tmp_arr['new_assurers'] = number_format($assurers); $tmp_arr['new_certificates'] = number_format($certs); @@ -229,7 +210,8 @@ function getDataFromLive() { } $stats['growth_last_12m_total'] = array( 'new_users' => number_format($totalusers), - 'new_assurers' => number_format($totassurers), + 'new_candidates' => number_format($totalcandidates), + 'new_assurers' => number_format($totalassurers), 'new_certificates' => number_format($totalcerts), ); |