Skip to content

Commit

Permalink
fix: compound details page, header link updates and annotation score …
Browse files Browse the repository at this point in the history
…code formatting
  • Loading branch information
CS76 committed Aug 8, 2024
1 parent 465672a commit ad443a0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
30 changes: 15 additions & 15 deletions app/Console/Commands/GenerateAnnotationScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ public function handle()
->where('active', true)
->orderBy('id')
->chunk($batchSize, function ($molecules) use ($data) {
foreach ($molecules as $molecule) {
$score = $this->calculateAnnotationScore($molecule);
array_push($data, [
'id' => $molecule->id,
'annotation_level' => $score,
]);
}
if (! empty($data)) {
$this->info('Updating row:' . $molecule->id);
$this->updateBatch($data);
$data = [];
}
});
foreach ($molecules as $molecule) {
$score = $this->calculateAnnotationScore($molecule);
array_push($data, [
'id' => $molecule->id,
'annotation_level' => $score,
]);
}
if (! empty($data)) {
$this->info('Updating row:'.$molecule->id);
$this->updateBatch($data);
$data = [];
}
});

$this->info('Annotation scores generated successfully.');
}

Expand Down Expand Up @@ -71,7 +71,7 @@ private function updateBatch(array $data)
protected function calculateAnnotationScore($molecule)
{
$casScore = $molecule->cas ? 1 : 0;
$synonymsScore = $molecule->synonyms ? ( $molecule->synonym_count >= 1 ? 1 : 0) : 0;
$synonymsScore = $molecule->synonyms ? ($molecule->synonym_count >= 1 ? 1 : 0) : 0;
$nameScore = $molecule->name ? 1 : 0;

$literatureScore = $molecule->citation_count >= 2 ? 1 : ($molecule->citation_count >= 1 ? 0.5 : 0);
Expand Down
6 changes: 3 additions & 3 deletions resources/views/livewire/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class="-m-2.5 inline-flex items-center justify-center rounded-md p-2.5 text-gray
</button>
</div>
<div class="hidden lg:flex lg:gap-x-12">
<a href="/search" class="text-sm font-semibold leading-6 text-gray-900">Browse</a>
<a href="/search" class="text-sm font-semibold leading-6 text-gray-900">Search</a>
<a href="/api-documentation" class="text-sm font-semibold leading-6 text-gray-900">API</a>
<a href="/guidelines" class="text-sm font-semibold leading-6 text-gray-900">Guidelines</a>
<a href="https://cheminf.uni-jena.de/" class="text-sm font-semibold leading-6 text-gray-900">About
<a href="https://" class="text-sm font-semibold leading-6 text-gray-900">Guidelines</a>
<a href="/about" class="text-sm font-semibold leading-6 text-gray-900">About
us</a>
<a href="/download" class="text-sm font-semibold leading-6 text-gray-900">Download</a>
</div>
Expand Down
37 changes: 21 additions & 16 deletions resources/views/livewire/molecule-details.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class="relative -ml-px inline-flex items-center rounded-r-md bg-white px-3 py-2
@endif
@endforeach
</ul>
@if(count($molecule->organisms) > 10)
<div class="mt-4">
<button @click="showAll = true" x-show="!showAll"
class="text-base font-semibold leading-7 text-secondary-dark text-sm">
Expand All @@ -151,6 +152,7 @@ class="text-base font-semibold leading-7 text-secondary-dark text-sm">
View Less ↑
</button>
</div>
@endif
</div>
</div>
</div>
Expand Down Expand Up @@ -284,6 +286,7 @@ class="border px-4 bg-white isolate inline-flex rounded-md shadow-sm mb-2">
@endif
@endforeach
</ul>
@if($molecule->synonym_count > 10)
<div class="mt-4">
<button @click="showAll = true" x-show="!showAll"
class="text-base font-semibold leading-7 text-secondary-dark text-sm">
Expand All @@ -294,6 +297,7 @@ class="text-base font-semibold leading-7 text-secondary-dark text-sm">
View Less ↑
</button>
</div>
@endif
</div>
</div>
</div>
Expand Down Expand Up @@ -475,16 +479,13 @@ class="text-base font-semibold leading-7 text-secondary-dark text-sm">
<div class="not-prose grid grid-cols-1 gap-6 sm:grid-cols-1"
x-data="{ showAllCollections: false }">
@foreach ($molecule->collections as $index => $collection)
<a href="/search?type=tags&amp;q={{ $collection->title }}&amp;tagType=dataSource"
<div
x-show="showAllCollections || {{ $index }} < 6">
<div class="group relative rounded-xl border border-slate-200">
<div
class="absolute -inset-px rounded-xl border-2 border-transparent opacity-0 [background:linear-gradient(var(--quick-links-hover-bg,theme(colors.sky.50)),var(--quick-links-hover-bg,theme(colors.sky.50)))_padding-box,linear-gradient(to_top,theme(colors.indigo.400),theme(colors.cyan.400),theme(colors.sky.500))_border-box] group-hover:opacity-100">
</div>
<div class="relative overflow-hidden rounded-xl p-6">
<svg aria-hidden="true" viewBox="0 0 32 32"
fill="none"
class="h-8 w-8 [--icon-foreground:theme(colors.slate.900)] [--icon-background:theme(colors.white)]">
class="mb-2 h-8 w-8 [--icon-foreground:theme(colors.slate.900)] [--icon-background:theme(colors.white)]">
<defs>
<radialGradient cx="0" cy="0"
r="1" gradientUnits="userSpaceOnUse"
Expand Down Expand Up @@ -537,21 +538,25 @@ class="fill-[var(--icon-background)] stroke-[color:var(--icon-foreground)]"
fill="url(#:R1k19n6:-gradient-dark)"></path>
</g>
</svg>
<h2 class="mt-2 font-bold text-base text-gray-900">
<span
class="absolute -inset-px rounded-xl"></span>{{ $collection->title }}
<a href="/search?type=tags&amp;q={{ $collection->title }}&amp;tagType=dataSource" class="hover:pointer font-bold text-base text-xl text-gray-900">
{{ $collection->title }} <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4 inline">
<path stroke-linecap="round" stroke-linejoin="round" d="m9 9 6-6m0 0 6 6m-6-6v12a6 6 0 0 1-12 0v-3"></path>
</svg>
</a>
<h2 x-show="$collection->description" class="mt-2 font-display text-base text-slate-900">
{{ $collection->description }}
</h2>
<h2 class="mt-2 font-display text-base text-slate-900">
<span
class="absolute -inset-px rounded-xl"></span>{{ $collection->description }}
<h2 x-show="$collection->doi" class="mt-2 font-display text-base text-slate-900">
{{ $collection->doi }}
</h2>
<h2 class="mt-2 font-display text-base text-slate-900">
<span
class="absolute -inset-px rounded-xl"></span>{{ $collection->doi }}
<h2 x-show="$collection->pivot->reference" class="hover:text-blue-500 mt-1 font-display text-base text-slate-900">
Reference: <a href="{{ $collection->pivot->url }}" target="_blank">{{ $collection->pivot->reference }} <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4 inline">
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"></path>
</svg></a>
</h2>
</div>
</div>
</a>
</div>
@endforeach
@if (count($molecule->collections) > 6)
<div class="flex justify-center mt-4">
Expand Down Expand Up @@ -623,7 +628,7 @@ class="text-base font-semibold leading-7 text-secondary-dark text-sm">
<div class="bg-white shadow border sm:overflow-hidden sm:rounded-lg">
<div class="divide-y divide-gray-200">
<div class="px-4 py-5 sm:px-6">
<h2 id="notes-title" class="text-lg font-medium text-gray-900">Parent
<h2 id="notes-title" class="text-lg font-medium text-gray-900">Parent (With our stereo definitions)
</h2>
</div>
<div class="px-4 pb-5 sm:px-6">
Expand Down

0 comments on commit ad443a0

Please sign in to comment.