From f41df39b0f75f502470065e344d91375158f54f1 Mon Sep 17 00:00:00 2001 From: n1rwana <93197434+n1rwana@users.noreply.github.com> Date: Sun, 21 Aug 2022 23:48:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BF=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82=D0=B0=D0=BC?= =?UTF-8?q?=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5=20=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D1=91=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/Models/Repositories/BugtrackerReports.php | 6 ++++-- Web/Presenters/BugtrackerPresenter.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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);