<commit_before><?php

namespace App\Console\Commands;

use App\Models\Collections\AgentRole;
use App\Models\Collections\ArtworkType;

class ImportCollectionsFull extends AbstractImportCommandNew
{

    protected $signature = 'import:collections-full
                            {endpoint? : Endpoint on dataservice to query, e.g. `object-types`}
                            {page? : Page to begin importing from}';

    protected $description = "Import all collections data. If no options are passed all Collections data will be imported.";


    public function handle()
    {

        $this->api = env('COLLECTIONS_DATA_SERVICE_URL');

        $endpoint = $this->argument('endpoint');

        if ($endpoint) {

            $page = $this->argument('page') ?: 1;

            $this->importEndpoint($endpoint, $page);

        } else {

            $this->importEndpoints();

        }

    }

    protected function importEndpoints()
    {

        $this->importEndpoint('artwork-place-qualifiers');
        $this->importEndpoint('artwork-date-qualifiers');
        $this->importEndpoint('artwork-agent-roles');
        $this->importEndpoint('object-types');
        $this->importEndpoint('agent-types');
        $this->importEndpoint('agent-places');
        $this->importEndpoint('agents');
        $this->importEndpoint('categories');
        $this->importEndpoint('places');
        $this->importEndpoint('galleries');
        $this->importEndpoint('artwork-catalogues');
        $this->importEndpoint('catalogues');
        $this->importEndpoint('artworks');
        $this->importEndpoint('links');
        $this->importEndpoint('videos');
        $this->importEndpoint('texts');
        $this->importEndpoint('sounds');
        $this->importEndpoint('images');
        $this->importEndpoint('exhibition-agents');
        $this->importEndpoint('exhibitions');
        $this->importEndpoint('term-types');
        $this->importEndpoint('terms');

    }

    protected function importEndpoint($endpoint, $page = 1)
    {

        $model = $this->getModelForEndpoint($endpoint);

        $this->import( $model, $endpoint, $page );

    }

    protected function getModelForEndpoint($endpoint)
    {

        // TODO: Outbound endpoints don't always equal inbound endpoints
        // Consider specifying them in inbound transformers? Or config file?
        switch( $endpoint )
        {
            case 'artwork-agent-roles':
                $model = AgentRole::class;
            break;
            case 'object-types':<commit_msg>Disable `links` import<commit_after><?php

namespace App\Console\Commands;

use App\Models\Collections\AgentRole;
use App\Models\Collections\ArtworkType;

class ImportCollectionsFull extends AbstractImportCommandNew
{

    protected $signature = 'import:collections-full
                            {endpoint? : Endpoint on dataservice to query, e.g. `object-types`}
                            {page? : Page to begin importing from}';

    protected $description = "Import all collections data. If no options are passed all Collections data will be imported.";


    public function handle()
    {

        $this->api = env('COLLECTIONS_DATA_SERVICE_URL');

        $endpoint = $this->argument('endpoint');

        if ($endpoint) {

            $page = $this->argument('page') ?: 1;

            $this->importEndpoint($endpoint, $page);

        } else {

            $this->importEndpoints();

        }

    }

    protected function importEndpoints()
    {

        $this->importEndpoint('artwork-place-qualifiers');
        $this->importEndpoint('artwork-date-qualifiers');
        $this->importEndpoint('artwork-agent-roles');
        $this->importEndpoint('object-types');
        $this->importEndpoint('agent-types');
        $this->importEndpoint('agent-places');
        $this->importEndpoint('agents');
        $this->importEndpoint('categories');
        $this->importEndpoint('places');
        $this->importEndpoint('galleries');
        $this->importEndpoint('artwork-catalogues');
        $this->importEndpoint('catalogues');
        $this->importEndpoint('artworks');
        // $this->importEndpoint('links'); // TODO: Deprecate links!
        $this->importEndpoint('videos');
        $this->importEndpoint('texts');
        $this->importEndpoint('sounds');
        $this->importEndpoint('images');
        $this->importEndpoint('exhibition-agents');
        $this->importEndpoint('exhibitions');
        $this->importEndpoint('term-types');
        $this->importEndpoint('terms');

    }

    protected function importEndpoint($endpoint, $page = 1)
    {

        $model = $this->getModelForEndpoint($endpoint);

        $this->import( $model, $endpoint, $page );

    }

    protected function getModelForEndpoint($endpoint)
    {

        // TODO: Outbound endpoints don't always equal inbound endpoints
        // Consider specifying them in inbound transformers? Or config file?
        switch( $endpoint )
        {
            case 'artwork-agent-roles':
                $model = AgentRole::class;
            break;
            case 'object-types':
{'fraction_non_alphanumeric': 0.1396713615023474, 'fraction_numerical': 0.000782472613458529, 'mean_word_length': 2.6211048158640224, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '816558', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1303, 'n_words': 256}