Skip to content

Commit

Permalink
Message: Filter messages with MatchSearchFilter - refs BT#22036
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Nov 14, 2024
1 parent afcc0fe commit b938450
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/CoreBundle/Entity/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use Chamilo\CoreBundle\Entity\Listener\MessageListener;
use Chamilo\CoreBundle\Filter\PartialSearchOrFilter;
use Chamilo\CoreBundle\Filter\MatchSearchFilter;
use Chamilo\CoreBundle\Repository\MessageRepository;
use Chamilo\CoreBundle\State\MessageByGroupStateProvider;
use Chamilo\CoreBundle\State\MessageProcessor;
Expand All @@ -35,6 +35,7 @@
#[ORM\Index(columns: ['user_sender_id'], name: 'idx_message_user_sender')]
#[ORM\Index(columns: ['group_id'], name: 'idx_message_group')]
#[ORM\Index(columns: ['msg_type'], name: 'idx_message_type')]
#[Orm\Index(columns: ['title', 'content'], name: 'idx_message_search', flags: ['fulltext'])]
#[ORM\Entity(repositoryClass: MessageRepository::class)]
#[ORM\EntityListeners([MessageListener::class])]
#[ApiResource(
Expand Down Expand Up @@ -78,7 +79,7 @@
BooleanFilter::class,
properties: ['receivers.read']
)]
#[ApiFilter(PartialSearchOrFilter::class, properties: ['title', 'content'])]
#[ApiFilter(MatchSearchFilter::class, properties: ['title', 'content'])]
#[ApiFilter(ExistsFilter::class, properties: ['receivers.deletedAt'])]
class Message
{
Expand Down
31 changes: 31 additions & 0 deletions src/CoreBundle/Migrations/Schema/V200/Version20241113110000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/* For licensing terms, see /license.txt */

declare(strict_types=1);

namespace Chamilo\CoreBundle\Migrations\Schema\V200;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;

final class Version20241113110000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Add fulltext index to messages';
}

/**
* @inheritDoc
*/
public function up(Schema $schema): void
{
$this->addSql('CREATE FULLTEXT INDEX idx_message_search ON message (title, content)');
}

public function down(Schema $schema): void
{
$this->addSql('DROP INDEX idx_message_search ON message');
}
}

0 comments on commit b938450

Please sign in to comment.