Skip to content

Commit

Permalink
Merge pull request #1208 from younginnovations/1185-dashboard-visuali…
Browse files Browse the repository at this point in the history
…zation-api

Resolved: 1185-dashboard-visualization-api
  • Loading branch information
sriza authored Jul 17, 2023
2 parents 27df1e9 + eef9194 commit c7f2482
Show file tree
Hide file tree
Showing 66 changed files with 36,061 additions and 1,922 deletions.
62 changes: 62 additions & 0 deletions app/Console/Commands/FillOrgRegistrationType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\IATI\Models\Organization\Organization;
use App\IATI\Models\User\User;
use Arr;
use DB;
use Illuminate\Console\Command;

/**
* Class FillOrgRegistrationType.
*/
class FillOrgRegistrationType extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:fillOrgRegistrationType';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Fill registration type in organization';

/**
* Execute the console command.
*/
public function handle(): void
{
try {
DB::beginTransaction();

$registrationMethodMapping = [
'new_org' =>'new_org',
'existing_org' =>'existing_org',
'user_create' =>'existing_org',
];

$organizations = Organization::get();

foreach ($organizations as $organization) {
$user = User::where('organization_id', $organization->id)->first();
$userRegistrationType = $user ? $user->registration_method : 'existing_org';
$organization['registration_type'] = Arr::get($registrationMethodMapping, $userRegistrationType, 'existing_org');
$organization->timestamps = false;
$organization->saveQuietly(['touch' => false]);
}

DB::commit();
} catch (\Exception $e) {
DB::rollback();
logger()->error($e);
}
}
}
12 changes: 11 additions & 1 deletion app/Constants/Enums.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,22 @@ abstract class Enums
'user_create',
];

/**
* Enum for Organization registration method.
*
* @var array
*/
const ORGANIZATION_REGISTRATION_METHOD = [
'new_org'=>'New org',
'existing_org'=>'Existing org',
];

/**
* Enum for language preference of user.
*
* @var array
*/
public const LANGUAGE_PREFERENCE = [
const LANGUAGE_PREFERENCE = [
'en',
'fr',
'es',
Expand Down
14 changes: 12 additions & 2 deletions app/Helpers/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,18 @@ function getTableConfig($module): array
{
$tableConfig = [
'activity' => ['orderBy' => ['updated_at', 'complete_percentage'], 'direction' => ['asc', 'desc']],
'organisation' => ['orderBy' => ['updated_at', 'all_activities_count', 'name'], 'direction' => ['asc', 'desc']],
'user' => ['orderBy' => ['username', 'publisher_name', 'created_at'], 'direction' => ['asc', 'desc']],
'organisation' => [
'orderBy' => ['updated_at', 'all_activities_count', 'name', 'registered_on', 'publisher_type', 'data_license', 'country', 'last_logged_in'],
'direction' => ['asc', 'desc'],
'filters'=>[
'completeness' => 'single',
'registration_type' => 'single',
'country' => 'multiple',
'publisher_type' => 'multiple',
'data_license' => 'multiple',
],
],
'user' => ['orderBy' => ['username', 'publisher_name', 'created_at', 'organisation', 'admin', 'general', 'active', 'deactivated', 'total', 'last_logged_in'], 'direction' => ['asc', 'desc']],
'audit' => ['orderBy' => ['user_id', 'user_type', 'event', 'auditable_type', 'created_at'], 'direction' => ['asc', 'desc']],
];

Expand Down
Loading

0 comments on commit c7f2482

Please sign in to comment.