Skip to content

Commit

Permalink
Merge branch 'main' into prod-helm-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Aug 1, 2024
2 parents 72668ef + c1ef552 commit 52529a7
Show file tree
Hide file tree
Showing 13 changed files with 291 additions and 117 deletions.
82 changes: 82 additions & 0 deletions app/Console/Commands/UpdateDOI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace App\Console\Commands;

use App\Models\Project;
use App\Models\Study;
use App\Services\DOI\DOIService;
use Carbon\Carbon;
use Illuminate\Console\Command;

class UpdateDOI extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'nmrxiv:update-projects-dois {operator?} {update-date?}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Update DataCite DOI metadata of all the projects, studies, and datasets updated before or after a given date.';

/**
* The DOI service instance.
*
* @var \App\Services\DOI\DOIService
*/
protected $doiService;

/**
* Create a new class instance.
*
* @return void
*/
public function __construct(DOIService $doiService)
{
parent::__construct();

// Assign the DOI service instance
$this->doiService = $doiService;
}

/**
* Execute the console command.
*/
public function handle()
{
// $operator takes values from
// {'>' : after a certain update date,
// '<' : before a certain update date,
// '=' : at a certain update date}
$operator = $this->argument('operator');
$date = $this->argument('update-date');
$date = $date ? Carbon::parse($date) : null;

// Fetch the projects and samples (studies) based on the date
$projects = $date ? Project::where('updated_at', $operator, $date)->get() : Project::all();
$studies = $date ? Study::where('updated_at', $operator, $date)->get() : Study::all();

// Cover all studies within or without projects
foreach ($studies as $study) {
echo $study->identifier."\r\n";
foreach ($study->datasets as $dataset) {
echo $dataset->identifier."\r\n";
$dataset->updateDOIMetadata($this->doiService);
$dataset->addRelatedIdentifiers($this->doiService);
}
$study->updateDOIMetadata($this->doiService);
$study->addRelatedIdentifiers($this->doiService);
}

foreach ($projects as $project) {
echo $project->identifier."\r\n";
$project->updateDOIMetadata($this->doiService);
$project->addRelatedIdentifiers($this->doiService);
}
}
}
2 changes: 1 addition & 1 deletion app/Jobs/ProcessSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function handle(AssignIdentifier $assigner, UpdateDOI $updater, PublishPr
$studyPublisher->publish($study);
}
}

$updater->update($_studies);
//Notification::send($this->prepareSendList($project), new StudyPublishNotification($_studies));
event(new StudyPublish($_studies, $this->prepareSendList($project)));

Expand Down
5 changes: 1 addition & 4 deletions app/Listeners/ProjectDeletion.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ class ProjectDeletion
/**
* Create the event listener.
*/
public function __construct()
{

}
public function __construct() {}

/**
* Handle the event.
Expand Down
29 changes: 17 additions & 12 deletions app/Models/HasDOI.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,14 @@ public function addRelatedIdentifiers($doiService)
$this->save();

} elseif ($this instanceof Study) {
$relatedIdentifier = [
'relatedIdentifier' => $this->project->doi,
'relatedIdentifierType' => 'DOI',
'relationType' => 'IsPartOf',
];
array_push($attributes['relatedIdentifiers'], $relatedIdentifier);
if ($this->project) {
$relatedIdentifier = [
'relatedIdentifier' => $this->project->doi,
'relatedIdentifierType' => 'DOI',
'relationType' => 'IsPartOf',
];
array_push($attributes['relatedIdentifiers'], $relatedIdentifier);
}
foreach ($this->datasets as &$dataset) {
$relatedIdentifier = [
'relatedIdentifier' => $dataset->doi,
Expand All @@ -291,12 +293,15 @@ public function addRelatedIdentifiers($doiService)
$this->datacite_schema = $doiResponse;
$this->save();
} elseif ($this instanceof Dataset) {
$relatedIdentifier = [
'relatedIdentifier' => $this->project->doi,
'relatedIdentifierType' => 'DOI',
'relationType' => 'IsPartOf',
];
array_push($attributes['relatedIdentifiers'], $relatedIdentifier);
if ($this->project) {
$relatedIdentifier = [
'relatedIdentifier' => $this->project->doi,
'relatedIdentifierType' => 'DOI',
'relationType' => 'IsPartOf',
];
array_push($attributes['relatedIdentifiers'], $relatedIdentifier);
}

$relatedIdentifier = [
'relatedIdentifier' => $this->study->doi,
'relatedIdentifierType' => 'DOI',
Expand Down
4 changes: 1 addition & 3 deletions app/Providers/CephStorageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,5 @@ public function boot()
*
* @return void
*/
public function register()
{
}
public function register() {}
}
4 changes: 1 addition & 3 deletions app/Providers/MinioStorageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,5 @@ public function boot()
*
* @return void
*/
public function register()
{
}
public function register() {}
}
5 changes: 4 additions & 1 deletion resources/js/Pages/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
</div>
</div>
</template>
<div v-if="projects.length > 0" class="px-8 py-8 mx-auto max-w-4xl">
<div
v-if="projects.length > 0 || samples.length > 0"
class="px-8 py-8 mx-auto max-w-4xl"
>
<div>
<div class="sm:hidden">
<label for="tabs" class="sr-only">Select a tab</label>
Expand Down
5 changes: 3 additions & 2 deletions resources/js/Pages/Project/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
<div class="mt-3 max-w-2xl text-sm text-gray-700">
nmrXiv is organized around projects. Projects can
contain as many samples as you wish and each sample
receives its very own URL. To learn more, check out our
documentation.
receives its very own URL. Use the "UPLOAD" button on
the upper left side to start uploading projects or
samples. To learn more, check out our documentation.
</div>
<!-- <button
type="button"
Expand Down
27 changes: 24 additions & 3 deletions resources/js/Pages/Project/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,20 @@
</span>
</div>
</div>
<div
v-if="!canUpdateProject"
class="flex-nowrap right ml-auto"
>
<img
:src="
project.project_photo_url
? project.project_photo_url
: 'https://via.placeholder.com/400x200'
"
:alt="project.name"
class="h-24 w-72 rounded-md object-cover"
/>
</div>
<div class="flex-nowrap">
<Link
v-if="canManageProjectSetings"
Expand Down Expand Up @@ -333,7 +347,8 @@
!project.is_public &&
!project.is_published &&
!project.is_deleted &&
!project.doi
!project.doi &&
role != 'reviewer'
"
class="flex-nowrap"
>
Expand Down Expand Up @@ -935,7 +950,10 @@
</div>
</div>
<!-- Citation -->
<div class="mb-8">
<div
v-if="canUpdateProject || project.citations.length > 0"
class="mb-8"
>
<div class="relative">
<div
class="absolute inset-0 flex items-center"
Expand Down Expand Up @@ -972,7 +990,10 @@
</div>

<!-- Author -->
<div class="mb-8">
<div
v-if="canUpdateProject || project.authors.length > 0"
class="mb-8"
>
<div class="relative">
<div
class="absolute inset-0 flex items-center"
Expand Down
43 changes: 43 additions & 0 deletions resources/js/Pages/Public/Sample/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,49 @@
"
class="mt-4"
>
<div class="gap-y-6 sm:grid-cols-6 sm:gap-x-6">
<div class="pt-2 sm:col-span-6">
<h2
class="text-xl font-extrabold mb-3 text-blue-gray-900"
>
Submitter
</h2>
</div>
</div>
<div class="mt-1 grid grid-cols-1 gap-4 sm:grid-cols-2">
<div
class="relative rounded-lg border border-gray-300 bg-white p-5 shadow-sm flex items-center space-x-3 hover:border-gray-400 focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-pink-500"
>
<div class="flex-shrink-0">
<img
class="h-10 w-10 rounded-full"
:src="study.data.owner.profile_photo_url"
alt=""
/>
</div>
<div class="flex-1 min-w-0">
<a class="focus:outline-none">
<span
class="absolute inset-0"
aria-hidden="true"
></span>
<p
class="text-sm font-medium text-gray-900"
>
{{
study.data.owner.first_name +
" " +
study.data.owner.last_name
}}
</p>
<p class="text-sm text-gray-500 truncate">
@ {{ study.data.owner.username }}
</p>
</a>
</div>
</div>
</div>

<div class="relative">
<div
class="absolute inset-0 flex items-center"
Expand Down
5 changes: 4 additions & 1 deletion resources/js/Pages/Study/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
<div class="divide-y divide-gray-200 sm:col-span-9">
<div class="py-3 px-4 sm:p-6 lg:pb-8">
<div class="mt-0">
<div class="mb-4">
<div
v-if="canUpdateStudy || study.tags.length > 0"
class="mb-4"
>
<div class="relative">
<div
class="absolute inset-0 flex items-center"
Expand Down
31 changes: 21 additions & 10 deletions resources/js/Pages/Welcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@
>
<path
d="M7 3.41a1 1 0 0 0-.668-.943L2.275 1.039a.987.987 0 0 0-.877.166c-.25.192-.398.493-.398.812V12.2c0 .454.296.853.725.977l3.948 1.365A1 1 0 0 0 7 13.596V3.41ZM9 13.596a1 1 0 0 0 1.327.946l3.948-1.365c.429-.124.725-.523.725-.977V2.017c0-.32-.147-.62-.398-.812a.987.987 0 0 0-.877-.166L9.668 2.467A1 1 0 0 0 9 3.41v10.186Z"
></path></svg
><span class="self-baseline text-dark"
></path>
</svg>
<span class="self-baseline text-dark"
>Documentation</span
></a
><a
Expand All @@ -302,8 +303,9 @@
>
<path
d="M8 .198a8 8 0 0 0-8 8 7.999 7.999 0 0 0 5.47 7.59c.4.076.547-.172.547-.384 0-.19-.007-.694-.01-1.36-2.226.482-2.695-1.074-2.695-1.074-.364-.923-.89-1.17-.89-1.17-.725-.496.056-.486.056-.486.803.056 1.225.824 1.225.824.714 1.224 1.873.87 2.33.666.072-.518.278-.87.507-1.07-1.777-.2-3.644-.888-3.644-3.954 0-.873.31-1.586.823-2.146-.09-.202-.36-1.016.07-2.118 0 0 .67-.214 2.2.82a7.67 7.67 0 0 1 2-.27 7.67 7.67 0 0 1 2 .27c1.52-1.034 2.19-.82 2.19-.82.43 1.102.16 1.916.08 2.118.51.56.82 1.273.82 2.146 0 3.074-1.87 3.75-3.65 3.947.28.24.54.73.54 1.48 0 1.07-.01 1.93-.01 2.19 0 .21.14.46.55.38A7.972 7.972 0 0 0 16 8.199a8 8 0 0 0-8-8Z"
></path></svg
><span class="self-baseline text-dark"
></path>
</svg>
<span class="self-baseline text-dark"
>GitHub</span
></a
><a
Expand Down Expand Up @@ -405,19 +407,28 @@
class="mt-4 grid grid-cols-1 gap-y-12 gap-x-6 sm:grid-cols-3"
>
<p class="text-center">
<span class="block text-2xl font-bold"
>{{ projects }} Projects</span
<a
href="/projects"
class="block text-2xl font-bold"
>
{{ projects }} Projects
</a>
</p>
<p class="text-center">
<span class="block text-2xl font-bold"
>{{ compounds }} Compounds</span
<a
href="/compounds"
class="block text-2xl font-bold"
>
{{ compounds }} Compounds
</a>
</p>
<p class="text-center">
<span class="block text-2xl font-bold"
>{{ spectra }} Spectra</span
<a
href="/spectra"
class="block text-2xl font-bold"
>
{{ spectra }} Spectra
</a>
</p>
<!-- <p>
<span class="block text-2xl font-bold"
Expand Down
Loading

0 comments on commit 52529a7

Please sign in to comment.