diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFTotalCalculationTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFTotalCalculationTest.php index 1624a21b2..3b28b59ff 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFTotalCalculationTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFTotalCalculationTest.php @@ -207,9 +207,9 @@ class PMFTotalCalculationTest extends TestCase ] ]; $expectedArray = [ - "0" => 20, - "1" => 70, - "2" => 10, + "1" => 20, + "2" => 70, + "3" => 10, ]; $this->assertEquals($expectedArray, PMFTotalCalculation($grid, 'field2', 'percentile')); } diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 37d40f81b..262fa78f1 100644 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -451,7 +451,7 @@ function evaluateFunction($aGrid, $sExpresion) * @method * * Executes operations in the grid fields, such as sum, average, median, minimum, maximun, - * stantard derivation, variance, percentile, count, count distinct + * stantard deviation, variance, percentile, count, count distinct * * @name PMFTotalCalculation * @label PMFTotalCalculation Function @@ -459,7 +459,7 @@ function evaluateFunction($aGrid, $sExpresion) * @param array | $grid | Grid | The input grid. * @param string (32) | $field | Name of field | The name of the field. * @param string (32) | $function | Operation. - * @return object|array | $result | Result | Result according of the function + * @return int|float|array | $result | Result | Result according of the function * */ function PMFTotalCalculation($grid, $field, $function) @@ -540,10 +540,10 @@ function PMFTotalCalculation($grid, $field, $function) $arrayAux = []; for ($i = 1; $i <= $totalRows; $i += 1) { $sum += $grid[$i][$field]; - $arrayAux[] = $grid[$i][$field]; + $arrayAux[$i] = $grid[$i][$field]; } - for ($i = 0; $i < count($arrayAux); $i += 1) { - $result[] = round(($arrayAux[$i] * 100) / $sum, $floatPointNumber); + for ($i = 1; $i <= count($arrayAux); $i += 1) { + $result[$i] = round(($arrayAux[$i] * 100) / $sum, $floatPointNumber); } break; case "count": diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php index 1d7f76b78..f51538af3 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php @@ -375,8 +375,7 @@ class Variable * @param string $search * @param string $prefix * - * @return array, return an array with data of a DynaForm - * @throws Exception + * @return array, return an array with varaibles filter by type */ public function getVariablesByType($processUid, $typeVarId = 0, $start = null, $limit = null, $search = null, $prefix = null) { diff --git a/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php b/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php index cdb487ddd..8647380e7 100644 --- a/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php +++ b/workflow/engine/src/ProcessMaker/Model/ProcessVariables.php @@ -76,7 +76,7 @@ class ProcessVariables extends Model } /** - * Scope a query to filter an specific type for variable + * Scope a query to filter a specific type for variable * * @param \Illuminate\Database\Eloquent\Builder $query * @param int $typeId @@ -136,7 +136,7 @@ class ProcessVariables extends Model if (!empty($search)) { $query->where('VAR_NAME', 'LIKE', "${search}%"); } - // orde by varNane + // order by varNane $query->orderBy('VAR_NAME', 'ASC'); // Check if we need to add a pagination if(!is_null($start) && !is_null($limit)) { diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/Variable.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/Variable.php index 46bbd585b..af3772de1 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project/Variable.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/Variable.php @@ -3,9 +3,9 @@ namespace ProcessMaker\Services\Api\Project; use Exception; use G; +use Luracast\Restler\RestException; use ProcessMaker\BusinessModel\Variable as BmVariable; use ProcessMaker\Services\Api; -use Luracast\Restler\RestException; /** * Project\Variable Api Controller @@ -33,6 +33,8 @@ class Variable extends Api } /** + * Get variables by type + * * @url GET /:prj_uid/process-variables/:typeVariable/paged * * @param string $prj_uid {@min 32}{@max 32}