Skip to content

Commit

Permalink
pkp/pkp-lib#10082 Fix getTotalGalleyViews()
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Jun 18, 2024
1 parent d78592a commit bb80701
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/submission/Submission.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,15 @@ function getTotalGalleyViews() {
$application = Application::get();
$publications = $this->getPublishedPublications();
$views = 0;
$fileIds = [];

foreach ($publications as $publication) {
foreach ((array) $publication->getData('galleys') as $galley) {
$file = $galley->getFile();
if (!$galley->getRemoteUrl() && $file) {
if (!$galley->getRemoteUrl() && $file && !in_array($file->getId(), $fileIds)) {
$views = $views + $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $file->getId());
}
$fileIds[] = $file->getId();
}
}
}
return $views;
Expand Down

0 comments on commit bb80701

Please sign in to comment.