diff --git a/Web/Models/Repositories/BugtrackerReports.php b/Web/Models/Repositories/BugtrackerReports.php index 46be8df0..d5465a38 100644 --- a/Web/Models/Repositories/BugtrackerReports.php +++ b/Web/Models/Repositories/BugtrackerReports.php @@ -38,9 +38,11 @@ class BugtrackerReports yield new BugReport($report); } - function getReportsCount(): int + function getReportsCount(int $product_id): int { - return sizeof($this->reports->where(["deleted" => NULL])); + return $product_id + ? sizeof($this->reports->where(["deleted" => NULL, "product_id" => $product_id])) + : sizeof($this->reports->where(["deleted" => NULL])); } function getByReporter(int $reporter_id, int $page = 1): \Traversable diff --git a/Web/Presenters/BugtrackerPresenter.php b/Web/Presenters/BugtrackerPresenter.php index c3435ea5..3f7501ba 100644 --- a/Web/Presenters/BugtrackerPresenter.php +++ b/Web/Presenters/BugtrackerPresenter.php @@ -39,8 +39,10 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->template->count = $this->reports->getCountByReporter((int) $this->queryParam("id")); } else { $this->template->page = (int) ($this->queryParam("p") ?? 1); - $this->template->count = $this->reports->getReportsCount(0); - $this->template->iterator = $this->reports->getAllReports($this->template->page); + $this->template->count = $this->reports->getReportsCount((int) $this->queryParam("product")); + $this->template->iterator = $this->queryParam("product") + ? $this->reports->getReports((int) $this->queryParam("product"), $this->template->page) + : $this->reports->getAllReports($this->template->page); } $this->template->canAdminBugTracker = $this->user->identity->getChandlerUser()->can("admin")->model('openvk\Web\Models\Repositories\BugtrackerReports')->whichBelongsTo(NULL);