Message: Filter messages with MatchSearchFilter - refs BT#22036

pull/5928/head
Angel Fernando Quiroz Campos 10 months ago
parent fd017c4216
commit e02ecf0843
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 5
      src/CoreBundle/Entity/Message.php
  2. 31
      src/CoreBundle/Migrations/Schema/V200/Version20241113110000.php

@ -18,7 +18,7 @@ use ApiPlatform\Metadata\GetCollection;
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;
@ -35,6 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert;
#[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(
@ -78,7 +79,7 @@ use Symfony\Component\Validator\Constraints as Assert;
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
{

@ -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');
}
}
Loading…
Cancel
Save