-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1343-store-activity-identifier-in-database-to-include-t…
…he-activity-identifier-with-old-organisation-identifier' into develop
- Loading branch information
Showing
14 changed files
with
155 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\IATI\Models\Organization\Organization; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\DB; | ||
use PHPUnit\Exception; | ||
|
||
class FillDataForIssue1343Changes extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'command:FillDataForIssue1343Changes'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Fills activity identifier data for activity and organization for change related to issue #1343'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
try { | ||
DB::beginTransaction(); | ||
$this->info('Filling data for Issue 1343 changes...'); | ||
$organizations = Organization::all(); | ||
|
||
foreach ($organizations as $organization) { | ||
// $organization->timestamps = false; | ||
// $organization->updateQuietly([ | ||
// 'old_organization_identifiers' => [ json_encode(['identifiers' => $organization->identifier, 'created_at' => $organization->created_at]) ] | ||
// ]); | ||
// | ||
// $organization->saveQuietly(); | ||
|
||
$orgActivities = $organization->allActivities; | ||
|
||
foreach ($orgActivities as $activity) { | ||
$activityIdentifier = $activity->iati_identifier['activity_identifier']; | ||
$organizationIdentifier = $organization->identifier; | ||
|
||
$iatiIdentifier = [ | ||
'activity_identifier' => $activityIdentifier, | ||
'iati_identifier_text' => $organizationIdentifier . '-' . $activityIdentifier, | ||
'present_organization_identifier' => $organizationIdentifier, | ||
'updated_at' => $activity->created_at, | ||
]; | ||
|
||
$activity->timestamps = false; | ||
$activity->updateQuietly(['iati_identifier' => $iatiIdentifier]); | ||
} | ||
} | ||
|
||
DB::commit(); | ||
$this->info('Data filled successfully.'); | ||
} catch(Exception $e) { | ||
DB::rollback(); | ||
logger()->info($e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.