Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions app/Console/Commands/UpdateOrcids.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,48 @@ public function __construct()
*/
public function handle()
{
$inc = 0;
$total_profiles_count = $total_orcid_works_count = $updated_total = $created_total = 0;
$exact_id_match_total = $contained_id_url_match_total = $exact_title_match_total = $contained_title_match_total = 0;
$no_url_count_total = $similar_title_count_total = 0;

$profiles = Profile::whereHas('data', function ($query) {
$query->where('type', 'information')
->where('data->orc_id_managed', '1')
->whereNotNull('data->orc_id');
})->get();
$query->where('type', 'information')
->where('data->orc_id_managed', '1')
->whereNotNull('data->orc_id');
})->get();

$this->lineAndLog("Starting scheduled ORCiD data update for {$profiles->count()} profiles... ");
$this->lineAndLog("Starting scheduled ORCiD data update for {$profiles->count()} profiles... \n");

foreach ($profiles as $profile) {
if ($profile->updateORCID()) {
$inc++;
$results = $profile->updateORCID();

if ($results['completed']) {
$total_profiles_count++;
$total_orcid_works_count += $results['orcid_works_count'];
$created_total += $results['created'];
$updated_total += $results['updated'];
$exact_id_match_total += $results['exact_id_match'];
$contained_id_url_match_total += $results['contained_id_url_match'];
$exact_title_match_total += $results['exact_title_match'];
$contained_title_match_total += $results['contained_title_match'];
$no_url_count_total += $results['no_url_count'];
$similar_title_count_total += $results['similar_title_count'];
$this->lineAndLog("Updated ORCiD info for {$profile->full_name}");
}
else {
$this->lineAndLog("An error has occurred updating ORCiD info for {$profile->full_name}, profile_id: {$profile->id}, profile: {$profile->url}", 'error');
}
}

$this->lineAndLog("Completed: {$inc}/{$profiles->count()} profiles have been updated.");
$this->lineAndLog("Completed: {$total_profiles_count}/{$profiles->count()} profiles have been updated.");
$this->lineAndLog("TOTAL: {$updated_total} publications updated/{$total_orcid_works_count} orcid records found.");
$this->lineAndLog("TOTAL: {$created_total} new publications created.");
$this->lineAndLog("TOTAL: {$exact_id_match_total} publications found by exact ID.");
$this->lineAndLog("TOTAL: {$contained_id_url_match_total} publications found by id contained in URL.");
$this->lineAndLog("TOTAL: {$exact_title_match_total} publications found by exact title.");
$this->lineAndLog("TOTAL: {$contained_title_match_total} publications found by title contained in existing record.");
$this->lineAndLog("TOTAL: {$similar_title_count_total} similar publications have been found.");
$this->lineAndLog("TOTAL: {$no_url_count_total} publications without URL.");

return Command::SUCCESS;
}
Expand Down
7 changes: 0 additions & 7 deletions app/Http/Controllers/ProfilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,6 @@ public function create(Request $request, User $user, LdapHelperContract $ldap):
*/
public function edit(Profile $profile, string $section): View|ViewContract|RedirectResponse
{
//dont manage auto-managed publications
if ($section == 'publications' && $profile->hasOrcidManagedPublications()) {
$profile->updateORCID();
return redirect()
->route('profiles.show', $profile->slug)
->with('flash_message', 'Publications updated via ORCID.');
}

$data = $profile->data()->$section()->get();

Expand Down
Loading
Loading