Skip to content

Commit

Permalink
pkp#10362 include editorName when logging an editorial decision
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlinnewson committed Nov 28, 2024
1 parent 8d8ada9 commit 6aca2bb
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
5 changes: 3 additions & 2 deletions classes/decision/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* @file classes/decision/Repository.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class Repository
Expand Down Expand Up @@ -242,6 +242,7 @@ public function add(Decision $decision): int
? PKPSubmissionEventLogEntry::SUBMISSION_LOG_EDITOR_RECOMMENDATION
: PKPSubmissionEventLogEntry::SUBMISSION_LOG_EDITOR_DECISION,
'userId' => Validation::loggedInAs() ?? $this->request->getUser()?->getId(),
'editorName' => $editor->getFullName(),
'message' => $decisionType->getLog(),
'isTranslated' => false,
'dateLogged' => Core::getCurrentDate()
Expand Down
71 changes: 71 additions & 0 deletions classes/migration/upgrade/v3_5_0/I10362_EventLogEditorNames.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/I10362_EventLogEditorNames.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I10362_EventLogEditorNames
*
* @brief Adds missing editorName settings to the event log.
*/

namespace PKP\migration\upgrade\v3_5_0;

use APP\facades\Repo;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Facades\DB;
use PKP\install\DowngradeNotSupportedException;
use PKP\migration\Migration;

class I10362_EventLogEditorNames extends Migration
{

/**
* Run the migrations.
*/
public function up(): void
{
$idsToUpdate = DB::table('event_log as e')
->select('e.log_id', 'e.user_id', 'e.event_type')
->leftJoin('event_log_settings as es', function (JoinClause $join) {
$join->on('es.log_id', '=', 'e.log_id')
->where('es.setting_name', '=', 'editorName');
})
->whereNull('es.log_id')
->whereIn('e.event_type', [
0x30000003, // PKPSubmissionEventLogEntry::SUBMISSION_LOG_EDITOR_DECISION
0x30000004 // PKPSubmissionEventLogEntry::SUBMISSION_LOG_EDITOR_RECOMMENDATION
])
->orderBy('e.log_id')
->pluck('user_id', 'log_id');

$inserts = [];
foreach ($idsToUpdate as $eventLogId => $userId) {
$editorName = Repo::user()->get($userId)->getFullName();

if ($editorName) {
$inserts[] = [
'log_id' => $eventLogId,
'setting_name' => 'editorName',
'setting_value' => $editorName
];
}
}

DB::table('event_log_settings')
->insert($inserts);
}

/**
* Reverse the migration.
*
* @throws DowngradeNotSupportedException
*/
public function down(): void
{
throw new DowngradeNotSupportedException();
}
}

0 comments on commit 6aca2bb

Please sign in to comment.