Skip to content

Commit 6cd11f5

Browse files
author
A. Van Driessche
authored
Merge pull request #2165 from codeeu/2161-events-not-imported-automatically
2161 events not imported automatically
2 parents 5705451 + baf7a3a commit 6cd11f5

13 files changed

Lines changed: 34 additions & 50 deletions

File tree

app/Console/Commands/api/Baden.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Baden extends Command
1616
{
1717

1818
use GermanTraits;
19+
1920
/**
2021
* The name and signature of the console command.
2122
*
@@ -58,24 +59,18 @@ public function handle()
5859
$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";
5960
dump("Loading $city events");
6061

61-
$response = Http::get($url);
62-
63-
$json = $response->json();
62+
$json = $this->loadJson($url);
6463

65-
if (is_null($json)){
64+
if (is_null($json)) {
6665
Log::info("!!! No data in feed from $city API:");
6766
return 0;
6867
}
6968

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

72-
73-
7471
return Artisan::call("import:baden");
7572

7673

77-
78-
7974
}
8075

8176
public function getCustomTag($item, $tag)

app/Console/Commands/api/Bayern.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ public function handle()
6262
dump("Loading $city events");
6363
$force = $this->option('force');
6464

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

67-
$json = $response->json();
68-
69-
if (is_null($json)){
67+
if (is_null($json)) {
7068
Log::info("!!! No data in feed from $city API:");
7169
return 0;
7270
}

app/Console/Commands/api/Berlin.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ public function handle()
6262
dump("Loading $city events");
6363
$force = $this->option('force');
6464

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

67-
$json = $response->json();
68-
69-
if (is_null($json)){
67+
if (is_null($json)) {
7068
Log::info("!!! No data in feed from $city API:");
7169
return 0;
7270
}

app/Console/Commands/api/Bonn.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ public function handle()
5959
$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";
6060
dump("Loading $city events");
6161

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

64-
$json = $response->json();
65-
66-
if (is_null($json)){
64+
if (is_null($json)) {
6765
Log::info("!!! No data in feed from $city API:");
6866
return 0;
6967
}

app/Console/Commands/api/Bremen.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ public function handle()
5858
$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";
5959
dump("Loading $city events");
6060

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

63-
$json = $response->json();
64-
65-
if (is_null($json)){
63+
if (is_null($json)) {
6664
Log::info("!!! No data in feed from $city API:");
6765
return 0;
6866
}

app/Console/Commands/api/Dresden.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ public function handle()
5858
$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";
5959
dump("Loading $city events");
6060

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

63-
$json = $response->json();
64-
65-
if (is_null($json)){
63+
if (is_null($json)) {
6664
Log::info("!!! No data in feed from $city API:");
6765
return 0;
6866
}

app/Console/Commands/api/GermanTraits.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212

1313
trait GermanTraits
1414
{
15+
16+
private function loadJson($url){
17+
$client = new \GuzzleHttp\Client();
18+
$guzzle = $client->request('get', $url);
19+
20+
return json_decode($guzzle->getBody(), true);
21+
}
1522
/**
1623
* @param $json
1724
*/
@@ -25,7 +32,6 @@ private function createRSSItem($json, $city): void
2532
$className = '\App\RSSItems\\' . $city . 'RSSItem';
2633
$RSSitem = new $className;
2734

28-
2935
$RSSitem->uid = $item['uid'];
3036
$RSSitem->title = $item['title'];
3137
$RSSitem->description = $item['description'];
@@ -41,7 +47,7 @@ private function createRSSItem($json, $city): void
4147
$RSSitem->user_publicEmail = $item['user']['publicEmail'];
4248
$RSSitem->user_type = $item['user']['type']['identifier'] ?? '';
4349
$RSSitem->user_website = $item['user']['www'];
44-
$RSSitem->activity_type = $item['type']['identifier'];
50+
$RSSitem->activity_type = $item['type']['identifier'] ?? 'invite-in-person';
4551
$RSSitem->tags = trim(implode(";", Arr::pluck($item['tags'], 'title')));
4652
$RSSitem->themes = trim(implode(",", Arr::pluck($item['themes'], 'identifier')));
4753
$RSSitem->audience = trim(implode(",", Arr::pluck($item['audience'], 'identifier')));

app/Console/Commands/api/Hamburg.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ public function handle()
6161
dump("Loading $city events");
6262
$force = $this->option('force');
6363

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

66-
$json = $response->json();
67-
68-
if (is_null($json)){
66+
if (is_null($json)) {
6967
Log::info("!!! No data in feed from $city API:");
7068
return 0;
7169
}

app/Console/Commands/api/Leipzig.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ public function handle()
6363
dump("Loading $city events");
6464
$force = $this->option('force');
6565

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

68-
$json = $response->json();
69-
70-
if (is_null($json)){
68+
if (is_null($json)) {
7169
Log::info("!!! No data in feed from $city API:");
7270
return 0;
7371
}

app/Console/Commands/api/Muensterland.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ public function handle()
5858
$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";
5959
dump("Loading $city events");
6060

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

63-
$json = $response->json();
6463

65-
if (is_null($json)){
64+
65+
if (is_null($json)) {
6666
Log::info("!!! No data in feed from $city API:");
6767
return 0;
6868
}

0 commit comments

Comments
 (0)