Фильтр по приоритету

This commit is contained in:
n1rwana 2022-08-22 12:36:35 +03:00
parent 43b5e7d167
commit e30c434d94
2 changed files with 14 additions and 8 deletions

View file

@ -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

View file

@ -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;
}