Skip to content
Browse files

calculate milestones

  • Loading branch information...
1 parent 5362fb5 commit ebb34a30aa44115d6638705f2134225bc8dcc258 @tommyrot committed Sep 29, 2012
Showing with 23 additions and 23 deletions.
  1. +23 −23 maintenance.php
View
46 maintenance.php
@@ -51,29 +51,7 @@ public function __construct($settings)
}
}
- public function do_maintenance($mysqli)
- {
- $this->mysqli = $mysqli;
- $this->output('notice', 'do_maintenance(): performing database maintenance routines');
- $query = @mysqli_query($this->mysqli, 'select count(*) as `usercount` from `user_status`') or $this->output('critical', 'mysqli: '.mysqli_error($this->mysqli));
- $rows = mysqli_num_rows($query);
-
- if (!empty($rows)) {
- $result = mysqli_fetch_object($query);
- }
-
- if (empty($result->usercount)) {
- $this->output('warning', 'do_maintenance(): database is empty, nothing to do');
- } else {
- $this->fix_user_status_errors();
- $this->register_most_active_alias();
- $this->make_materialized_views();
- $this->fetch_milestones();
- $this->output('notice', 'do_maintenance(): maintenance completed');
- }
- }
-
- private function fetch_milestones()
+ private function calculate_milestones()
{
$query = @mysqli_query($this->mysqli, 'select `q_activity_by_day`.`ruid`, `date`, `l_total` from `q_activity_by_day` join `user_status` on `q_activity_by_day`.`ruid` = `user_status`.`uid` where `status` != 3 order by `ruid` asc, `date` asc') or $this->output('critical', 'mysqli: '.mysqli_error($this->mysqli));
$rows = mysqli_num_rows($query);
@@ -108,6 +86,28 @@ private function fetch_milestones()
}
}
+ public function do_maintenance($mysqli)
+ {
+ $this->mysqli = $mysqli;
+ $this->output('notice', 'do_maintenance(): performing database maintenance routines');
+ $query = @mysqli_query($this->mysqli, 'select count(*) as `usercount` from `user_status`') or $this->output('critical', 'mysqli: '.mysqli_error($this->mysqli));
+ $rows = mysqli_num_rows($query);
+
+ if (!empty($rows)) {
+ $result = mysqli_fetch_object($query);
+ }
+
+ if (empty($result->usercount)) {
+ $this->output('warning', 'do_maintenance(): database is empty, nothing to do');
+ } else {
+ $this->fix_user_status_errors();
+ $this->register_most_active_alias();
+ $this->make_materialized_views();
+ $this->calculate_milestones();
+ $this->output('notice', 'do_maintenance(): maintenance completed');
+ }
+ }
+
/**
* Fix user status errors.
*

0 comments on commit ebb34a3

Please sign in to comment.
Something went wrong with that request. Please try again.