Skip to content

Commit

Permalink
fix: cache and search filters update and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Aug 7, 2024
1 parent e53ddb7 commit fe82ab1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
9 changes: 6 additions & 3 deletions app/Actions/Coconut/SearchMolecule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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}";
}
Expand Down
17 changes: 1 addition & 16 deletions app/Console/Commands/DashWidgetsRefresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');

Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/RecentMolecules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}),
]);
}
Expand Down
5 changes: 1 addition & 4 deletions resources/views/livewire/structure-editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -24,6 +20,7 @@ class="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left ov
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title">
Structure Editor
</h3>

<div class="py-3">
<div id="structureSearchEditor" class="border" style="height: 400px; width: 100%"></div>
</div>
Expand Down

0 comments on commit fe82ab1

Please sign in to comment.