Skip to content
Snippets Groups Projects
Commit af9c834a authored by Lidiya Gelemeev's avatar Lidiya Gelemeev
Browse files

Use constants for states

parent 119fd9b1
No related branches found
No related tags found
1 merge request!1Devel
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
......@@ -11,6 +11,8 @@ use OCP\IDBConnection;
abstract class BaseCollector implements ICollector {
const RETRY_TIMES = 3;
const STATE_ENABLED = 'true';
const STATE_DISABLED = 'false';
public function collect(IDBConnection $db, int $timestamp, int $chunkSize, ConfigService $config) {
$data = null;
......
......@@ -10,7 +10,7 @@ use OCP\IDBConnection;
class FileTypesCountsCollector extends BaseCollector {
protected function collectData(IDBConnection $db, int $timestamp, int $chunkSize, ConfigService $config) {
$fileCounts = [];
$mapper = new FilecacheMapper($db, $chunkSize, $config->getSnapshotFiletypesFilterClosedAccounts() ? '1' : 0);
$mapper = new FilecacheMapper($db, $chunkSize, $config->getSnapshotFiletypesFilterClosedAccounts() ? self::STATE_ENABLED : 0);
$counts = $mapper->queryFiletypesCounts();
foreach ($config->getSnapshotFileTypes()->groups() as $groupName => $group) {
if (!$group->isCollectEnabled()) {
......
......@@ -13,7 +13,7 @@ class FilesCountCollector extends BaseCollector {
protected function collectData(IDBConnection $db, int $timestamp, int $chunkSize, ConfigService $config) {
$mapper = new FilecacheMapper($db, $chunkSize);
$totalCount = $mapper->queryTotalFilesCount();
$mapper->setAccountsState(0); # disabled
$mapper->setAccountsState(self::STATE_DISABLED);
$obsoleteCount = $mapper->queryTotalFilesCount();
return [
FilesCountValue::TOTAL_COUNT => $totalCount,
......
......@@ -13,7 +13,7 @@ class FilesSizeCollector extends BaseCollector {
protected function collectData(IDBConnection $db, int $timestamp, int $chunkSize, ConfigService $config) {
$mapper = new FilecacheMapper($db, $chunkSize);
$totalCount = $mapper->queryTotalFilesSize();
$mapper->setAccountsState(0); #disabled
$mapper->setAccountsState(self::STATE_DISABLED);
$obsoleteCount = $mapper->queryTotalFilesSize();
return [
FilesSizeValue::TOTAL_SIZE => $totalCount,
......
......@@ -12,8 +12,8 @@ use OCP\IDBConnection;
class UsersCountCollector extends BaseCollector {
protected function collectData(IDBConnection $db, int $timestamp, int $chunkSize, ConfigService $config): array {
$mapper = new PreferencesMapper($db, $chunkSize);
$activeUsers = $mapper->queryTotalCount('true');
$closedUsers = $mapper->queryTotalCount('false');
$activeUsers = $mapper->queryTotalCount(self::STATE_ENABLED);
$closedUsers = $mapper->queryTotalCount(self::STATE_DISABLED);
$values = [UsersCountValue::TOTAL_COUNT => $activeUsers + $closedUsers, UsersCountValue::CLOSED_COUNT => $closedUsers];
foreach (TimePeriods::periods() as $k => $period) {
$values[$k] = $mapper->queryActiveCount($period->before($timestamp));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment