Skip to content

Commit a8f9617

Browse files
shyimschneider-felix
authored andcommitted
fix: consider all pools as active namespaces
1 parent cfa803c commit a8f9617

File tree

6 files changed

+46
-26
lines changed

6 files changed

+46
-26
lines changed

src/Command/RedisNamespaceCleanupCommand.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ protected function configure(): void
3131
protected function execute(InputInterface $input, OutputInterface $output): int
3232
{
3333
$io = new SymfonyStyle($input, $output);
34-
$cacheAdapter = $this->cacheRegistry->get('cache.object');
34+
$activeNamespaces = $this->cacheRegistry->getActiveNamespaces();
35+
3536
$dryRun = $input->getOption('dry-run');
3637

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

4241
return Command::FAILURE;
4342
}
4443

45-
$activeNamespace = $cacheAdapter->getNamespace();
44+
$cacheApp = $this->cacheRegistry->get('cache.app');
45+
$redis = $cacheApp->getRedisOrFail();
46+
4647
$io->title('Redis Namespace Cleanup');
47-
$io->writeln(\sprintf('Active namespace: <info>%s</info>', $activeNamespace));
48+
$io->writeln(\sprintf('Active namespaces: <info>%s</info>', implode(', ', $activeNamespaces)));
4849

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

7576
// Track keys that are not in the active namespace
76-
if ($namespace !== $activeNamespace) {
77+
if (!\in_array($namespace, $activeNamespaces, true)) {
7778
$keysToDelete[] = $key;
7879
}
7980
}
@@ -82,10 +83,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8283
// Display namespace summary
8384
$tableData = [];
8485
foreach ($namespaces as $namespace => $count) {
85-
$status = $namespace === $activeNamespace ? 'KEEP' : 'DELETE';
86+
$status = \in_array($namespace, $activeNamespaces, true) ? 'KEEP' : 'DELETE';
8687
$tableData[] = [$namespace, $count, $status];
8788
}
8889

90+
usort($tableData, function ($a, $b) {
91+
return $b[0] <=> $a[0];
92+
});
93+
8994
$io->section('Namespace Summary');
9095
$io->table(
9196
['Namespace', 'Key Count', 'Action'],

src/Command/RedisNamespaceListCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3535
return Command::FAILURE;
3636
}
3737

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

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

72+
usort($tableData, function ($a, $b) {
73+
return $b[0] <=> $a[0];
74+
});
75+
7276
$io->table(
7377
['Prefix', 'Count', 'Percentage', 'Active'],
7478
$tableData

src/Components/CacheRegistry.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,21 @@ public function has(string $name): bool
3737
{
3838
return isset($this->adapters[$name]);
3939
}
40+
41+
/**
42+
* @return array<string>
43+
*/
44+
public function getActiveNamespaces(): array
45+
{
46+
$list = [];
47+
48+
foreach ($this->adapters as $adapter) {
49+
try {
50+
$list[] = $adapter->getNamespace();
51+
} catch (\Exception) {
52+
}
53+
}
54+
55+
return array_unique($list);
56+
}
4057
}

src/Resources/app/administration/src/api/frosh-tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class FroshTools extends ApiService {
187187
headers: this.getBasicHeaders(),
188188
})
189189
.then((response) => {
190-
return response
190+
return response;
191191
});
192192
}
193193

src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-files/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ Component.register('frosh-tools-tab-files', {
5858

5959
async createdComponent() {
6060
this.items = (await this.froshToolsService.getShopwareFiles()).data;
61-
this.extensionItems = (await this.froshToolsService.getExtensionFiles()).data;
61+
this.extensionItems = (
62+
await this.froshToolsService.getExtensionFiles()
63+
).data;
6264
this.isLoading = false;
6365
},
6466

src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-files/template.twig

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,19 @@
153153
<dd v-for="file in extensionResult.newFiles">
154154
{{ file }}
155155
</dd>
156-
<dt
157-
v-if="extensionResult.changedFiles.length > 0"
158-
>
156+
<dt v-if="extensionResult.changedFiles.length > 0">
159157
{{ $t('frosh-tools.tabs.extensionFiles.changedFiles') }}
160158
</dt>
161-
<dd
162-
v-for="file in extensionResult.changedFiles"
163-
>
159+
<dd v-for="file in extensionResult.changedFiles">
164160
{{ file }}
165161
</dd>
166-
<dt
167-
v-if="extensionResult.missingFiles.length > 0"
168-
>
162+
<dt v-if="extensionResult.missingFiles.length > 0">
169163
{{ $t('frosh-tools.tabs.extensionFiles.missingFiles') }}
170164
</dt>
171-
<dd
172-
v-for="file in extensionResult.missingFiles"
173-
>
165+
<dd v-for="file in extensionResult.missingFiles">
174166
{{ file }}
175167
</dd>
176168
</sw-description-list>
177169
</div>
178170
</sw-card>
179-
</sw-card-view>
171+
</sw-card-view>

0 commit comments

Comments
 (0)