mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
Remove caching form the MonitoringBadgeNavigationItemRenderer
Caching will be no longer necessary because we will replace the queries used to fetch the problem badges.
This commit is contained in:
parent
c0d359fbbd
commit
28790d254b
@ -11,14 +11,11 @@ use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
|||||||
use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer;
|
use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render generic dataView columns as badges in MenuItems
|
* Render generic DataView columns as badges in menu items
|
||||||
*
|
|
||||||
* Renders numeric data view column values into menu item badges, fully configurable
|
|
||||||
* and with a caching mechanism to prevent needless requests to the same data view.
|
|
||||||
*
|
*
|
||||||
* It is possible to configure the class of the rendered badge as option 'class', the
|
* It is possible to configure the class of the rendered badge as option 'class', the
|
||||||
* column to fetch using the option 'column' and the dataView from which the columns
|
* columns to fetch using the option 'columns' and the DataView from which the columns
|
||||||
* will be fetched using the option 'dataView'.
|
* will be fetched using the option 'dataview'.
|
||||||
*/
|
*/
|
||||||
class MonitoringBadgeNavigationItemRenderer extends BadgeNavigationItemRenderer
|
class MonitoringBadgeNavigationItemRenderer extends BadgeNavigationItemRenderer
|
||||||
{
|
{
|
||||||
@ -104,29 +101,6 @@ class MonitoringBadgeNavigationItemRenderer extends BadgeNavigationItemRenderer
|
|||||||
return $this->columns;
|
return $this->columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
// clear the outdated summary cache, since new columns are being added. Optimally all menu item are constructed
|
|
||||||
// before any rendering is going on to avoid trashing too man old requests
|
|
||||||
if (isset(self::$summaries[$this->dataView])) {
|
|
||||||
unset(self::$summaries[$this->dataView]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the new columns to this view
|
|
||||||
if (! isset(self::$dataViews[$this->dataView])) {
|
|
||||||
self::$dataViews[$this->dataView] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->columns as $column => $title) {
|
|
||||||
if (! array_search($column, self::$dataViews[$this->dataView])) {
|
|
||||||
self::$dataViews[$this->dataView][] = $column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a restriction on the given data view
|
* Apply a restriction on the given data view
|
||||||
*
|
*
|
||||||
@ -146,24 +120,18 @@ class MonitoringBadgeNavigationItemRenderer extends BadgeNavigationItemRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the dataview from the database or access cache
|
* Fetch the dataview from the database
|
||||||
*
|
|
||||||
* @param string $view
|
|
||||||
*
|
*
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
protected static function summary($view)
|
protected function fetchDataView()
|
||||||
{
|
{
|
||||||
if (! isset(self::$summaries[$view])) {
|
$summary = MonitoringBackend::instance()->select()->from(
|
||||||
$summary = MonitoringBackend::instance()->select()->from(
|
$this->getDataView(),
|
||||||
$view,
|
array_keys($this->getColumns())
|
||||||
self::$dataViews[$view]
|
);
|
||||||
);
|
static::applyRestriction('monitoring/filter/objects', $summary);
|
||||||
static::applyRestriction('monitoring/filter/objects', $summary);
|
return $summary->fetchRow();
|
||||||
self::$summaries[$view] = $summary->fetchRow();
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$summaries[$view];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,7 +141,7 @@ class MonitoringBadgeNavigationItemRenderer extends BadgeNavigationItemRenderer
|
|||||||
{
|
{
|
||||||
if ($this->count === null) {
|
if ($this->count === null) {
|
||||||
try {
|
try {
|
||||||
$summary = self::summary($this->getDataView());
|
$summary = $this->fetchDataView();
|
||||||
} catch (Exception $_) {
|
} catch (Exception $_) {
|
||||||
$this->count = 0;
|
$this->count = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user