protected function collectGarbage()
 {
     $table = new PhabricatorSystemActionLog();
     $conn_w = $table->establishConnection('w');
     queryfx($conn_w, 'DELETE FROM %T WHERE epoch < %d LIMIT 100', $table->getTableName(), $this->getGarbageEpoch());
     return $conn_w->getAffectedRows() == 100;
 }
 public function collectGarbage()
 {
     $ttl = phutil_units('3 days in seconds');
     $table = new PhabricatorSystemActionLog();
     $conn_w = $table->establishConnection('w');
     queryfx($conn_w, 'DELETE FROM %T WHERE epoch < %d LIMIT 100', $table->getTableName(), time() - $ttl);
     return $conn_w->getAffectedRows() == 100;
 }
 /**
  * Reset all action counts for actions taken by some set of actors in the
  * previous action window.
  *
  * @param list<string> Actors to reset counts for.
  * @return int Number of actions cleared.
  */
 public static function resetActions(array $actors)
 {
     $log = new PhabricatorSystemActionLog();
     $conn_w = $log->establishConnection('w');
     $now = PhabricatorTime::getNow();
     $hashes = array();
     foreach ($actors as $actor) {
         $hashes[] = PhabricatorHash::digestForIndex($actor);
     }
     queryfx($conn_w, 'DELETE FROM %T
     WHERE actorHash IN (%Ls) AND epoch BETWEEN %d AND %d', $log->getTableName(), $hashes, $now - self::getWindow(), $now);
     return $conn_w->getAffectedRows();
 }
 private static function recordAction(array $actors, PhabricatorSystemAction $action, $score)
 {
     $log = new PhabricatorSystemActionLog();
     $conn_w = $log->establishConnection('w');
     $sql = array();
     foreach ($actors as $actor) {
         $sql[] = qsprintf($conn_w, '(%s, %s, %s, %f, %d)', PhabricatorHash::digestForIndex($actor), $actor, $action->getActionConstant(), $score, time());
     }
     foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
         queryfx($conn_w, 'INSERT INTO %T (actorHash, actorIdentity, action, score, epoch)
       VALUES %Q', $log->getTableName(), $chunk);
     }
 }