Explorar el Código

Poprawka pasku postępu

Mariusz Muszyński hace 7 años
padre
commit
3919979a3e
Se han modificado 1 ficheros con 8 adiciones y 9 borrados
  1. 8 9
      tools/Bocian.php

+ 8 - 9
tools/Bocian.php

@@ -1901,16 +1901,15 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
 				if (empty($json['summary']['count'])) return 0;
 				if (empty($json['summary']['step'])) return 0;
 				if (empty($json['details'])) return 0;
-				if ('relations' === $json['summary']['step']
-					|| 'reports' === $json['summary']['step']
-				) {
-					$listDetailsProgress = array_map(function ($detail) {
-						return floatval($detail['progress']);
-					}, $json['details']);
-					return (array_sum($listDetailsProgress) + V::get('created', 0, $json['summary'], 'int')) / ($json['summary']['count'] * 2);
-				}
 
-				return 0;
+				$listDetailsProgress = array_map(function ($detail) {
+					return floatval($detail['progress']);
+				}, $json['details']);
+
+				$relationsProgress = $json['summary']['count'] > 0 ? (array_sum($listDetailsProgress) / $json['summary']['count']) : 0;
+				$reportsCount = V::get('reportsCount', 0, $json['summary'], 'int');
+				$reportsProgress = $reportsCount > 0 ? (V::get('reportsCreated', 0, $json['summary'], 'int') / $reportsCount) : 0;
+				return round(0.5 * $relationsProgress + 0.5 * $reportsProgress, 2);
 			} catch (Exception $e) {
 				DBG::log($e);
 			}