diff --git a/database/migrations/2024_02_09_202858_create_molecules_table.php b/database/migrations/2024_02_09_202858_create_molecules_table.php index 5e16cb6e..33ab31d5 100644 --- a/database/migrations/2024_02_09_202858_create_molecules_table.php +++ b/database/migrations/2024_02_09_202858_create_molecules_table.php @@ -42,6 +42,12 @@ public function up(): void $table->boolean('is_parent')->default(0); $table->boolean('is_placeholder')->default(0); + $table->integer('organism_count')->default(0)->nullable(); + $table->integer('geo_count')->default(0)->nullable(); + $table->integer('citation_count')->default(0)->nullable(); + $table->integer('collection_count')->default(0)->nullable(); + $table->integer('synonym_count')->default(0)->nullable(); + $table->json('comment')->nullable(); $table->timestamps(); diff --git a/resources/scripts/update-counts.sql b/resources/scripts/update-counts.sql new file mode 100644 index 00000000..524b2856 --- /dev/null +++ b/resources/scripts/update-counts.sql @@ -0,0 +1,80 @@ +CREATE TEMPORARY TABLE temp_organism_counts AS +SELECT + mo.molecule_id, + COUNT(mo.organism_id) AS organism_count +FROM + molecule_organism mo +GROUP BY + mo.molecule_id; + +-- Then, update the molecules table using the temporary table +UPDATE molecules m +SET organism_count = toc.organism_count +FROM temp_organism_counts toc +WHERE m.id = toc.molecule_id; + +-- Optionally, drop the temporary table if no longer needed +DROP TABLE temp_organism_counts; + + +-- First, create a temporary table to store the counts +CREATE TEMPORARY TABLE temp_geo_counts AS +SELECT + mgl.molecule_id, + COUNT(mgl.geo_location_id) AS geo_count +FROM + geo_location_molecule mgl +GROUP BY + mgl.molecule_id; + +-- Then, update the molecules table using the temporary table +UPDATE molecules m +SET geo_count = tg.geo_count +FROM temp_geo_counts tg +WHERE m.id = tg.molecule_id; + +-- Optionally, drop the temporary table if no longer needed +DROP TABLE temp_geo_counts; + + +-- First, create a temporary table to store the counts +CREATE TEMPORARY TABLE temp_collection_counts AS +SELECT + mc.molecule_id, + COUNT(mc.collection_id) AS collection_count +FROM + collection_molecule mc +GROUP BY + mc.molecule_id; + +-- Then, update the molecules table using the temporary table +UPDATE molecules m +SET collection_count = tc.collection_count +FROM temp_collection_counts tc +WHERE m.id = tc.molecule_id; + +-- Optionally, drop the temporary table if no longer needed +DROP TABLE temp_collection_counts; + + +-- First, create a temporary table to store the counts +CREATE TEMPORARY TABLE temp_citation_counts AS +SELECT + mc.citable_id, + COUNT(mc.citation_id) AS citation_count +FROM + citables mc +GROUP BY + mc.citable_id; + +-- Then, update the molecules table using the temporary table +UPDATE molecules m +SET citation_count = tc.citation_count +FROM temp_citation_counts tc +WHERE m.id = tc.citable_id; + +-- Optionally, drop the temporary table if no longer needed +DROP TABLE temp_citation_counts; + +UPDATE molecules +SET synonym_count = json_array_length(synonyms); \ No newline at end of file diff --git a/resources/views/livewire/molecule-card.blade.php b/resources/views/livewire/molecule-card.blade.php index 1bbc82ed..3502dc36 100644 --- a/resources/views/livewire/molecule-card.blade.php +++ b/resources/views/livewire/molecule-card.blade.php @@ -1,31 +1,122 @@
- @if($molecule->identifier) + @if ($molecule->identifier) -
-
- +
+
+ +
+
+
+ @for ($i = 0; $i < $molecule->annotation_level; $i++) + + @endfor + @for ($i = $molecule->annotation_level; $i < 5; $i++) + ☆ + @endfor +
+
+

{{ $molecule->identifier }}

+
+

+ @if ($molecule->name) + {{ $molecule->name }} + @else + {{ $molecule->iupac_name }} + @endif +

+
-
- diff --git a/resources/views/livewire/welcome.blade.php b/resources/views/livewire/welcome.blade.php index 15651bc8..ef10fe15 100644 --- a/resources/views/livewire/welcome.blade.php +++ b/resources/views/livewire/welcome.blade.php @@ -61,7 +61,7 @@ class="rounded-md bg-secondary-dark px-3.5 py-1.5 text-base font-semibold leadin
+ class="bg-gray-50 justify-center items-center text-center rounded-md text-gray-900 mr-1 py-3 px-4 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-secondary-dark focus:ring-offset-2"> - Browse Data + Browse Data + class="bg-gray-50 justify-center items-center text-center rounded-md text-gray-900 mr-1 py-3 px-4 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-secondary-dark focus:ring-offset-2"> - Submit Data + Submit Data