diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-02-26 05:23:28 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-03-05 05:31:18 +0300 |
commit | 287aad82841f0f0e85406192b2f1f865bc0be67d (patch) | |
tree | d9c035a484c3f2727d7fa1cdf14ccd213c308508 /core/Plugin/Metric.php | |
parent | a1cb3695319b321f92bb0a4fd31892a9bc1bdf38 (diff) |
Faster flattening for many reports
Diffstat (limited to 'core/Plugin/Metric.php')
-rw-r--r-- | core/Plugin/Metric.php | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/core/Plugin/Metric.php b/core/Plugin/Metric.php index e475eb837f..6d69350d92 100644 --- a/core/Plugin/Metric.php +++ b/core/Plugin/Metric.php @@ -108,26 +108,41 @@ abstract class Metric */ public static function getMetric($row, $columnName, $mappingNameToId = null) { - if (empty($mappingNameToId)) { - $mappingNameToId = Metrics::getMappingFromNameToId(); - } - if ($row instanceof Row) { $value = $row->getColumn($columnName); - if ($value === false - && isset($mappingNameToId[$columnName]) - ) { - $value = $row->getColumn($mappingNameToId[$columnName]); + + if ($value === false) { + + if (empty($mappingNameToId)) { + $mappingNameToId = Metrics::getMappingFromNameToId(); + } + + if (isset($mappingNameToId[$columnName])) { + return $row->getColumn($mappingNameToId[$columnName]); + } } + + return $value; + } else { - $value = @$row[$columnName]; - if ($value === null - && isset($mappingNameToId[$columnName]) - ) { - $columnName = $mappingNameToId[$columnName]; - $value = @$row[$columnName]; + $value = null; + if (array_key_exists($columnName, $row)) { + $value = $row[$columnName]; + } else { + + if (empty($mappingNameToId)) { + $mappingNameToId = Metrics::getMappingFromNameToId(); + } + + if (isset($mappingNameToId[$columnName])) { + $columnName = $mappingNameToId[$columnName]; + + if (array_key_exists($columnName, $row)) { + return $row[$columnName]; + } + } } - return $value; + } return $value; |