Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Jan 25, 2018
2 parents 0567f65 + 0fd9ce5 commit c2a88be
Show file tree
Hide file tree
Showing 68 changed files with 2,885 additions and 928 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ELASTICSEARCH_ALIAS=test-v1 # use this to search across all model indexes

LAKE_URL=
IIIF_URL=
WEBSITE_URL=

COLLECTIONS_DATA_SERVICE_URL=
EVENTS_DATA_SERVICE_URL=
Expand All @@ -48,7 +49,12 @@ ULAN_DATA_SERVICE_URL=
LIBRARY_DATA_SERVICE_URL=
ARCHIVES_DATA_SERVICE_URL=

MOBILE_JSON=
LEGACY_EVENTS_JSON=
LEGACY_EXHIBITIONS_JSON=
STATIC_ARCHIVE_JSON=

PRIMO_API_SOURCE=

LOG_EMAIL_1=
LOG_EMAIL_2=
2 changes: 1 addition & 1 deletion app/Console/Commands/CreateEndpointDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function handle()
$doc .= \App\Models\Collections\ObjectType::instance()->docEndpoints($this->appUrl);
$doc .= \App\Models\Collections\Category::instance()->docEndpoints($this->appUrl);
$doc .= \App\Models\Collections\AgentType::instance()->docEndpoints($this->appUrl);
$doc .= \App\Models\Collections\Gallery::instance()->docEndpoints($this->appUrl);
$doc .= \App\Models\Collections\Place::instance()->docEndpoints($this->appUrl);
$doc .= \App\Models\Collections\Exhibition::instance()->docEndpoints($this->appUrl);
$doc .= \App\Models\Collections\Image::instance()->docEndpoints($this->appUrl);
$doc .= \App\Models\Collections\Video::instance()->docEndpoints($this->appUrl);
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/CreateFieldsDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function handle()
$doc .= \App\Models\Collections\ObjectType::instance()->docFields();
$doc .= \App\Models\Collections\Category::instance()->docFields();
$doc .= \App\Models\Collections\AgentType::instance()->docFields();
$doc .= \App\Models\Collections\Gallery::instance()->docFields();
$doc .= \App\Models\Collections\Place::instance()->docFields();
$doc .= \App\Models\Collections\Exhibition::instance()->docFields();
$doc .= \App\Models\Collections\Image::instance()->docFields();
$doc .= \App\Models\Collections\Video::instance()->docFields();
Expand Down
62 changes: 62 additions & 0 deletions app/Console/Commands/DatabaseReset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace App\Console\Commands;

use DB;
use Schema;

use Aic\Hub\Foundation\AbstractCommand;

class DatabaseReset extends AbstractCommand
{

protected $signature = 'db:reset';

protected $description = 'Removes all tables in current database';

public function handle()
{

if( $this->confirmReset() )
{
$this->dropTables();

} else {

$this->info('Database reset command aborted. Whew!');

}

}

private function confirmReset()
{

return (
$this->confirm('Are you sure you want to drop all tables in `'.env('DB_DATABASE').'`? [y|N]')
) && (
env('APP_ENV') === 'local' || $this->confirm('You aren\'t running in `local` environment. Are you really sure? [y|N]')
) && (
env('APP_ENV') !== 'production' || $this->confirm('You are in production! Are you really, really sure? [y|N]')
);

}

private function dropTables()
{

$tables = DB::select('SHOW TABLES');

// TODO: Return if there's no tables?
foreach( $tables as $table )
{
$table_array = get_object_vars( $table );
$table_name = $table_array[ key( $table_array ) ];
Schema::drop( $table_name );
$this->info( 'Dropped table ' . $table_name );
}

}

}
57 changes: 57 additions & 0 deletions app/Console/Commands/ImportAllCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class ImportAllCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'import:all';


/**
* The console command description.
*
* @var string
*/
protected $description = 'Run all import commands';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{

//$this->call('db:reset');
//$this->call('migrate');
//$this->call('import:collections-full');
//$this->call('import:exhibitions-legacy');
//$this->call('import:events-full');
//$this->call('import:events-legacy');
//$this->call('import:dsc');
//$this->call('import:mobile');
//$this->call('import:library');
//$this->call('import:archive');
//$this->call('import:sites');
$this->call('import:set-ulan-uris');

}

}
13 changes: 4 additions & 9 deletions app/Console/Commands/ImportArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use Carbon\Carbon;
use DB;

class ImportArchive extends AbstractImportCommand
{
Expand All @@ -24,12 +25,10 @@ public function handle()
// Remove all library materials from the search index
//$this->call("scout:flush", ['model' => \App\Models\Archive\ArchiveImage::class]);

// Pseduo-refresh this specific migration...
$migration = new \CreateArchiveTables();
$migration->down();
$migration->up();
// Truncate tables
DB::table('archival_images')->truncate();

$this->info("Refreshed \CreateArchiveTables migration.");
$this->info("Truncated archive tables.");

// Reinstall search: flush might not work, since some models might be present in the index, which aren't here
$this->warn("Please manually ensure that your search index mappings are up-to-date.");
Expand All @@ -46,8 +45,6 @@ public function handle()
private function import($model, $endpoint, $current = 1)
{

\DB::statement('SET FOREIGN_KEY_CHECKS=0');

// Abort if the table is already filled
if( $model::count() > 0 )
{
Expand All @@ -73,8 +70,6 @@ private function import($model, $endpoint, $current = 1)

}

\DB::statement('SET FOREIGN_KEY_CHECKS=1');

}

private function queryService($endpoint, $page = 1, $limit = 1000)
Expand Down
13 changes: 5 additions & 8 deletions app/Console/Commands/ImportCatalogues.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use Carbon\Carbon;
use DB;

use App\Models\Dsc\Publication;
use App\Models\Dsc\Section;
Expand All @@ -28,15 +29,11 @@ public function handle()
$this->call("scout:flush", ['model' => Publication::class]);
$this->call("scout:flush", ['model' => Section::class]);

// Truncate all tables
// $this->call("migrate:refresh");
// Truncate tables
DB::table('sections')->truncate();
DB::table('publications')->truncate();

// Pseduo-refresh this specific migration...
$migration = new \CreateDscTables();
$migration->down();
$migration->up();

$this->info("Refreshed CreateDscTables migration.");
$this->info("Truncated catalogue tables.");

// Reinstall search: flush might not work, since some models might be present in the index, which aren't here
$this->warn("Please manually ensure that your search index mappings are up-to-date.");
Expand Down
6 changes: 1 addition & 5 deletions app/Console/Commands/ImportCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function handle()
$this->import('departments');
$this->import('object-types');
$this->import('categories');
$this->import('galleries');
$this->import('places');
$this->import('artworks');
$this->import('links');
$this->import('videos');
Expand All @@ -34,8 +34,6 @@ public function handle()
private function import($endpoint, $current = 1)
{

\DB::statement('SET FOREIGN_KEY_CHECKS=0');

$model = \App\Models\CollectionsModel::classFor($endpoint);

$json = $this->queryService($endpoint, $current);
Expand Down Expand Up @@ -67,8 +65,6 @@ private function import($endpoint, $current = 1)

}

\DB::statement('SET FOREIGN_KEY_CHECKS=1');

}

private function queryService($endpoint, $page = 1, $limit = 100)
Expand Down
8 changes: 3 additions & 5 deletions app/Console/Commands/ImportCollectionsFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ public function handle()
{

$this->import('agent-types');
$this->import('agent-places');
$this->import('agents');
$this->import('departments');
$this->import('object-types');
$this->import('categories');
$this->import('galleries');
$this->import('places');
$this->import('artworks');
$this->import('links');
$this->import('videos');
$this->import('texts');
$this->import('sounds');
$this->import('images');
$this->import('exhibition-agents');
$this->import('exhibitions');

}
Expand All @@ -51,8 +53,6 @@ public function handle()
private function import($endpoint, $current = 1)
{

\DB::statement('SET FOREIGN_KEY_CHECKS=0');

$model = \App\Models\CollectionsModel::classFor($endpoint);

// Abort if the table is already filled in production.
Expand Down Expand Up @@ -83,8 +83,6 @@ private function import($endpoint, $current = 1)

}

\DB::statement('SET FOREIGN_KEY_CHECKS=1');

}

private function queryService($endpoint, $page = 1, $limit = 100)
Expand Down
14 changes: 6 additions & 8 deletions app/Console/Commands/ImportEventsFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use Carbon\Carbon;
use DB;

class ImportEventsFull extends AbstractImportCommand
{
Expand All @@ -24,15 +25,11 @@ public function handle()
// Remove all events from the search index
$this->call("scout:flush", ['model' => \App\Models\Membership\Event::class]);

// Truncate all tables
// $this->call("migrate:refresh");
// Truncate tables
DB::table('event_exhibition')->truncate();
DB::table('events')->truncate();

// Pseduo-refresh this specific migration...
$migration = new \CreateMembershipTables();
$migration->down();
$migration->up();

$this->info("Refreshed CreateMembershipTables migration.");
$this->info("Truncated event tables.");

// Reinstall search: flush might not work, since some models might be present in the index, which aren't here
$this->warn("Please manually ensure that your search index mappings are up-to-date.");
Expand Down Expand Up @@ -81,6 +78,7 @@ private function import($endpoint, $current = 1)

private function queryService($endpoint, $page = 1, $limit = 100)
{
$this->info(env('EVENTS_DATA_SERVICE_URL', 'http://localhost') . '/' . $endpoint . '?page=' . $page . '&limit=' . $limit);
return $this->query( env('EVENTS_DATA_SERVICE_URL', 'http://localhost') . '/' . $endpoint . '?page=' . $page . '&limit=' . $limit );
}

Expand Down
7 changes: 0 additions & 7 deletions app/Console/Commands/ImportLegacyEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Console\Commands;

use Storage;
use DB;
use Carbon\Carbon;
use App\Models\Membership\Event;

Expand Down Expand Up @@ -32,14 +31,8 @@ public function handle()

$results = json_decode( $contents );

// // We need to turn off foreign key checks, since we will be e.g. attaching sound ids
// // to mobile artworks before the mobile sounds have been imported.
DB::statement('SET FOREIGN_KEY_CHECKS=0');

$this->importEvents( $results );

DB::statement('SET FOREIGN_KEY_CHECKS=1');

}


Expand Down
Loading

0 comments on commit c2a88be

Please sign in to comment.