Skip to content

Commit

Permalink
fix: search gambit does not function as intended when negated
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Sep 26, 2024
1 parent 2830be7 commit b970103
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Search/BestAnswerFilterGambit.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ protected function conditions(SearchState $search, array $matches, $negate)
$actor = $search->getActor();

$search->getQuery()->where(function ($query) use ($negate, $actor) {
$method = $negate ? 'whereNull' : 'whereNotNull';
$method = $negate ? 'whereNotIn' : 'whereIn';
$methodBestAnswerPostId = $negate ? 'whereNull' : 'whereNotNull';

$query->whereIn('id', function ($query) use ($actor) {
$query->$method('discussions.id', function ($query) use ($actor) {
$query->select('discussion_id')
->from('discussion_tag')
->whereIn('tag_id', $this->allowedQnATags($actor))
->pluck('discussion_id');
})->$method('best_answer_post_id');
})->$methodBestAnswerPostId('discussions.best_answer_post_id');
});
}

Expand Down

0 comments on commit b970103

Please sign in to comment.