PMCORE-3515
This commit is contained in:
@@ -96,6 +96,18 @@ $factory->state(\ProcessMaker\Model\Application::class, 'draft', function (Faker
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$factory->state(\ProcessMaker\Model\Application::class, 'paused', function (Faker $faker) {
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'APP_NUMBER' => $faker->unique()->numberBetween(1000),
|
||||||
|
'APP_STATUS_ID' => 1,
|
||||||
|
'APP_STATUS' => 'PAUSED',
|
||||||
|
'APP_INIT_USER' => $user->USR_UID,
|
||||||
|
'APP_INIT_USER_ID' => $user->USR_ID,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
$factory->state(\ProcessMaker\Model\Application::class, 'completed', function (Faker $faker) {
|
$factory->state(\ProcessMaker\Model\Application::class, 'completed', function (Faker $faker) {
|
||||||
return [
|
return [
|
||||||
'APP_NUMBER' => $faker->unique()->numberBetween(1000),
|
'APP_NUMBER' => $faker->unique()->numberBetween(1000),
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class DraftTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
Delegation::truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -881,4 +882,18 @@ class DraftTest extends TestCase
|
|||||||
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'OVERDUE');
|
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'OVERDUE');
|
||||||
$this->assertCount(1, $res);
|
$this->assertCount(1, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This tests the getCounterMetrics() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCounterMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_counter_metrics()
|
||||||
|
{
|
||||||
|
$this->createDraft();
|
||||||
|
$draft = new Draft();
|
||||||
|
$result = $draft->getCounterMetrics();
|
||||||
|
$this->assertTrue($result > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ class InboxTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
Delegation::truncate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method tearDown
|
||||||
|
*/
|
||||||
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,9 +280,14 @@ class InboxTest extends TestCase
|
|||||||
public function it_filter_by_thread_title()
|
public function it_filter_by_thread_title()
|
||||||
{
|
{
|
||||||
// Create factories related to the to_do cases
|
// Create factories related to the to_do cases
|
||||||
$cases = $this->createInbox();
|
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
$usrId = $cases->USR_ID;
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
$title = $cases->DEL_TITLE;
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_TITLE' => 'Test',
|
||||||
|
]);
|
||||||
|
$usrId = $delegation->USR_ID;
|
||||||
|
$title = 'Test';
|
||||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||||
DB::commit();
|
DB::commit();
|
||||||
// Create new Inbox object
|
// Create new Inbox object
|
||||||
@@ -830,4 +843,18 @@ class InboxTest extends TestCase
|
|||||||
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "OVERDUE");
|
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "OVERDUE");
|
||||||
$this->assertCount(1, $res);
|
$this->assertCount(1, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the getCounterMetrics method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounterMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_counter_metrics()
|
||||||
|
{
|
||||||
|
$this->createInbox();
|
||||||
|
$inbox = new Inbox();
|
||||||
|
$res = $inbox->getCounterMetrics();
|
||||||
|
$this->assertTrue($res > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class PausedTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
Delegation::truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -911,4 +912,19 @@ class PausedTest extends TestCase
|
|||||||
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
|
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
|
||||||
$this->assertCount(1, $res);
|
$this->assertCount(1, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the getCounterMetrics() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCounterMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_counter_metrics()
|
||||||
|
{
|
||||||
|
$this->createMultiplePaused(3);
|
||||||
|
$paused = new Paused();
|
||||||
|
|
||||||
|
$res = $paused->getCounterMetrics();
|
||||||
|
$this->assertTrue($res > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class UnassignedTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
Delegation::truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -951,4 +952,18 @@ class UnassignedTest extends TestCase
|
|||||||
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
|
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
|
||||||
$this->assertCount(1, $res);
|
$this->assertCount(1, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This the getCounterMetrics method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCounterMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_counter_metrics()
|
||||||
|
{
|
||||||
|
$this->createSelfServiceUserOrGroup();
|
||||||
|
$unassigned = new Unassigned;
|
||||||
|
$result = $unassigned->getCounterMetrics();
|
||||||
|
$this->assertTrue($result > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1154,7 +1154,11 @@ class DelegationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_should_search_and_filter_by_app_title()
|
public function it_should_search_and_filter_by_app_title()
|
||||||
{
|
{
|
||||||
$delegations = factory(Delegation::class, 1)->states('foreign_keys')->create();
|
$delegations = factory(Delegation::class, 1)->states('foreign_keys')->create([
|
||||||
|
'APP_NUMBER' => function () {
|
||||||
|
return factory(Application::class)->create()->APP_NUMBER;
|
||||||
|
}
|
||||||
|
]);
|
||||||
$title = $delegations->last()->DEL_TITLE;
|
$title = $delegations->last()->DEL_TITLE;
|
||||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||||
DB::commit();
|
DB::commit();
|
||||||
@@ -3596,4 +3600,83 @@ class DelegationTest extends TestCase
|
|||||||
$res = $table->joinApplication()->participatedUser($table->USR_ID)->get();
|
$res = $table->joinApplication()->participatedUser($table->USR_ID)->get();
|
||||||
$this->assertCount(1, $res);
|
$this->assertCount(1, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the scopeInboxMetrics
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeInboxMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_scope_inbox_metrics()
|
||||||
|
{
|
||||||
|
$application = factory(Application::class)->states('todo')->create();
|
||||||
|
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
]);
|
||||||
|
$res = $table->inboxMetrics()->get();
|
||||||
|
$this->assertCount(1, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the scopeDraftMetrics
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeDraftMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_scope_draft_metrics()
|
||||||
|
{
|
||||||
|
$application = factory(Application::class)->states('draft')->create();
|
||||||
|
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
]);
|
||||||
|
$res = $table->draftMetrics()->get();
|
||||||
|
$this->assertCount(1, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the scopePausedMetrics
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopePausedMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_scope_paused_metrics()
|
||||||
|
{
|
||||||
|
$application = factory(Application::class)->states('paused')->create();
|
||||||
|
$appDelay = factory(AppDelay::class)->states('paused_foreign_keys')->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
]);
|
||||||
|
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'DEL_INDEX' => $appDelay->APP_DEL_INDEX,
|
||||||
|
]);
|
||||||
|
$res = $table->pausedMetrics()->get();
|
||||||
|
$this->assertCount(1, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the scopeSelfServiceMetrics
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeSelfServiceMetrics()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_scope_self_service_metrics()
|
||||||
|
{
|
||||||
|
$application = factory(Application::class)->states('paused')->create();
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||||
|
]);
|
||||||
|
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_ID' => 0,
|
||||||
|
]);
|
||||||
|
$res = $delegation->selfServiceMetrics()->get();
|
||||||
|
$this->assertCount(1, $res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,13 @@ use Luracast\Restler\Defaults;
|
|||||||
use Luracast\Restler\HumanReadableCache;
|
use Luracast\Restler\HumanReadableCache;
|
||||||
use Maveriks\Extension\Restler;
|
use Maveriks\Extension\Restler;
|
||||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||||
|
use ProcessMaker\Model\AppDelay;
|
||||||
|
use ProcessMaker\Model\Application as ApplicationModel;
|
||||||
|
use ProcessMaker\Model\Delegation;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
|
use ProcessMaker\Model\Task;
|
||||||
|
use ProcessMaker\Model\TaskUser;
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
use ProcessMaker\Services\Api\Metrics;
|
use ProcessMaker\Services\Api\Metrics;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -31,6 +38,7 @@ class MetricsTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
Delegation::truncate();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initialize Rest API.
|
* Initialize Rest API.
|
||||||
@@ -80,6 +88,8 @@ class MetricsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_tests_get_counters_list_method_empty_lists()
|
public function it_tests_get_counters_list_method_empty_lists()
|
||||||
{
|
{
|
||||||
|
ApplicationModel::truncate();
|
||||||
|
|
||||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
$this->initializeRestApi($user->USR_UID);
|
$this->initializeRestApi($user->USR_UID);
|
||||||
|
|
||||||
@@ -154,4 +164,560 @@ class MetricsTest extends TestCase
|
|||||||
$res = $metrics->getCountersList();
|
$res = $metrics->getCountersList();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getProcessTotalCases method with inbox
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_process_total_cases_inbox()
|
||||||
|
{
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getProcessTotalCases('inbox');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getProcessTotalCases method with draft
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_process_total_cases_draft()
|
||||||
|
{
|
||||||
|
$application = factory(ApplicationModel::class)->states('draft')->create();
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'USR_UID' => $application->APP_INIT_USER,
|
||||||
|
'USR_ID' => $application->APP_INIT_USER_ID,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getProcessTotalCases('draft');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getProcessTotalCases method with paused
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_process_total_cases_paused()
|
||||||
|
{
|
||||||
|
$process1 = factory(Process::class)->create(
|
||||||
|
['PRO_CATEGORY' => '1']
|
||||||
|
);
|
||||||
|
$process2 = factory(Process::class)->create(
|
||||||
|
['PRO_CATEGORY' => '2']
|
||||||
|
);
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => '',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'TAS_TYPE' => 'NORMAL'
|
||||||
|
]);
|
||||||
|
$application1 = factory(ApplicationModel::class)->create();
|
||||||
|
$application2 = factory(ApplicationModel::class)->create();
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 0,
|
||||||
|
'DEL_INDEX' => 1
|
||||||
|
]);
|
||||||
|
$delegation1 = factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process2->PRO_ID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 0,
|
||||||
|
'DEL_INDEX' => 1
|
||||||
|
]);
|
||||||
|
$delegation2 = factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process2->PRO_ID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2
|
||||||
|
]);
|
||||||
|
factory(AppDelay::class, 5)->create([
|
||||||
|
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||||
|
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||||
|
'APP_DISABLE_ACTION_USER' => 0,
|
||||||
|
'APP_TYPE' => 'PAUSE'
|
||||||
|
]);
|
||||||
|
factory(AppDelay::class, 5)->create([
|
||||||
|
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||||
|
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||||
|
'APP_DISABLE_ACTION_USER' => 0,
|
||||||
|
'APP_TYPE' => 'PAUSE'
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getProcessTotalCases('paused');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getProcessTotalCases method with unassigned
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_process_total_cases_unassigned()
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(ApplicationModel::class)->create([
|
||||||
|
'APP_STATUS_ID' => 2
|
||||||
|
]);
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
]);
|
||||||
|
factory(TaskUser::class)->create([
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'TU_RELATION' => 1,
|
||||||
|
'TU_TYPE' => 1
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_ID' => 0,
|
||||||
|
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year"))
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getProcessTotalCases('unassigned');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getTotalCasesByRange method with inbox
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_total_cases_by_range_inbox()
|
||||||
|
{
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getTotalCasesByRange('inbox');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getTotalCasesByRange method with draft
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_total_cases_by_range_draft()
|
||||||
|
{
|
||||||
|
$application = factory(ApplicationModel::class)->states('draft')->create();
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'USR_UID' => $application->APP_INIT_USER,
|
||||||
|
'USR_ID' => $application->APP_INIT_USER_ID,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getTotalCasesByRange('draft');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getTotalCasesByRange method with paused
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_total_cases_by_range_paused()
|
||||||
|
{
|
||||||
|
$process1 = factory(Process::class)->create(
|
||||||
|
['PRO_CATEGORY' => '1']
|
||||||
|
);
|
||||||
|
$process2 = factory(Process::class)->create(
|
||||||
|
['PRO_CATEGORY' => '2']
|
||||||
|
);
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => '',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'TAS_TYPE' => 'NORMAL'
|
||||||
|
]);
|
||||||
|
$application1 = factory(ApplicationModel::class)->create();
|
||||||
|
$application2 = factory(ApplicationModel::class)->create();
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 0,
|
||||||
|
'DEL_INDEX' => 1
|
||||||
|
]);
|
||||||
|
$delegation1 = factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process2->PRO_ID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 0,
|
||||||
|
'DEL_INDEX' => 1
|
||||||
|
]);
|
||||||
|
$delegation2 = factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process2->PRO_ID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2
|
||||||
|
]);
|
||||||
|
factory(AppDelay::class, 5)->create([
|
||||||
|
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||||
|
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||||
|
'APP_DISABLE_ACTION_USER' => 0,
|
||||||
|
'APP_TYPE' => 'PAUSE'
|
||||||
|
]);
|
||||||
|
factory(AppDelay::class, 5)->create([
|
||||||
|
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||||
|
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||||
|
'APP_DISABLE_ACTION_USER' => 0,
|
||||||
|
'APP_TYPE' => 'PAUSE'
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getTotalCasesByRange('paused');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getTotalCasesByRange method with unassigned
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_total_cases_by_range_unassigned()
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(ApplicationModel::class)->create([
|
||||||
|
'APP_STATUS_ID' => 2
|
||||||
|
]);
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
]);
|
||||||
|
factory(TaskUser::class)->create([
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'TU_RELATION' => 1,
|
||||||
|
'TU_TYPE' => 1
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_ID' => 0,
|
||||||
|
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year"))
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getTotalCasesByRange('unassigned');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getCasesRiskByProcess method with inbox
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_cases_risk_by_process_inbox()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getCasesRiskByProcess('inbox', $delegation->PRO_ID, null, null, 'AT_RISK');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getCasesRiskByProcess method with draft
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_cases_risk_by_process_draft()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(ApplicationModel::class)->states('draft')->create();
|
||||||
|
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'USR_UID' => $application->APP_INIT_USER,
|
||||||
|
'USR_ID' => $application->APP_INIT_USER_ID,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getCasesRiskByProcess('draft', $delegation->PRO_ID, null, null, 'AT_RISK');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getCasesRiskByProcess method with paused
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_cases_risk_by_process_paused()
|
||||||
|
{
|
||||||
|
$process1 = factory(Process::class)->create(
|
||||||
|
['PRO_CATEGORY' => '1']
|
||||||
|
);
|
||||||
|
$process2 = factory(Process::class)->create(
|
||||||
|
['PRO_CATEGORY' => '2']
|
||||||
|
);
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => '',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'TAS_TYPE' => 'NORMAL'
|
||||||
|
]);
|
||||||
|
$application1 = factory(ApplicationModel::class)->create();
|
||||||
|
$application2 = factory(ApplicationModel::class)->create();
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 0,
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||||
|
]);
|
||||||
|
$delegation1 = factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process2->PRO_ID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 0,
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||||
|
]);
|
||||||
|
$delegation2 = factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process2->PRO_ID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||||
|
]);
|
||||||
|
factory(AppDelay::class, 5)->create([
|
||||||
|
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||||
|
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||||
|
'APP_DISABLE_ACTION_USER' => 0,
|
||||||
|
'APP_TYPE' => 'PAUSE'
|
||||||
|
]);
|
||||||
|
factory(AppDelay::class, 5)->create([
|
||||||
|
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||||
|
'PRO_UID' => $process2->PRO_UID,
|
||||||
|
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||||
|
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||||
|
'APP_DISABLE_ACTION_USER' => 0,
|
||||||
|
'APP_TYPE' => 'PAUSE'
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getCasesRiskByProcess('paused', $delegation1->PRO_ID, null, null, 'AT_RISK');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getCasesRiskByProcess method with unassigned
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_cases_risk_by_process_unassigned()
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(ApplicationModel::class)->create([
|
||||||
|
'APP_STATUS_ID' => 2
|
||||||
|
]);
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
]);
|
||||||
|
factory(TaskUser::class)->create([
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'TU_RELATION' => 1,
|
||||||
|
'TU_TYPE' => 1
|
||||||
|
]);
|
||||||
|
$delegation = factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_ID' => 0,
|
||||||
|
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year")),
|
||||||
|
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||||
|
]);
|
||||||
|
unset($RBAC);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$res = $metrics->getCasesRiskByProcess('unassigned', $delegation->PRO_ID, null, null, 'AT_RISK');
|
||||||
|
$this->assertNotEmpty($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getProcessTotalCases method with exception
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_process_total_cases_exception()
|
||||||
|
{
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$this->expectExceptionMessage("Undefined variable: list");
|
||||||
|
$metrics->getProcessTotalCases(12, 123, "asda");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getTotalCasesByRange method with exception
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_total_cases_by_range_exception()
|
||||||
|
{
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$this->expectExceptionMessage("Undefined variable: list");
|
||||||
|
$metrics->getTotalCasesByRange(12, 123, "asda");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getCasesRiskByProcess method with exception
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_tests_get_counters_list_exception()
|
||||||
|
{
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
]);
|
||||||
|
$metrics = new Metrics();
|
||||||
|
$this->expectExceptionMessage("Undefined variable: list");
|
||||||
|
$metrics->getCasesRiskByProcess(12, 123, "asda");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1552,16 +1552,16 @@ class AbstractCases implements CasesInterface
|
|||||||
$list = end($listArray);
|
$list = end($listArray);
|
||||||
switch ($list) {
|
switch ($list) {
|
||||||
case 'Inbox':
|
case 'Inbox':
|
||||||
$query->inbox($this->getUserId());
|
$query->inboxMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Draft':
|
case 'Draft':
|
||||||
$query->draft($this->getUserId());
|
$query->draftMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Paused':
|
case 'Paused':
|
||||||
$query->paused($this->getUserId());
|
$query->pausedMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Unassigned':
|
case 'Unassigned':
|
||||||
$query->selfService($this->getUserUid());
|
$query->selfServiceMetrics();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$query->joinProcess();
|
$query->joinProcess();
|
||||||
@@ -1604,16 +1604,16 @@ class AbstractCases implements CasesInterface
|
|||||||
$list = end($listArray);
|
$list = end($listArray);
|
||||||
switch ($list) {
|
switch ($list) {
|
||||||
case 'Inbox':
|
case 'Inbox':
|
||||||
$query->inbox($this->getUserId());
|
$query->inboxMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Draft':
|
case 'Draft':
|
||||||
$query->draft($this->getUserId());
|
$query->draftMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Paused':
|
case 'Paused':
|
||||||
$query->paused($this->getUserId());
|
$query->pausedMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Unassigned':
|
case 'Unassigned':
|
||||||
$query->selfService($this->getUserUid());
|
$query->selfServiceMetrics();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$query->joinProcess();
|
$query->joinProcess();
|
||||||
@@ -1657,16 +1657,16 @@ class AbstractCases implements CasesInterface
|
|||||||
$list = end($listArray);
|
$list = end($listArray);
|
||||||
switch ($list) {
|
switch ($list) {
|
||||||
case 'Inbox':
|
case 'Inbox':
|
||||||
$query->inbox($this->getUserId());
|
$query->inboxMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Draft':
|
case 'Draft':
|
||||||
$query->draft($this->getUserId());
|
$query->draftMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Paused':
|
case 'Paused':
|
||||||
$query->paused($this->getUserId());
|
$query->pausedMetrics();
|
||||||
break;
|
break;
|
||||||
case 'Unassigned':
|
case 'Unassigned':
|
||||||
$query->selfService($this->getUserUid());
|
$query->selfServiceMetrics();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$query->joinProcess();
|
$query->joinProcess();
|
||||||
|
|||||||
@@ -244,4 +244,16 @@ class Draft extends AbstractCases
|
|||||||
'total' => $count
|
'total' => $count
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count how many cases there are in DRAFT
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getCounterMetrics()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
$query->draftMetrics();
|
||||||
|
return $query->count(['APPLICATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,4 +260,16 @@ class Inbox extends AbstractCases
|
|||||||
'total' => $count
|
'total' => $count
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count how many cases there are in TO_DO
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getCounterMetrics()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
$query->inboxMetrics();
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,4 +254,16 @@ class Paused extends AbstractCases
|
|||||||
'total' => $count
|
'total' => $count
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count how many cases there are in PAUSED
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getCounterMetrics()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
$query->pausedMetrics();
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,4 +263,16 @@ class Unassigned extends AbstractCases
|
|||||||
'total' => $count
|
'total' => $count
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count how many cases there are in SELF_SERVICE
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getCounterMetrics()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
$query->selfServiceMetrics();
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1069,6 +1069,64 @@ class Delegation extends Model
|
|||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope the Inbox cases no matter the user
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeInboxMetrics($query)
|
||||||
|
{
|
||||||
|
$query->joinApplication();
|
||||||
|
$query->status(Application::STATUS_TODO);
|
||||||
|
$query->threadOpen();
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope a draft cases no matter the user
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeDraftMetrics($query)
|
||||||
|
{
|
||||||
|
$query->joinApplication();
|
||||||
|
$query->status(Application::STATUS_DRAFT);
|
||||||
|
$query->threadOpen();
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope paused cases list no matter the user
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopePausedMetrics($query)
|
||||||
|
{
|
||||||
|
$query->joinAppDelay('PAUSE');
|
||||||
|
$query->joinApplication();
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope a self service cases no matter the user
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeSelfServiceMetrics($query)
|
||||||
|
{
|
||||||
|
$query->taskAssignType('SELF_SERVICE');
|
||||||
|
$query->threadOpen()->withoutUserId();
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get specific cases unassigned that the user can view
|
* Get specific cases unassigned that the user can view
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
namespace ProcessMaker\Services\Api;
|
namespace ProcessMaker\Services\Api;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Luracast\Restler\RestException;
|
||||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||||
use ProcessMaker\BusinessModel\Cases\Inbox;
|
use ProcessMaker\BusinessModel\Cases\Inbox;
|
||||||
use ProcessMaker\BusinessModel\Cases\Paused;
|
use ProcessMaker\BusinessModel\Cases\Paused;
|
||||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||||
use ProcessMaker\Model\User;
|
|
||||||
use ProcessMaker\Services\Api;
|
use ProcessMaker\Services\Api;
|
||||||
use RBAC;
|
use RBAC;
|
||||||
|
|
||||||
@@ -46,8 +46,6 @@ class Metrics extends Api
|
|||||||
*/
|
*/
|
||||||
public function getProcessTotalCases($caseList, $category = null, $topTen = false, $processes = [])
|
public function getProcessTotalCases($caseList, $category = null, $topTen = false, $processes = [])
|
||||||
{
|
{
|
||||||
$usrUid = $this->getUserId();
|
|
||||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
|
||||||
try {
|
try {
|
||||||
switch ($caseList) {
|
switch ($caseList) {
|
||||||
case 'inbox':
|
case 'inbox':
|
||||||
@@ -61,10 +59,8 @@ class Metrics extends Api
|
|||||||
break;
|
break;
|
||||||
case 'unassigned':
|
case 'unassigned':
|
||||||
$list = new Unassigned();
|
$list = new Unassigned();
|
||||||
$list->setUserUid($usrUid);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$list->setUserId($usrId);
|
|
||||||
$result = $list->getCountersByProcesses($category, $topTen, $processes);
|
$result = $list->getCountersByProcesses($category, $topTen, $processes);
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -91,8 +87,6 @@ class Metrics extends Api
|
|||||||
*/
|
*/
|
||||||
public function getTotalCasesByRange($caseList, $processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day')
|
public function getTotalCasesByRange($caseList, $processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day')
|
||||||
{
|
{
|
||||||
$usrUid = $this->getUserId();
|
|
||||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
|
||||||
try {
|
try {
|
||||||
switch ($caseList) {
|
switch ($caseList) {
|
||||||
case 'inbox':
|
case 'inbox':
|
||||||
@@ -106,10 +100,8 @@ class Metrics extends Api
|
|||||||
break;
|
break;
|
||||||
case 'unassigned':
|
case 'unassigned':
|
||||||
$list = new Unassigned();
|
$list = new Unassigned();
|
||||||
$list->setUserUid($usrUid);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$list->setUserId($usrId);
|
|
||||||
$result = $list->getCountersByRange($processId, $dateFrom, $dateTo, $groupBy);
|
$result = $list->getCountersByRange($processId, $dateFrom, $dateTo, $groupBy);
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -125,31 +117,21 @@ class Metrics extends Api
|
|||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
|
*
|
||||||
|
* @class AccessControl {@permission TASK_METRICS_VIEW}
|
||||||
*/
|
*/
|
||||||
public function getCountersList()
|
public function getCountersList()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$usrUid = $this->getUserId();
|
|
||||||
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
|
|
||||||
|
|
||||||
$listInbox = new Inbox();
|
$listInbox = new Inbox();
|
||||||
$listInbox->setProperties($properties);
|
|
||||||
|
|
||||||
$listDraft = new Draft();
|
$listDraft = new Draft();
|
||||||
$listDraft->setUserUid($usrUid);
|
|
||||||
$listDraft->setProperties($properties);
|
|
||||||
|
|
||||||
$listPaused = new Paused();
|
$listPaused = new Paused();
|
||||||
$listPaused->setProperties($properties);
|
|
||||||
|
|
||||||
$listUnassigned = new Unassigned();
|
$listUnassigned = new Unassigned();
|
||||||
$listUnassigned->setUserUid($usrUid);
|
|
||||||
$listUnassigned->setProperties($properties);
|
|
||||||
|
|
||||||
$casesInbox = $listInbox->getCounter();
|
$casesInbox = $listInbox->getCounterMetrics();
|
||||||
$casesDraft = $listDraft->getCounter();
|
$casesDraft = $listDraft->getCounterMetrics();
|
||||||
$casesPaused = $listPaused->getCounter();
|
$casesPaused = $listPaused->getCounterMetrics();
|
||||||
$casesUnassigned = $listUnassigned->getCounter();
|
$casesUnassigned = $listUnassigned->getCounterMetrics();
|
||||||
|
|
||||||
$result = [
|
$result = [
|
||||||
['List Name' => 'Inbox', 'Total' => $casesInbox, 'Color' => 'green'],
|
['List Name' => 'Inbox', 'Total' => $casesInbox, 'Color' => 'green'],
|
||||||
@@ -179,12 +161,12 @@ class Metrics extends Api
|
|||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
|
*
|
||||||
|
* @class AccessControl {@permission TASK_METRICS_VIEW}
|
||||||
*/
|
*/
|
||||||
public function getCasesRiskByProcess($caseList = 'inbox', $process, $dateFrom = null, $dateTo = null, $riskStatus = 'ON_TIME', $topCases = null)
|
public function getCasesRiskByProcess($caseList = 'inbox', $process, $dateFrom = null, $dateTo = null, $riskStatus = 'ON_TIME', $topCases = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$usrUid = $this->getUserId();
|
|
||||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
|
||||||
switch ($caseList) {
|
switch ($caseList) {
|
||||||
case 'inbox':
|
case 'inbox':
|
||||||
$list = new Inbox();
|
$list = new Inbox();
|
||||||
@@ -197,10 +179,8 @@ class Metrics extends Api
|
|||||||
break;
|
break;
|
||||||
case 'unassigned':
|
case 'unassigned':
|
||||||
$list = new Unassigned();
|
$list = new Unassigned();
|
||||||
$list->setUserUid($usrUid);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$list->setUserId($usrId);
|
|
||||||
$result = $list->getCasesRisk($process, $dateFrom, $dateTo, $riskStatus, $topCases);
|
$result = $list->getCasesRisk($process, $dateFrom, $dateTo, $riskStatus, $topCases);
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user