Skip to content

Commit

Permalink
Merge pull request #708 from bozana/10082
Browse files Browse the repository at this point in the history
pkp/pkp-lib#10082 Fix getTotalGalleyViews()
  • Loading branch information
bozana authored Jun 19, 2024
2 parents d78592a + bb80701 commit 3eaee33
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 3eaee33

Please sign in to comment.