Skip to content

Commit d97d181

Browse files
committed
Review fixes
1 parent 31f0cb1 commit d97d181

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

bin/tasks/load.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Swoole\Database\PDOConfig;
66
use Swoole\Database\PDOPool;
7-
use Swoole\Runtime;
87
use Utopia\Cache\Adapter\None as NoCache;
98
use Utopia\Cache\Cache;
109
use Utopia\CLI\Console;
@@ -24,8 +23,8 @@
2423

2524
// Global pools for faster document generation
2625
$namesPool = ['Alice', 'Bob', 'Carol', 'Dave', 'Eve', 'Frank', 'Grace', 'Heidi', 'Ivan', 'Judy', 'Mallory', 'Niaj', 'Olivia', 'Peggy', 'Quentin', 'Rupert', 'Sybil', 'Trent', 'Uma', 'Victor'];
27-
$genresPool = ['fashion','food','travel','music','lifestyle','fitness','diy','sports','finance'];
28-
$tagsPool = ['short','quick','easy','medium','hard'];
26+
$genresPool = ['fashion', 'food', 'travel', 'music', 'lifestyle', 'fitness', 'diy', 'sports', 'finance'];
27+
$tagsPool = ['short', 'quick', 'easy', 'medium', 'hard'];
2928

3029
/**
3130
* @Example
@@ -69,16 +68,14 @@
6968
'attrs' => MySQL::getPDOAttributes(),
7069
],
7170
'postgres' => [
72-
'postgres' => [
73-
'host' => 'postgres',
74-
'port' => 5432,
75-
'user' => 'postgres',
76-
'pass' => 'password',
77-
'dsn' => static fn (string $host, int $port) => "pgsql:host={$host};port={$port}",
78-
'driver' => 'pgsql',
79-
'adapter' => Postgres::class,
80-
'attrs' => Postgres::getPDOAttributes(),
81-
],
71+
'host' => 'postgres',
72+
'port' => 5432,
73+
'user' => 'postgres',
74+
'pass' => 'password',
75+
'dsn' => static fn (string $host, int $port) => "pgsql:host={$host};port={$port}",
76+
'driver' => 'pgsql',
77+
'adapter' => Postgres::class,
78+
'attrs' => Postgres::getPDOAttributes(),
8279
],
8380
];
8481

@@ -175,7 +172,7 @@ function createDocuments(Database $database): void
175172
$bytes = \random_bytes(intdiv($length + 1, 2));
176173
$text = \substr(\bin2hex($bytes), 0, $length);
177174
$tagCount = \mt_rand(1, count($tagsPool));
178-
$tagKeys = (array) \array_rand($tagsPool, $tagCount);
175+
$tagKeys = (array)\array_rand($tagsPool, $tagCount);
179176
$tags = \array_map(fn ($k) => $tagsPool[$k], $tagKeys);
180177

181178
$documents[] = new Document([
@@ -186,12 +183,12 @@ function createDocuments(Database $database): void
186183
...array_map(fn () => Permission::update(Role::user(mt_rand(0, 999999999))), range(1, 3)),
187184
...array_map(fn () => Permission::delete(Role::user(mt_rand(0, 999999999))), range(1, 3)),
188185
],
189-
'author' => $namesPool[\array_rand($namesPool)],
186+
'author' => $namesPool[\array_rand($namesPool)],
190187
'created' => DateTime::now(),
191-
'text' => $text,
192-
'genre' => $genresPool[\array_rand($genresPool)],
193-
'views' => \mt_rand(0, 999999),
194-
'tags' => $tags,
188+
'text' => $text,
189+
'genre' => $genresPool[\array_rand($genresPool)],
190+
'views' => \mt_rand(0, 999999),
191+
'tags' => $tags,
195192
]);
196193
}
197194
$time = \microtime(true) - $start;

src/Database/Database.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7873,7 +7873,10 @@ private function convertRelationshipFiltersToSubqueries(
78737873
$indicesToRemove = [];
78747874

78757875
// Group queries by relationship key
7876-
foreach (Query::groupByType($queries)['filters'] as $index => $query) {
7876+
foreach ($queries as $index => $query) {
7877+
if ($query->getMethod() === Query::TYPE_SELECT) {
7878+
continue;
7879+
}
78777880
$method = $query->getMethod();
78787881
$attribute = $query->getAttribute();
78797882

@@ -8034,8 +8037,8 @@ private function convertRelationshipFiltersToSubqueries(
80348037
}
80358038

80368039
// Remove all original relationship queries for this group
8037-
foreach ($group['indices'] as $index) {
8038-
$indicesToRemove[] = $index;
8040+
foreach ($group['indices'] as $originalIndex) {
8041+
$indicesToRemove[] = $originalIndex;
80398042
}
80408043
} catch (\Exception $e) {
80418044
return null;

0 commit comments

Comments
 (0)