Skip to content

Commit

Permalink
fix: trying to fix the backfill action (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Apr 1, 2024
1 parent e4d068f commit 55a4713
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Actions\Models\Wiki\Anime;

use App\Actions\Models\Wiki\BackfillExternalLinksAnilistResourceAction;
use App\Actions\Models\Wiki\BackfillOtherResourcesAction;
use App\Enums\Models\Wiki\ResourceSite;
use App\Models\Wiki\Anime;
use App\Models\Wiki\ExternalResource;
Expand All @@ -15,11 +15,11 @@
use Illuminate\Support\Facades\Log;

/**
* Class BackfillAnimeExternalLinksAnilistResourceAction.
* Class BackfillAnimeOtherResourcesAction.
*
* @extends BackfillExternalLinksAnilistResourceAction<Anime>
* @extends BackfillOtherResourcesAction<Anime>
*/
class BackfillAnimeExternalLinksAnilistResourceAction extends BackfillExternalLinksAnilistResourceAction
class BackfillAnimeOtherResourcesAction extends BackfillOtherResourcesAction
{
/**
* Create a new action instance.
Expand Down Expand Up @@ -165,7 +165,7 @@ protected function getExternalLinksByAnilistResource(): ?array
';

$variables = [
'id' => $anilistResource->external_id
'id' => $anilistResource->external_id,
];

$response = Http::post('https://graphql.anilist.co', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
use Illuminate\Support\Facades\Log;

/**
* Class BackfillExternalLinksAnilistResourceAction.
* Class BackfillOtherResourcesAction.
*
* @template TModel of \App\Models\BaseModel
*
* @extends BackfillAction<TModel>
*/
abstract class BackfillExternalLinksAnilistResourceAction extends BackfillAction
abstract class BackfillOtherResourcesAction extends BackfillAction
{
/**
* Handle action.
Expand Down Expand Up @@ -59,10 +59,9 @@ public function handle(): ActionResult
if ($resource !== null) {
$this->attachResource($resource);
}

DB::commit();
}

DB::commit();
} catch (Exception $e) {
Log::error($e->getMessage());

Expand Down
8 changes: 4 additions & 4 deletions app/Nova/Actions/Models/Wiki/Anime/BackfillAnimeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Nova\Actions\Models\Wiki\Anime;

use App\Actions\Models\BackfillAction;
use App\Actions\Models\Wiki\Anime\BackfillAnimeExternalLinksAnilistResourceAction;
use App\Actions\Models\Wiki\Anime\BackfillAnimeOtherResourcesAction;
use App\Actions\Models\Wiki\Anime\Image\BackfillLargeCoverImageAction;
use App\Actions\Models\Wiki\Anime\Image\BackfillSmallCoverImageAction;
use App\Actions\Models\Wiki\Anime\Resource\BackfillAnidbResourceAction;
Expand Down Expand Up @@ -47,7 +47,7 @@ class BackfillAnimeAction extends Action implements ShouldQueue
final public const BACKFILL_ANILIST_RESOURCE = 'backfill_anilist_resource';
final public const BACKFILL_ANN_RESOURCE = 'backfill_ann_resource';
final public const BACKFILL_KITSU_RESOURCE = 'backfill_kitsu_resource';
final public const BACKFILL_EXTERNAL_LINKS_BY_ANILIST_RESOURCE = 'backfill_external_links_by_anilist_resource';
final public const BACKFILL_OTHER_RESOURCES = 'backfill_other_resources';
final public const BACKFILL_LARGE_COVER = 'backfill_large_cover';
final public const BACKFILL_MAL_RESOURCE = 'backfill_mal_resource';
final public const BACKFILL_SMALL_COVER = 'backfill_small_cover';
Expand Down Expand Up @@ -152,7 +152,7 @@ public function fields(NovaRequest $request): array
->help(__('nova.actions.anime.backfill.fields.resources.ann.help'))
->default(fn () => $anime instanceof Anime && $anime->resources()->where(ExternalResource::ATTRIBUTE_SITE, ResourceSite::ANN->value)->doesntExist()),

Boolean::make(__('nova.actions.anime.backfill.fields.resources.external_links.name'), self::BACKFILL_EXTERNAL_LINKS_BY_ANILIST_RESOURCE)
Boolean::make(__('nova.actions.anime.backfill.fields.resources.external_links.name'), self::BACKFILL_OTHER_RESOURCES)
->help(__('nova.actions.anime.backfill.fields.resources.external_links.help'))
->default(fn () => $anime instanceof Anime),

Expand Down Expand Up @@ -208,7 +208,7 @@ protected function getActionMapping(Anime $anime): array
self::BACKFILL_MAL_RESOURCE => new BackfillMalResourceAction($anime),
self::BACKFILL_ANIDB_RESOURCE => new BackfillAnidbResourceAction($anime),
self::BACKFILL_ANN_RESOURCE => new BackfillAnnResourceAction($anime),
self::BACKFILL_EXTERNAL_LINKS_BY_ANILIST_RESOURCE => new BackfillAnimeExternalLinksAnilistResourceAction($anime),
self::BACKFILL_OTHER_RESOURCES => new BackfillAnimeOtherResourcesAction($anime),
self::BACKFILL_LARGE_COVER => new BackfillLargeCoverImageAction($anime),
self::BACKFILL_SMALL_COVER => new BackfillSmallCoverImageAction($anime),
self::BACKFILL_STUDIOS => new BackfillAnimeStudiosAction($anime),
Expand Down

0 comments on commit 55a4713

Please sign in to comment.