Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable26] probeCircles on search #1335

Merged
merged 1 commit into from
Jul 12, 2023
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
13 changes: 1 addition & 12 deletions lib/Db/CoreQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,7 @@ public function filterCircleDetails(Circle $circle): void {
}
$orX->add($andX);
}
if ($circle->getDescription() !== '') {
$orDescription = $expr->orX();
foreach (explode(' ', $circle->getDescription()) as $word) {
$orDescription->add(
$expr->iLike(
$this->getDefaultSelectAlias() . '.' . 'description',
$this->createNamedParameter('%' . $word . '%')
)
);
}
$orX->add($orDescription);
}

if ($orX->count() > 0) {
$this->andWhere($orX);
}
Expand Down
62 changes: 62 additions & 0 deletions lib/Migration/Version0028Date20230705222601.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);


/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


namespace OCA\Circles\Migration;

use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Psr\Log\LoggerInterface;

class Version0028Date20230705222601 extends SimpleMigrationStep {
public function __construct(
private LoggerInterface $logger
) {
}

public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

try {
$table = $schema->getTable('circles_circle');
if (!$table->hasIndex('dname')) {
$table->addIndex(['display_name'], 'dname');
}
} catch (SchemaException $e) {
$this->logger->warning('Could not find circles_circle', ['exception' => $e]);
}

return $schema;
}
}
5 changes: 2 additions & 3 deletions lib/Service/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function unifiedSearch(string $term, array $options): array {
$probe = $this->generateSearchProbe($term, $options);

try {
$circles = $this->circleService->getCircles($probe);
$circles = $this->circleService->probeCircles($probe);
} catch (InitiatorNotFoundException $e) {
return [];
}
Expand Down Expand Up @@ -154,8 +154,7 @@ private function generateSearchProbe(string $term, array $options): CircleProbe
->filterBackendCircles();

$circle = new Circle();
$circle->setDisplayName($term)
->setDescription($term);
$circle->setDisplayName($term);

$probe->setFilterCircle($circle);

Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OC" />
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
</errorLevel>
</UndefinedClass>
<UndefinedDocblockClass>
Expand Down
Loading