diff --git a/app/Actions/Coconut/SearchMolecule.php b/app/Actions/Coconut/SearchMolecule.php index dac6b452..5943a73c 100644 --- a/app/Actions/Coconut/SearchMolecule.php +++ b/app/Actions/Coconut/SearchMolecule.php @@ -216,7 +216,7 @@ private function buildTagsStatement($offset) if ($this->tagType == 'dataSource') { $this->collection = Collection::where('title', $this->query)->first(); if ($this->collection) { - return $this->collection->molecules()->orderBy('annotation_level', 'desc')->paginate($this->size); + return $this->collection->molecules()->where('active', true)->where('is_parent', false)->orderBy('annotation_level', 'desc')->paginate($this->size); } else { return []; } @@ -230,9 +230,9 @@ private function buildTagsStatement($offset) return Molecule::whereHas('organisms', function ($query) use ($organismIds) { $query->whereIn('organism_id', $organismIds); - })->orderBy('annotation_level', 'DESC')->paginate($this->size); + })->where('active', true)->where('is_parent', false)->orderBy('annotation_level', 'DESC')->paginate($this->size); } else { - return Molecule::withAnyTags([$this->query], $this->tagType)->paginate($this->size); + return Molecule::withAnyTags([$this->query], $this->tagType)->where('active', true)->where('is_parent', false)->paginate($this->size); } } @@ -296,6 +296,8 @@ private function buildDefaultStatement($offset) (\"name\"::TEXT ILIKE '%{$this->query}%') OR (\"synonyms\"::TEXT ILIKE '%{$this->query}%') OR (\"identifier\"::TEXT ILIKE '%{$this->query}%') + AND is_parent = FALSE + AND active = TRUE ORDER BY CASE WHEN \"name\"::TEXT ILIKE '{$this->query}' THEN 1 @@ -310,6 +312,7 @@ private function buildDefaultStatement($offset) } else { return "SELECT id, COUNT(*) OVER () FROM molecules + WHERE is_parent = FALSE AND active = TRUE ORDER BY annotation_level DESC LIMIT {$this->size} OFFSET {$offset}"; } diff --git a/app/Console/Commands/DashWidgetsRefresh.php b/app/Console/Commands/DashWidgetsRefresh.php index b5870577..a7d0f34b 100644 --- a/app/Console/Commands/DashWidgetsRefresh.php +++ b/app/Console/Commands/DashWidgetsRefresh.php @@ -78,22 +78,7 @@ public function handle() $this->info('Cache for molecules parent refreshed.'); Cache::rememberForever('stats.molecules', function () { - return Cache::rememberForever('stats.molecules.non_stereo', function () { - return DB::table('molecules')->selectRaw('count(*)')->whereRaw('has_stereo=false and is_parent=false')->get()[0]->count; - }) - // return DB::table('molecules') - // ->where('is_parent', false) - // ->where('has_stereo', false) - // ->count() - + - Cache::rememberForever('stats.molecules.stereo', function () { - return DB::table('molecules')->selectRaw('count(*)')->whereRaw('has_stereo=true')->get()[0]->count; - }); - // DB::table('molecules') - // ->where('is_parent', false) - // ->where('has_stereo', true) - // ->whereNotNull('parent_id') - // ->count(); + return DB::table('molecules')->selectRaw('count(*)')->whereRaw('has_stereo=false and is_parent=false and active=true')->get()[0]->count + DB::table('molecules')->selectRaw('count(*)')->whereRaw('has_stereo=true and active=true')->get()[0]->count; }); $this->info('Cache for molecules refreshed.'); diff --git a/app/Livewire/RecentMolecules.php b/app/Livewire/RecentMolecules.php index 8bb15428..8e5d9e7c 100644 --- a/app/Livewire/RecentMolecules.php +++ b/app/Livewire/RecentMolecules.php @@ -18,7 +18,7 @@ public function render() { return view('livewire.recent-molecules', [ 'molecules' => Cache::rememberForever('molecules.recent', function () { - return MoleculeResource::collection(Molecule::where('has_variants', true)->where('name', '!=', null)->where('annotation_level', '=', 5)->orderByDesc('updated_at')->paginate($this->size)); + return MoleculeResource::collection(Molecule::where('is_parent', false)->where('active', true)->where('name', '!=', null)->where('annotation_level', '=', 5)->orderByDesc('updated_at')->paginate($this->size)); }), ]); } diff --git a/resources/views/livewire/structure-editor.blade.php b/resources/views/livewire/structure-editor.blade.php index 52aaec46..c50ecafc 100644 --- a/resources/views/livewire/structure-editor.blade.php +++ b/resources/views/livewire/structure-editor.blade.php @@ -2,10 +2,6 @@ if (value) { setTimeout(() => { const editor = OCL.StructureEditor.createSVGEditor('structureSearchEditor', 1); - if (smiles) { - console.log(smiles) - editor.setSmiles(smiles); - } window.getEditorSmiles = () => editor.getSmiles(); }, 100); } @@ -24,6 +20,7 @@ class="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left ov +