diff --git a/Entity/Event.php b/Entity/Event.php index 4248e495..9804f017 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -77,8 +77,10 @@ public static function loadMetadata(ORM\ClassMetadata $metadata) $builder->setTable('contactclient_events') ->setCustomRepositoryClass('MauticPlugin\MauticContactClientBundle\Entity\EventRepository') - // ->addIndex(['type', 'contactclient_id', 'contact_id'], 'event_contactclient_contact') ->addIndex(['type', 'contact_id'], 'type_contact') + ->addIndex(['type', 'message'], 'type_message') + ->addIndex(['contact_id'], 'contact_id') + ->addIndex(['contactclient_id', 'date_added'], 'contactclient_id_date_added') ->addIndex(['date_added'], 'date_added'); $builder->addId(); diff --git a/Entity/EventRepository.php b/Entity/EventRepository.php index 3a0a7529..f8f7c45d 100644 --- a/Entity/EventRepository.php +++ b/Entity/EventRepository.php @@ -78,19 +78,18 @@ public function getEventsForTimeline($contactClientId, $contactId = null, array } if (isset($options['search']) && $options['search']) { - if (isset($options['logs']) && $options['logs']) { + if (is_numeric($options['search']) && !$contactId) { $expr = $query->expr()->orX( - $query->expr()->like('c.type', $query->expr()->literal('%'.$options['search'].'%')), - $query->expr()->like('c.message', $query->expr()->literal('%'.$options['search'].'%')), - $query->expr()->like('c.logs', $query->expr()->literal('%'.$options['search'].'%')) + $query->expr()->eq('c.contact_id', (int) $options['search']) ); } else { $expr = $query->expr()->orX( - $query->expr()->like('c.type', $query->expr()->literal('%'.$options['search'].'%')), + $query->expr()->eq('c.type', ':search'), $query->expr()->like('c.message', $query->expr()->literal('%'.$options['search'].'%')) ); } $query->andWhere($expr); + $query->setParameter('search', $options['search']); } if (!empty($options['fromDate']) && !empty($options['toDate'])) { diff --git a/Views/Timeline/index.html.php b/Views/Timeline/index.html.php index 1fe0940a..68fd5525 100644 --- a/Views/Timeline/index.html.php +++ b/Views/Timeline/index.html.php @@ -38,14 +38,6 @@ class="btn btn-default btn-search btn-nospin"> - -
- - -