Skip to content

Commit

Permalink
Merge pull request #2165 from codeeu/2161-events-not-imported-automat…
Browse files Browse the repository at this point in the history
…ically

2161 events not imported automatically
  • Loading branch information
alainvd committed Oct 10, 2023
2 parents 5705451 + baf7a3a commit 6cd11f5
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 50 deletions.
11 changes: 3 additions & 8 deletions app/Console/Commands/api/Baden.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Baden extends Command
{

use GermanTraits;

/**
* The name and signature of the console command.
*
Expand Down Expand Up @@ -58,24 +59,18 @@ public function handle()
$url = "https://bw.codeweek.de/?tx_codeweekevents_api[action]=listForEu&tx_codeweekevents_api[controller]=Api&tx_codeweekevents_api[format]=.json&tx_typoscriptrendering[context]={%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.list.20.codeweekevents_api%22}&cHash=74bb9d71d62e381ebe95b33c1e197943";
dump("Loading $city events");

$response = Http::get($url);

$json = $response->json();
$json = $this->loadJson($url);

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}

$this->createRSSItem($json, $city);



return Artisan::call("import:baden");




}

public function getCustomTag($item, $tag)
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Bayern.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ public function handle()
dump("Loading $city events");
$force = $this->option('force');

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Berlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ public function handle()
dump("Loading $city events");
$force = $this->option('force');

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Bonn.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ public function handle()
$url = "https://bonn.codeweek.de/?tx_codeweekevents_api[action]=listForEu&tx_codeweekevents_api[controller]=Api&tx_codeweekevents_api[format]=.json&tx_typoscriptrendering[context]={%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.list.20.codeweekevents_api%22}&cHash=74bb9d71d62e381ebe95b33c1e197943";
dump("Loading $city events");

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Bremen.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ public function handle()
$url = "https://bremen.codeweek.de/?tx_codeweekevents_api[action]=listForEu&tx_codeweekevents_api[controller]=Api&tx_codeweekevents_api[format]=.json&tx_typoscriptrendering[context]={%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.list.20.codeweekevents_api%22}&cHash=74bb9d71d62e381ebe95b33c1e197943";
dump("Loading $city events");

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Dresden.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ public function handle()
$url = "https://dresden.codeweek.de/?tx_codeweekevents_api[action]=listForEu&tx_codeweekevents_api[controller]=Api&tx_codeweekevents_api[format]=.json&tx_typoscriptrendering[context]={%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.list.20.codeweekevents_api%22}&cHash=74bb9d71d62e381ebe95b33c1e197943";
dump("Loading $city events");

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
10 changes: 8 additions & 2 deletions app/Console/Commands/api/GermanTraits.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

trait GermanTraits
{

private function loadJson($url){
$client = new \GuzzleHttp\Client();
$guzzle = $client->request('get', $url);

return json_decode($guzzle->getBody(), true);
}
/**
* @param $json
*/
Expand All @@ -25,7 +32,6 @@ private function createRSSItem($json, $city): void
$className = '\App\RSSItems\\' . $city . 'RSSItem';
$RSSitem = new $className;


$RSSitem->uid = $item['uid'];
$RSSitem->title = $item['title'];
$RSSitem->description = $item['description'];
Expand All @@ -41,7 +47,7 @@ private function createRSSItem($json, $city): void
$RSSitem->user_publicEmail = $item['user']['publicEmail'];
$RSSitem->user_type = $item['user']['type']['identifier'] ?? '';
$RSSitem->user_website = $item['user']['www'];
$RSSitem->activity_type = $item['type']['identifier'];
$RSSitem->activity_type = $item['type']['identifier'] ?? 'invite-in-person';
$RSSitem->tags = trim(implode(";", Arr::pluck($item['tags'], 'title')));
$RSSitem->themes = trim(implode(",", Arr::pluck($item['themes'], 'identifier')));
$RSSitem->audience = trim(implode(",", Arr::pluck($item['audience'], 'identifier')));
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Hamburg.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ public function handle()
dump("Loading $city events");
$force = $this->option('force');

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Leipzig.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ public function handle()
dump("Loading $city events");
$force = $this->option('force');

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/api/Muensterland.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public function handle()
$url = "https://muensterland.codeweek.de/?tx_codeweekevents_api[action]=listForEu&tx_codeweekevents_api[controller]=Api&tx_codeweekevents_api[format]=.json&tx_typoscriptrendering[context]={%22record%22%3A%22pages_1%22%2C%22path%22%3A%22tt_content.list.20.codeweekevents_api%22}&cHash=74bb9d71d62e381ebe95b33c1e197943";
dump("Loading $city events");

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){

if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Nordhessen.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ public function handle()
dump("Loading $city events");
$force = $this->option('force');

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/api/Thueringen.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ public function handle()
dump("Loading $city events");
$force = $this->option('force');

$response = Http::get($url);
$json = $this->loadJson($url);

$json = $response->json();

if (is_null($json)){
if (is_null($json)) {
Log::info("!!! No data in feed from $city API:");
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion app/Helpers/ImporterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ImporterHelper

public static function getGermanCities()
{
return ['hamburg', 'baden', 'bonn', 'berlin', 'leipzig', 'dresden', 'thueringen', 'bremen', 'muensterland', 'nordhessen', 'bayern'];
// return ['hamburg', 'baden', 'bonn', 'berlin', 'leipzig', 'dresden', 'thueringen', 'bremen', 'muensterland', 'nordhessen', 'bayern'];
return ['hamburg', 'baden', 'bonn', 'berlin', 'leipzig', 'thueringen', 'bremen', 'muensterland', 'nordhessen', 'bayern'];
}

//Create or load Technical user based on username
Expand Down

0 comments on commit 6cd11f5

Please sign in to comment.