CR
This commit is contained in:
Fabio Guachalla
2020-06-08 17:25:28 -04:00
parent 1e508a2450
commit 557f3634e5
5 changed files with 14 additions and 13 deletions

View File

@@ -207,9 +207,9 @@ class PMFTotalCalculationTest extends TestCase
] ]
]; ];
$expectedArray = [ $expectedArray = [
"0" => 20, "1" => 20,
"1" => 70, "2" => 70,
"2" => 10, "3" => 10,
]; ];
$this->assertEquals($expectedArray, PMFTotalCalculation($grid, 'field2', 'percentile')); $this->assertEquals($expectedArray, PMFTotalCalculation($grid, 'field2', 'percentile'));
} }

View File

@@ -451,7 +451,7 @@ function evaluateFunction($aGrid, $sExpresion)
* @method * @method
* *
* Executes operations in the grid fields, such as sum, average, median, minimum, maximun, * 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 * @name PMFTotalCalculation
* @label PMFTotalCalculation Function * @label PMFTotalCalculation Function
@@ -459,7 +459,7 @@ function evaluateFunction($aGrid, $sExpresion)
* @param array | $grid | Grid | The input grid. * @param array | $grid | Grid | The input grid.
* @param string (32) | $field | Name of field | The name of the field. * @param string (32) | $field | Name of field | The name of the field.
* @param string (32) | $function | Operation. * @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) function PMFTotalCalculation($grid, $field, $function)
@@ -540,10 +540,10 @@ function PMFTotalCalculation($grid, $field, $function)
$arrayAux = []; $arrayAux = [];
for ($i = 1; $i <= $totalRows; $i += 1) { for ($i = 1; $i <= $totalRows; $i += 1) {
$sum += $grid[$i][$field]; $sum += $grid[$i][$field];
$arrayAux[] = $grid[$i][$field]; $arrayAux[$i] = $grid[$i][$field];
} }
for ($i = 0; $i < count($arrayAux); $i += 1) { for ($i = 1; $i <= count($arrayAux); $i += 1) {
$result[] = round(($arrayAux[$i] * 100) / $sum, $floatPointNumber); $result[$i] = round(($arrayAux[$i] * 100) / $sum, $floatPointNumber);
} }
break; break;
case "count": case "count":

View File

@@ -375,8 +375,7 @@ class Variable
* @param string $search * @param string $search
* @param string $prefix * @param string $prefix
* *
* @return array, return an array with data of a DynaForm * @return array, return an array with varaibles filter by type
* @throws Exception
*/ */
public function getVariablesByType($processUid, $typeVarId = 0, $start = null, $limit = null, $search = null, $prefix = null) public function getVariablesByType($processUid, $typeVarId = 0, $start = null, $limit = null, $search = null, $prefix = null)
{ {

View File

@@ -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 \Illuminate\Database\Eloquent\Builder $query
* @param int $typeId * @param int $typeId
@@ -136,7 +136,7 @@ class ProcessVariables extends Model
if (!empty($search)) { if (!empty($search)) {
$query->where('VAR_NAME', 'LIKE', "${search}%"); $query->where('VAR_NAME', 'LIKE', "${search}%");
} }
// orde by varNane // order by varNane
$query->orderBy('VAR_NAME', 'ASC'); $query->orderBy('VAR_NAME', 'ASC');
// Check if we need to add a pagination // Check if we need to add a pagination
if(!is_null($start) && !is_null($limit)) { if(!is_null($start) && !is_null($limit)) {

View File

@@ -3,9 +3,9 @@ namespace ProcessMaker\Services\Api\Project;
use Exception; use Exception;
use G; use G;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Variable as BmVariable; use ProcessMaker\BusinessModel\Variable as BmVariable;
use ProcessMaker\Services\Api; use ProcessMaker\Services\Api;
use Luracast\Restler\RestException;
/** /**
* Project\Variable Api Controller * Project\Variable Api Controller
@@ -33,6 +33,8 @@ class Variable extends Api
} }
/** /**
* Get variables by type
*
* @url GET /:prj_uid/process-variables/:typeVariable/paged * @url GET /:prj_uid/process-variables/:typeVariable/paged
* *
* @param string $prj_uid {@min 32}{@max 32} * @param string $prj_uid {@min 32}{@max 32}