Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
IllyaMoskvin committed Apr 12, 2022
2 parents 07922e7 + 8c861f0 commit 5a72694
Show file tree
Hide file tree
Showing 23 changed files with 734 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/Behaviors/ImportsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ protected function import($source, $model, $endpoint, $current = 1)
foreach ($json->data as $datum) {
// TODO: Careful, this conflicts w/ partial imports – running on one endpoint counts for all!
// Break if this is a partial import + this datum is older than last run
if ($this->isPartial && isset($datum->{$model::$sourceLastUpdateDateField})) {
$sourceTime = new Carbon($datum->{$model::$sourceLastUpdateDateField});
if ($this->isPartial && isset($datum->{$transformer::$sourceLastUpdateDateField})) {
$sourceTime = new Carbon($datum->{$transformer::$sourceLastUpdateDateField});
$sourceTime->timezone = config('app.timezone');

if ($this->since->gt($sourceTime)) {
Expand Down
1 change: 1 addition & 0 deletions app/Console/Commands/Import/ImportEnhancerFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected function importEndpoints()
$this->importEndpoint('agents');
$this->importEndpoint('artworks');
$this->importEndpoint('artwork-types');
$this->importEndpoint('places');
$this->importEndpoint('terms');
}

Expand Down
56 changes: 56 additions & 0 deletions app/Console/Commands/Report/ReportPlaces.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Console\Commands\Report;

use App\Models\Collections\Agent;

use League\Csv\Writer;
use Illuminate\Support\Facades\Storage;

use Aic\Hub\Foundation\AbstractCommand as BaseCommand;

class ReportPlaces extends BaseCommand
{

protected $signature = 'report:places {artistId}';

protected $description = 'Export all places associated with an artist\'s artworks';

public function handle()
{
$artistId = $this->argument('artistId');

$items = Agent::findOrFail($artistId)
->createdArtworks
->pluck('places')
->collapse()
->unique('citi_id')
->sortBy([
['citi_id', 'asc'],
])
->values();

$csv = Writer::createFromString('');

$csv->insertOne([
'id',
'title',
'latitude',
'longitude',
]);

foreach ($items as $item) {
$row = [
'id' => $item->citi_id,
'title' => $item->title,
'latitude' => $item->latitude,
'longitude' => $item->longitude,
];

$this->info(json_encode(array_values($row)));
$csv->insertOne($row);
}

Storage::put('places-for-' . $artistId . '.csv', $csv->getContent());
}
}
5 changes: 5 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ protected function schedule(Schedule $schedule)
->withoutOverlapping(self::FOR_ONE_YEAR)
->sendOutputTo(storage_path('logs/import-queues-last-run.log'));

$schedule->command('import:enhancer')
->everyMinute()
->withoutOverlapping(self::FOR_ONE_YEAR)
->sendOutputTo(storage_path('logs/import-enhancer-last-run.log'));

// API-231, API-232: Temporary remediation! Artworks can't touch artists.
$schedule->command('scout:import', [
\App\Models\Collections\Agent::class,
Expand Down
Loading

0 comments on commit 5a72694

Please sign in to comment.