Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/Command/RedisNamespaceCleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$cacheAdapter = $this->cacheRegistry->get('cache.object');
$activeNamespaces = $this->cacheRegistry->getActiveNamespaces();

$dryRun = $input->getOption('dry-run');

try {
$redis = $cacheAdapter->getRedisOrFail();
} catch (\RuntimeException $e) {
$io->error($e->getMessage());
if (empty($activeNamespaces)) {
$io->error('No active Redis namespaces found. Please check your configuration.');

return Command::FAILURE;
}

$activeNamespace = $cacheAdapter->getNamespace();
$cacheApp = $this->cacheRegistry->get('cache.app');
$redis = $cacheApp->getRedisOrFail();

$io->title('Redis Namespace Cleanup');
$io->writeln(\sprintf('Active namespace: <info>%s</info>', $activeNamespace));
$io->writeln(\sprintf('Active namespaces: <info>%s</info>', implode(', ', $activeNamespaces)));

if ($dryRun) {
$io->note('Running in dry-run mode - no keys will be deleted');
Expand Down Expand Up @@ -73,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
++$namespaces[$namespace];

// Track keys that are not in the active namespace
if ($namespace !== $activeNamespace) {
if (!\in_array($namespace, $activeNamespaces, true)) {
$keysToDelete[] = $key;
}
}
Expand All @@ -82,10 +83,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Display namespace summary
$tableData = [];
foreach ($namespaces as $namespace => $count) {
$status = $namespace === $activeNamespace ? 'KEEP' : 'DELETE';
$status = \in_array($namespace, $activeNamespaces, true) ? 'KEEP' : 'DELETE';
$tableData[] = [$namespace, $count, $status];
}

usort($tableData, function ($a, $b) {
return $b[0] <=> $a[0];
});

$io->section('Namespace Summary');
$io->table(
['Namespace', 'Key Count', 'Action'],
Expand Down
8 changes: 6 additions & 2 deletions src/Command/RedisNamespaceListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::FAILURE;
}

$namespace = $cacheAdapter->getNamespace();
$activeNamespaces = $this->cacheRegistry->getActiveNamespaces();
$io->title('Redis Key Groupping by Namespace');

// Group keys by first 10 characters
Expand Down Expand Up @@ -66,9 +66,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Display results in a table
$tableData = [];
foreach ($keyGroups as $prefix => $count) {
$tableData[] = [$prefix, $count, \sprintf('%.1f%%', ($count / $totalKeys) * 100), $namespace === $prefix ? 'Yes' : 'No'];
$tableData[] = [$prefix, $count, \sprintf('%.1f%%', ($count / $totalKeys) * 100), \in_array($prefix, $activeNamespaces, true) ? 'Yes' : 'No'];
}

usort($tableData, function ($a, $b) {
return $b[0] <=> $a[0];
});

$io->table(
['Prefix', 'Count', 'Percentage', 'Active'],
$tableData
Expand Down
17 changes: 17 additions & 0 deletions src/Components/CacheRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,21 @@ public function has(string $name): bool
{
return isset($this->adapters[$name]);
}

/**
* @return array<string>
*/
public function getActiveNamespaces(): array
{
$list = [];

foreach ($this->adapters as $adapter) {
try {
$list[] = $adapter->getNamespace();
} catch (\Exception) {
}
}

return array_unique($list);
}
}
2 changes: 1 addition & 1 deletion src/Resources/app/administration/src/api/frosh-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class FroshTools extends ApiService {
headers: this.getBasicHeaders(),
})
.then((response) => {
return response
return response;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ Component.register('frosh-tools-tab-files', {

async createdComponent() {
this.items = (await this.froshToolsService.getShopwareFiles()).data;
this.extensionItems = (await this.froshToolsService.getExtensionFiles()).data;
this.extensionItems = (
await this.froshToolsService.getExtensionFiles()
).data;
this.isLoading = false;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,19 @@
<dd v-for="file in extensionResult.newFiles">
{{ file }}
</dd>
<dt
v-if="extensionResult.changedFiles.length > 0"
>
<dt v-if="extensionResult.changedFiles.length > 0">
{{ $t('frosh-tools.tabs.extensionFiles.changedFiles') }}
</dt>
<dd
v-for="file in extensionResult.changedFiles"
>
<dd v-for="file in extensionResult.changedFiles">
{{ file }}
</dd>
<dt
v-if="extensionResult.missingFiles.length > 0"
>
<dt v-if="extensionResult.missingFiles.length > 0">
{{ $t('frosh-tools.tabs.extensionFiles.missingFiles') }}
</dt>
<dd
v-for="file in extensionResult.missingFiles"
>
<dd v-for="file in extensionResult.missingFiles">
{{ file }}
</dd>
</sw-description-list>
</div>
</sw-card>
</sw-card-view>
</sw-card-view>