Skip to content

Commit

Permalink
feat: bug fixes and other updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed May 15, 2024
1 parent 9b3cac4 commit 6772b7c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Console/Commands/ImportEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ImportEntries extends Command
*
* @var string
*/
protected $signature = 'entries:import {collection_id}';
protected $signature = 'entries:import {collection_id?}';

/**
* The console command description.
Expand All @@ -35,7 +35,7 @@ public function handle()
if (! is_null($collection_id)) {
$collections = Collection::where('id', $collection_id)->get();
} else {
$collections = Collection::where('status', 'PUBLISHED')->get();
$collections = Collection::where('status', 'DRAFT')->get();
}

foreach ($collections as $collection) {
Expand Down
2 changes: 2 additions & 0 deletions app/Filament/Dashboard/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Filament\Dashboard\Resources\CollectionResource\RelationManagers\CitationsRelationManager;
use App\Filament\Dashboard\Resources\CollectionResource\RelationManagers\EntriesRelationManager;
use App\Filament\Dashboard\Resources\CollectionResource\Widgets\CollectionStats;
use App\Filament\Dashboard\Resources\CollectionResource\Widgets\EntriesOverview;
use App\Livewire\ShowJobStatus;
use App\Models\Collection;
use Filament\Forms\Components\Livewire;
Expand Down Expand Up @@ -112,6 +113,7 @@ public static function getWidgets(): array
{
return [
CollectionStats::class,
EntriesOverview::class
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ class CollectionStats extends BaseWidget
protected function getStats(): array
{
return [
Stat::make('Total Entries', $this->record->entries->count()),
Stat::make('Entries', $this->record->entries->count())
->description('Total count')
->color('primary'),
Stat::make('Passed Entries', $this->record->entries->where('status', 'PASSED')->count())
->description('Successful count')
->color('success'),
Stat::make('Entries', $this->record->entries->where('status', 'REJECTED')->count())
->description('Failed entries')
->color('danger'),
// Stat::make('Total Entries', $this->record->entries->count()),
Stat::make('Total Molecules', $this->record->molecules->count()),
Stat::make('Total Citations', $this->record->citations->count()),
// Stat::make('Total Organisms', Cache::rememberForever('stats.collections'.$this->record->id.'organisms.count', function () {
Expand Down
4 changes: 3 additions & 1 deletion app/Jobs/ImportEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function __construct($entry)
public function handle(): void
{
if ($this->entry->status == 'PASSED') {
$molecule = null;
if ($this->entry->has_stereocenters) {
$data = $this->getRepresentations('parent');
$parent = $this->firstOrCreateMolecule($data['canonical_smiles'], $data['standard_inchi']);
Expand Down Expand Up @@ -288,7 +289,8 @@ public function fetchDOICitation($doi, $molecule)
} else {
// fetch citation from CrossRef
$crossrefUrl = env('CROSSREF_WS_API').$doi;
$crossrefResponse = $this->makeRequest($crossrefUrl)->json();
$response = $this->makeRequest($crossrefUrl);
$crossrefResponse = $response ? $response->json() : null;
if ($crossrefResponse && isset($crossrefResponse['message'])) {
$citationResponse = $this->formatCitationResponse($crossrefResponse['message'], 'crossref');
} else {
Expand Down

0 comments on commit 6772b7c

Please sign in to comment.