Skip to content

Commit

Permalink
EZP-32243: Exposed repository object counts in database tab (#76)
Browse files Browse the repository at this point in the history
Added "Repository" tab in "Admin -> System Info" providing current Repository metrics:
- published content objects count,
- users count,
- drafts count,
- content types count.

* Exposed repository object counts in database tab

* Marked contracts as internal, to be fine-tuned before exposing as API

Co-authored-by: Paweł Niedzielski <pawel.niedzielski@ibexa.co>
Co-authored-by: Andrew Longosz <alongosz@users.noreply.github.com>
  • Loading branch information
3 people authored and kacper-wieczorek-ibexa committed Sep 24, 2021
1 parent 52d659f commit aee6393
Show file tree
Hide file tree
Showing 27 changed files with 803 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

class EzSystemsEzSupportToolsExtension extends Extension implements PrependExtensionInterface
{
public const METRICS_TAG = 'ibexa.system_info.metrics';

public function getAlias()
{
return 'ezplatform_support_tools';
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/Resources/config/default_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ parameters:
match:
SystemInfo\Identifier: 'composer'
database:
template: '@@ezdesign/system_info/database.html.twig'
template: '@@ezdesign/system_info/repository.html.twig'
match:
SystemInfo\Identifier: 'database'
SystemInfo\Identifier: 'repository'
hardware:
template: '@@ezdesign/system_info/hardware.html.twig'
match:
Expand Down
65 changes: 55 additions & 10 deletions src/bundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ parameters:
support_tools.system_info.output_registry.class: EzSystems\EzSupportToolsBundle\SystemInfo\OutputFormatRegistry
support_tools.system_info.ezc.wrapper.class: EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper
support_tools.system_info.collector.composer.lock_file.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector
support_tools.system_info.collector.database.doctrine.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\DoctrineDatabaseSystemInfoCollector
support_tools.system_info.collector.system.ibexa.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\IbexaSystemInfoCollector
support_tools.system_info.collector.hardware.ezc.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcHardwareSystemInfoCollector
support_tools.system_info.collector.php.ezc.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcPhpSystemInfoCollector
Expand All @@ -35,14 +34,12 @@ parameters:

services:
# EventSubscriber

EzSystems\EzSupportToolsBundle\EventSubscriber\AddXPoweredByHeader:
arguments: ["%ezplatform_support_tools.system_info.powered_by.name%"]
tags:
- { name: kernel.event_subscriber }

# Console

support_tools.command.dump_info:
class: "%support_tools.command.dump_info.class%"
arguments:
Expand All @@ -62,7 +59,6 @@ services:
lazy: true

# SystemInfoCollectors

support_tools.system_info.collector.system.ibexa:
class: '%support_tools.system_info.collector.system.ibexa.class%'
arguments:
Expand All @@ -80,13 +76,13 @@ services:
tags:
- { name: "support_tools.system_info.collector", identifier: "composer" }

support_tools.system_info.collector.database.doctrine:
class: "%support_tools.system_info.collector.database.doctrine.class%"
arguments:
- "@ezpublish.persistence.connection"
EzSystems\EzSupportToolsBundle\SystemInfo\Collector\RepositorySystemInfoCollector:
lazy: true
autowire: true
arguments:
$db: '@ezpublish.persistence.connection'
tags:
- { name: "support_tools.system_info.collector", identifier: "database" }
- { name: "support_tools.system_info.collector", identifier: "repository" }

support_tools.system_info.collector.hardware.ezc:
class: "%support_tools.system_info.collector.hardware.ezc.class%"
Expand All @@ -111,8 +107,57 @@ services:
- { name: "support_tools.system_info.collector", identifier: "symfony_kernel" }

# SystemInfoOutputFormats

support_tools.system_info.output_format.json:
class: "%support_tools.system_info.output_format.json.class%"
tags:
- { name: "support_tools.system_info.output_format", format: "json" }

# Gateways
EzSystems\EzSupportTools\Storage\MetricsProvider:
alias: EzSystems\EzSupportTools\Storage\AggregateMetricsProvider

EzSystems\EzSupportTools\Storage\AggregateMetricsProvider:
arguments:
$metrics: !tagged_locator
tag: !php/const \EzSystems\EzSupportToolsBundle\DependencyInjection\EzSystemsEzSupportToolsExtension::METRICS_TAG
index_by: identifier

EzSystems\EzSupportTools\Storage\Metrics\RepositoryConnectionAwareMetrics:
abstract: true
arguments:
$connection: '@ezpublish.persistence.connection'

EzSystems\EzSupportTools\Storage\Metrics\PublishedContentObjectsCountMetrics:
parent: EzSystems\EzSupportTools\Storage\Metrics\RepositoryConnectionAwareMetrics
tags:
-
name: !php/const \EzSystems\EzSupportToolsBundle\DependencyInjection\EzSystemsEzSupportToolsExtension::METRICS_TAG
identifier: published

EzSystems\EzSupportTools\Storage\Metrics\UsersCountMetrics:
parent: EzSystems\EzSupportTools\Storage\Metrics\RepositoryConnectionAwareMetrics
tags:
-
name: !php/const \EzSystems\EzSupportToolsBundle\DependencyInjection\EzSystemsEzSupportToolsExtension::METRICS_TAG
identifier: users

EzSystems\EzSupportTools\Storage\Metrics\DraftsCountMetrics:
parent: EzSystems\EzSupportTools\Storage\Metrics\RepositoryConnectionAwareMetrics
tags:
-
name: !php/const \EzSystems\EzSupportToolsBundle\DependencyInjection\EzSystemsEzSupportToolsExtension::METRICS_TAG
identifier: drafts

EzSystems\EzSupportTools\Storage\Metrics\VersionsCountMetrics:
parent: EzSystems\EzSupportTools\Storage\Metrics\RepositoryConnectionAwareMetrics
tags:
-
name: !php/const \EzSystems\EzSupportToolsBundle\DependencyInjection\EzSystemsEzSupportToolsExtension::METRICS_TAG
identifier: versions

EzSystems\EzSupportTools\Storage\Metrics\ContentTypesCountMetrics:
parent: EzSystems\EzSupportTools\Storage\Metrics\RepositoryConnectionAwareMetrics
tags:
-
name: !php/const \EzSystems\EzSupportToolsBundle\DependencyInjection\EzSystemsEzSupportToolsExtension::METRICS_TAG
identifier: content_types
38 changes: 34 additions & 4 deletions src/bundle/Resources/translations/systeminfo.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,36 @@
<target state="new">CPU</target>
<note>key: cpu</note>
</trans-unit>
<trans-unit id="7d98ad90ac8076d2bda25ff05688ced394d0ca1b" resname="repository">
<source>Repository</source>
<target state="new">Repository</target>
<note>key: repository</note>
</trans-unit>
<trans-unit id="5de05c757e2ce051da58581c67074f5fa96fe424" resname="repository.published_content_objects_count">
<source>Published content objects count</source>
<target state="new">Published content objects count</target>
<note>key: repository.published_content_objects_count</note>
</trans-unit>
<trans-unit id="2f9d49c355e4660fbb8cc89c39d048b53edc7e3c" resname="repository.users_count">
<source>Users count</source>
<target state="new">Users count</target>
<note>key: repository.users_count</note>
</trans-unit>
<trans-unit id="f17704b4dda4d61ecc379a0960655f35c6abef2d" resname="repository.drafts_count">
<source>Drafts count</source>
<target state="new">Drafts count</target>
<note>key: repository.drafts_count</note>
</trans-unit>
<trans-unit id="6fdeb59a15d4eea938b956273b9944a5c483dd57" resname="repository.versions_count">
<source>Versions count</source>
<target state="new">Versions count</target>
<note>key: repository.versions_count</note>
</trans-unit>
<trans-unit id="ca27c822aa4f52351a6a89150fc5ac970d052fca" resname="repository.content_types_count">
<source>Content Types count</source>
<target state="new">Content Types count</target>
<note>key: repository.content_types_count</note>
</trans-unit>
<trans-unit id="6d613a1ee01eec4c0f8ca66df0db71dca0c6e1cf" resname="database">
<source>Database</source>
<target state="new">Database</target>
Expand Down Expand Up @@ -221,10 +251,10 @@
<target state="new">Composer</target>
<note>key: tab.name.composer</note>
</trans-unit>
<trans-unit id="7a874a3b12fa965b16ed628878c5f6ce9c53b59f" resname="tab.name.database">
<source>Database</source>
<target state="new">Database</target>
<note>key: tab.name.database</note>
<trans-unit id="1d99640a1a35d6f805a048ba701c6b98aed7654b" resname="tab.name.repository">
<source>Repository</source>
<target state="new">Repository</target>
<note>key: tab.name.repository</note>
</trans-unit>
<trans-unit id="951e3ad18b17f0b2aa96fcb84f6eb25f208e1127" resname="tab.name.hardware">
<source>Hardware</source>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{% trans_default_domain "systeminfo" %}

<!-- Tab name: {{ 'tab.name.repository'|trans|desc('Repository') }} -->

<section class="ez-fieldgroup">
<h2 class="ez-fieldgroup__name">{{ 'repository'|trans|desc('Repository') }}</h2>
<div class="ez-fieldgroup__content">
<table class="table ez-table--list">
<tbody>
<tr class="ez-table__row">
<td class="ez-table__cell">
{{ 'repository.published_content_objects_count'|trans|desc('Published content objects count') }}
</td>
<td class="ez-table__cell">{{ info.repositoryMetrics.publishedCount }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.users_count'|trans|desc('Users count') }}</td>
<td class="ez-table__cell">{{ info.repositoryMetrics.usersCount }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.drafts_count'|trans|desc('Drafts count') }}</td>
<td class="ez-table__cell">{{ info.repositoryMetrics.draftsCount }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.versions_count'|trans|desc('Versions count') }}</td>
<td class="ez-table__cell">{{ info.repositoryMetrics.versionsCount }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.content_types_count'|trans|desc('Content Types count') }}</td>
<td class="ez-table__cell">{{ info.repositoryMetrics.contentTypesCount }}</td>
</tr>
</tbody>
</table>
</div>
</section>
<section class="ez-fieldgroup">
<h2 class="ez-fieldgroup__name">{{ 'database'|trans|desc('Database') }}</h2>
<div class="ez-fieldgroup__content">
<table class="table ez-table--list">
<tbody>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.type'|trans|desc('Type') }}</td>
<td class="ez-table__cell">{{ info.type }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.name'|trans|desc('Name') }}</td>
<td class="ez-table__cell">{{ info.name }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.host'|trans|desc('Host') }}</td>
<td class="ez-table__cell">{{ info.host }}</td>
</tr>
<tr class="ez-table__row">
<td class="ez-table__cell">{{ 'repository.username'|trans|desc('Username') }}</td>
<td class="ez-table__cell">{{ info.username }}</td>
</tr>
</tbody>
</table>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
namespace EzSystems\EzSupportToolsBundle\SystemInfo\Collector;

use EzSystems\EzSupportToolsBundle\SystemInfo\Value;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\SymfonyKernelSystemInfo;
use Symfony\Component\HttpKernel\Kernel;

/**
Expand Down Expand Up @@ -45,13 +45,13 @@ public function __construct(Kernel $kernel, array $bundles)
/**
* Collects information about the Symfony kernel.
*
* @return Value\SymfonyKernelSystemInfo
* @return \EzSystems\EzSupportToolsBundle\SystemInfo\Value\SymfonyKernelSystemInfo
*/
public function collect()
public function collect(): SymfonyKernelSystemInfo
{
ksort($this->bundles, SORT_FLAG_CASE | SORT_STRING);

return new Value\SymfonyKernelSystemInfo([
return new SymfonyKernelSystemInfo([
'environment' => $this->kernel->getEnvironment(),
'debugMode' => $this->kernel->isDebug(),
'version' => Kernel::VERSION,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace EzSystems\EzSupportToolsBundle\SystemInfo\Collector;

use EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\HardwareSystemInfo;

/**
* Collects hardware system information using zetacomponents/sysinfo.
Expand All @@ -29,11 +29,11 @@ public function __construct(EzcSystemInfoWrapper $ezcSystemInfo)
* - cpu information
* - memory size.
*
* @return Value\HardwareSystemInfo
* @return \EzSystems\EzSupportToolsBundle\SystemInfo\Value\HardwareSystemInfo
*/
public function collect()
public function collect(): HardwareSystemInfo
{
return new Value\HardwareSystemInfo([
return new HardwareSystemInfo([
'cpuType' => $this->ezcSystemInfo->cpuType,
'cpuSpeed' => $this->ezcSystemInfo->cpuSpeed,
'cpuCount' => $this->ezcSystemInfo->cpuCount,
Expand Down
8 changes: 4 additions & 4 deletions src/bundle/SystemInfo/Collector/EzcPhpSystemInfoCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace EzSystems\EzSupportToolsBundle\SystemInfo\Collector;

use EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\PhpSystemInfo;

/**
* Collects PHP information using zetacomponents/sysinfo.
Expand All @@ -29,9 +29,9 @@ public function __construct(EzcSystemInfoWrapper $ezcSystemInfo)
* - php version
* - php accelerator info.
*
* @return Value\PhpSystemInfo
* @return \EzSystems\EzSupportToolsBundle\SystemInfo\Value\PhpSystemInfo
*/
public function collect()
public function collect(): PhpSystemInfo
{
$properties = [
'version' => PHP_VERSION,
Expand All @@ -50,6 +50,6 @@ public function collect()
);
}

return new Value\PhpSystemInfo($properties);
return new PhpSystemInfo($properties);
}
}
Loading

0 comments on commit aee6393

Please sign in to comment.