Skip to content

Commit

Permalink
Merge pull request #2 from asmecher/fix-search
Browse files Browse the repository at this point in the history
pkp/pkp-lib#4859 Fix search query for PPS
  • Loading branch information
ajnyga authored Nov 13, 2019
2 parents 96f1aa5 + 480e934 commit cdf5603
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions classes/search/ArticleSearchDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ function getPhraseResults($journal, $phrase, $publishedFrom = null, $publishedTo
}

if (!empty($publishedFrom)) {
$sqlWhere .= ' AND ps.date_published >= ' . $this->datetimeToDB($publishedFrom);
$sqlWhere .= ' AND p.date_published >= ' . $this->datetimeToDB($publishedFrom);
}

if (!empty($publishedTo)) {
$sqlWhere .= ' AND ps.date_published <= ' . $this->datetimeToDB($publishedTo);
$sqlWhere .= ' AND p.date_published <= ' . $this->datetimeToDB($publishedTo);
}

if (!empty($journal)) {
$sqlWhere .= ' AND i.journal_id = ?';
$sqlWhere .= ' AND s.context_id = ?';
$params[] = $journal->getId();
}

Expand All @@ -71,20 +71,16 @@ function getPhraseResults($journal, $phrase, $publishedFrom = null, $publishedTo
'SELECT
o.submission_id,
MAX(s.context_id) AS journal_id,
MAX(i.date_published) AS i_pub,
MAX(ps.date_published) AS s_pub,
MAX(p.date_published) AS s_pub,
COUNT(*) AS count
FROM
submissions s,
published_submissions ps,
issues i,
submissions s
JOIN publications p ON (p.publication_id = s.current_publication_id),
submission_search_objects o NATURAL JOIN ' . $sqlFrom . '
WHERE
s.submission_id = o.submission_id AND
s.status = ' . STATUS_PUBLISHED . ' AND
ps.submission_id = s.submission_id AND
i.issue_id = ps.issue_id AND
i.published = 1 AND ' . $sqlWhere . '
' . $sqlWhere . '
GROUP BY o.submission_id
ORDER BY count DESC
LIMIT ' . $limit,
Expand Down

0 comments on commit cdf5603

Please sign in to comment.