diff --git a/Web/Models/Repositories/BugtrackerReports.php b/Web/Models/Repositories/BugtrackerReports.php index 0eae1a4d..22170d5d 100644 --- a/Web/Models/Repositories/BugtrackerReports.php +++ b/Web/Models/Repositories/BugtrackerReports.php @@ -32,17 +32,23 @@ class BugtrackerReports yield new BugReport($report); } - function getReports(int $product_id = 0, int $page = 1): \Traversable + function getReports(int $product_id = 0, int $priority = 0, int $page = 1): \Traversable { - foreach($this->reports->where(["deleted" => NULL, "product_id" => $product_id])->order("created DESC")->page($page, 5) as $report) + $filter = ["deleted" => NULL]; + $product_id && $filter["product_id"] = $product_id; + $priority && $filter["priority"] = $priority; + + foreach($this->reports->where($filter)->order("created DESC")->page($page, 5) as $report) yield new BugReport($report); } - function getReportsCount(int $product_id): int + function getReportsCount(int $product_id = 0, int $priority = 0): int { - return $product_id - ? sizeof($this->reports->where(["deleted" => NULL, "product_id" => $product_id])) - : sizeof($this->reports->where(["deleted" => NULL])); + $filter = ["deleted" => NULL]; + $product_id && $filter["product_id"] = $product_id; + $priority && $filter["priority"] = $priority; + + return sizeof($this->reports->where($filter)); } function getByReporter(int $reporter_id, int $page = 1): \Traversable diff --git a/Web/Presenters/BugtrackerPresenter.php b/Web/Presenters/BugtrackerPresenter.php index 627a9095..72b7d4b2 100644 --- a/Web/Presenters/BugtrackerPresenter.php +++ b/Web/Presenters/BugtrackerPresenter.php @@ -48,9 +48,9 @@ final class BugtrackerPresenter extends OpenVKPresenter break; default: - $this->template->count = $this->reports->getReportsCount((int) $this->queryParam("product")); + $this->template->count = $this->reports->getReportsCount((int) $this->queryParam("product"), (int) $this->queryParam("priority")); $this->template->iterator = $this->queryParam("product") - ? $this->reports->getReports((int) $this->queryParam("product"), $this->template->page) + ? $this->reports->getReports((int) $this->queryParam("product"), (int) $this->queryParam("priority"), $this->template->page) : $this->reports->getAllReports($this->template->page); break; }