Skip to content

Commit

Permalink
Merge pull request #90 from TheDMSGroup/ENG-317-indexing
Browse files Browse the repository at this point in the history
[ENG-317] Various event search improvements.
  • Loading branch information
heathdutton authored Jul 2, 2018
2 parents 74bdb03 + ba947b2 commit 892a0aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 4 additions & 5 deletions Entity/EventRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
8 changes: 0 additions & 8 deletions Views/Timeline/index.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ class="btn btn-default btn-search btn-nospin">
<i class="the-icon fa fa-search fa-fw"></i>
</button>
</div>

<div class="input-group-btn" style="width:auto;font-size:1em;padding-left:4px;"
">
<input id="include-logs" type="checkbox"
title="Apply search term to verbose logs - may cause unexpected results." name="logs"
class="bdr-w-0">
<label style="padding:4px;" for="include-logs">Apply search term to verbose logs.</label>
</div>
</div>
</div>

Expand Down

0 comments on commit 892a0aa

Please sign in to comment.