Skip to content

Commit 0bd74c5

Browse files
authored
fix: local time (#284)
1 parent abff78a commit 0bd74c5

8 files changed

Lines changed: 54 additions & 28 deletions

File tree

.env

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@ APP_ENV=dev
33
APP_DEBUG=1
44
APP_SECRET=67d829bf61dc5f87a73fd814e2c9f622
55
###< symfony/framework-bundle ###
6-
7-
# meetup.com api - from https://www.meetup.com/api/oauth/list/ - complete in .env.local
8-
MEETUP_COM_OAUTH_KEY=
9-
MEETUP_COM_OAUTH_SECRET=

.github/workflows/rector.yaml

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

1313
steps:
1414
- uses: actions/checkout@v6
15-
with:
16-
token: ${{ secrets.ACCESS_TOKEN || github.token }}
1715

1816
- uses: shivammathur/setup-php@v2
1917
with:

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ cd friendsofphp.org
1919
composer install
2020
```
2121

22-
- Copy `.env` to `.env.local`
23-
- Add your [Meetup.com API keys](https://secure.meetup.com/meetup_api/oauth_consumers/):
24-
25-
```dotenv
26-
# .env.local
27-
MEETUP_COM_OAUTH_KEY=...
28-
MEETUP_COM_OAUTH_SECRET=...
29-
```
30-
3122
- Update Meetup Data
3223

3324
```bash

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"sort-packages": true,
6363
"allow-plugins": {
6464
"phpstan/extension-installer": true
65+
},
66+
"platform": {
67+
"php": "8.3"
6568
}
6669
},
6770
"minimum-stability": "dev",

src/MeetupCom/Meetup/MeetupComMeetupFactory.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ public function createFromData(array $data): ?Meetup
5151
$dateTimeImmutable = new DateTimeImmutable($data['startDate']);
5252

5353
return new Meetup(
54-
$name,
55-
html_entity_decode((string) $data[self::GROUP][self::NAME]),
56-
$dateTimeImmutable->setTimezone(new DateTimeZone('UTC')),
57-
$dateTimeImmutable->format('Y-m-d'),
58-
$dateTimeImmutable->format('H:i'),
59-
$data['url'],
60-
$location->getCity(),
61-
$location->getCountry(),
62-
$location->getCoordinateLatitude(),
63-
$location->getCoordinateLongitude(),
54+
name: $name,
55+
userGroupName: html_entity_decode((string) $data[self::GROUP][self::NAME]),
56+
utcStartDateTime: $dateTimeImmutable->setTimezone(new DateTimeZone('UTC')),
57+
localDate: $dateTimeImmutable->format('Y-m-d'),
58+
localTime: $dateTimeImmutable->format('H:i'),
59+
url: $data['url'],
60+
city: $location->getCity(),
61+
country: $location->getCountry(),
62+
latitude: $location->getCoordinateLatitude(),
63+
longitude: $location->getCoordinateLongitude(),
6464
);
6565
}
6666

src/MeetupCom/MeetupComCrawler.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public function getMeetupsByGroupSlug(string $groupSlug): array
3939
continue;
4040
}
4141

42+
if (! isset($schema['url'])) {
43+
continue;
44+
}
45+
4246
if (! isset($schema['organizer']['url'])) {
4347
continue;
4448
}
@@ -47,7 +51,21 @@ public function getMeetupsByGroupSlug(string $groupSlug): array
4751
continue;
4852
}
4953

50-
$data[] = $schema;
54+
$crawler = $this->httpBrowser->request('GET', $schema['url']);
55+
$innerStructuredDataElements = $crawler->filter('script[type="application/ld+json"]');
56+
57+
foreach ($innerStructuredDataElements as $innerStructuredDataElement) {
58+
$innerSchema = Json::decode($innerStructuredDataElement->textContent, Json::FORCE_ARRAY);
59+
if (! isset($innerSchema['@type'])) {
60+
continue;
61+
}
62+
63+
if ($innerSchema['@type'] !== 'Event') {
64+
continue;
65+
}
66+
67+
$data[] = $innerSchema;
68+
}
5169
}
5270
}
5371

tests/MeetupCom/MeetupComCrawlerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ public function testGetMeetupsByGroupSlug(): void
1717
{
1818
// Arrange
1919
$smartFileSystem = new SmartFileSystem();
20-
$mockResponse = new MockResponse($smartFileSystem->readFile(__DIR__ . '/fixtures/meetup_events.html'));
21-
$mockHttpClient = new MockHttpClient([$mockResponse]);
20+
$mockResponseList = new MockResponse($smartFileSystem->readFile(__DIR__ . '/fixtures/meetup_events.html'));
21+
$mockResponseDetail = new MockResponse($smartFileSystem->readFile(__DIR__ . '/fixtures/meetup_detail.html'));
22+
$mockHttpClient = new MockHttpClient([$mockResponseList, $mockResponseDetail]);
2223
$httpBrowser = new HttpBrowser($mockHttpClient);
2324
$meetupComCrawler = new MeetupComCrawler($httpBrowser);
2425

tests/MeetupCom/fixtures/meetup_detail.html

Lines changed: 19 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)