diff --git a/php/Services/BrainService.php b/php/Services/BrainService.php index c533407..2c6940b 100644 --- a/php/Services/BrainService.php +++ b/php/Services/BrainService.php @@ -217,6 +217,10 @@ class BrainService $must[] = ['key' => 'workspace_id', 'match' => ['value' => $criteria['workspace_id']]]; } + if (isset($criteria['org'])) { + $must[] = ['key' => 'org', 'match' => ['value' => $criteria['org']]]; + } + if (isset($criteria['project'])) { $must[] = ['key' => 'project', 'match' => ['value' => $criteria['project']]]; } diff --git a/php/tests/Feature/BrainServiceTest.php b/php/tests/Feature/BrainServiceTest.php new file mode 100644 index 0000000..68d9a83 --- /dev/null +++ b/php/tests/Feature/BrainServiceTest.php @@ -0,0 +1,58 @@ +buildQdrantFilter([ + 'org' => 'core', + ]); + + $this->assertSame([ + 'must' => [ + ['key' => 'org', 'match' => ['value' => 'core']], + ], + ], $filter); + } + + public function test_BrainService_buildQdrantFilter_Bad_CombinesOrgAndProject(): void + { + $filter = (new BrainService)->buildQdrantFilter([ + 'org' => 'core', + 'project' => 'agent', + ]); + + $this->assertSame([ + 'must' => [ + ['key' => 'org', 'match' => ['value' => 'core']], + ['key' => 'project', 'match' => ['value' => 'agent']], + ], + ], $filter); + } + + public function test_BrainService_buildQdrantFilter_Ugly_CombinesWorkspaceOrgAndProject(): void + { + $filter = (new BrainService)->buildQdrantFilter([ + 'workspace_id' => 42, + 'org' => 'core', + 'project' => 'agent', + ]); + + $this->assertSame([ + 'must' => [ + ['key' => 'workspace_id', 'match' => ['value' => 42]], + ['key' => 'org', 'match' => ['value' => 'core']], + ['key' => 'project', 'match' => ['value' => 'agent']], + ], + ], $filter); + } +}