-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
833 additions
and
1,550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,3 +116,6 @@ MAIL_PORT=2525 | |
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
|
||
GTM_ENABLED=false | ||
GTM_ID= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Aic\Hub\Foundation\AbstractCommand; | ||
|
||
abstract class BaseCommand extends AbstractCommand | ||
{ | ||
|
||
/** | ||
* Keys are namespaces under `\App\Models`. Values are human-readable headings for the docs. | ||
* Here, order determines order of sections in the docs. Resources under these sections will | ||
* be ordered according to their definitions in `config/resources.php`. | ||
* | ||
* @TODO: Consider moving this to `resources.sources`? | ||
* | ||
* @return array | ||
*/ | ||
protected function getCategories() | ||
{ | ||
return [ | ||
'Collections' => 'Collections', | ||
'Shop' => 'Shop', | ||
//'Membership' => 'Membership', | ||
'Mobile' => 'Mobile', | ||
'Dsc' => 'Digital Scholarly Catalogs', | ||
'StaticArchive' => 'Static Archive', | ||
//'Archive' => 'Archive', | ||
//'Library' => 'Library', | ||
'Web' => 'Website', | ||
]; | ||
} | ||
|
||
protected function getModelsForNamespace($desiredNamespace) | ||
{ | ||
return $this->getModels() | ||
->filter(function ($modelNamespace, $model) use ($desiredNamespace) { | ||
return $modelNamespace === $desiredNamespace; | ||
}) | ||
->keys(); | ||
} | ||
|
||
protected function getModels() | ||
{ | ||
if (isset($this->models)) { | ||
return $this->models; | ||
} | ||
|
||
return $this->models = collect(config('resources.outbound.base')) | ||
->filter(function ($value, $key) { | ||
return array_key_exists('endpoint', $value) && (!array_key_exists('is_restricted', $value) || $value['is_restricted'] === false); | ||
}) | ||
->pluck('model') | ||
->unique() | ||
->filter() | ||
->values() | ||
->map(function ($model) { | ||
$segments = explode('\\', $model); | ||
return [$model => $segments[count($segments) - 2]]; | ||
}) | ||
->collapse(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands\Dump; | ||
|
||
use Illuminate\Support\Facades\Storage; | ||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\File; | ||
use Exception; | ||
use Throwable; | ||
use App\Scopes\PublishedScope; | ||
|
||
class DumpJsonExport extends AbstractDumpCommand | ||
{ | ||
|
||
protected $signature = 'dump:json-export | ||
{--path= : Directory where to save dump, with `tables` subdir }'; | ||
|
||
protected $description = 'Create JSON dumps of all pubic endpoints'; | ||
|
||
public function handle() | ||
{ | ||
// Get all models for export | ||
$models = $this->getModels(); | ||
|
||
foreach ($models as $model => $category) { | ||
// Remove any old CSVs in this dump | ||
$dumpPath = $this->getDumpPath('local/json/' .app('Resources')->getEndpointForModel($model)); | ||
array_map('unlink', glob($dumpPath . '/*.json') ?: []); | ||
|
||
// Create transformer used for generating JSON output | ||
$transformer = app('Resources')->getTransformerForModel($model); | ||
$transformer = new $transformer; | ||
|
||
$model::addGlobalScope(new PublishedScope); | ||
|
||
// Give feedback to the user | ||
$this->info(app('Resources')->getEndpointForModel($model)); | ||
$bar = $this->output->createProgressBar($model::count()); | ||
|
||
// Loop through each record and dump its contents into a file | ||
$model::chunk(100, function ($items) use ($transformer, $model, $bar) { | ||
foreach ($items as $key => $item) { | ||
$filename = 'local/json/' .app('Resources')->getEndpointForModel($model) .'/' .$item->{$item->getKeyName()}. '.json'; | ||
Storage::disk('dumps')->put($filename, json_encode($transformer->transform($item), JSON_PRETTY_PRINT)); | ||
} | ||
$bar->advance($items->count()); | ||
}); | ||
$bar->finish(); | ||
$this->output->newLine(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.