Fix error with not unique bus service name.
This commit is contained in:
parent
85d65e3996
commit
11356a84a2
77
composer.lock
generated
77
composer.lock
generated
@ -286,16 +286,16 @@
|
||||
},
|
||||
{
|
||||
"name": "doctrine/common",
|
||||
"version": "v2.11.0",
|
||||
"version": "2.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/common.git",
|
||||
"reference": "b8ca1dcf6b0dc8a2af7a09baac8d0c48345df4ff"
|
||||
"reference": "2053eafdf60c2172ee1373d1b9289ba1db7f1fc6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/common/zipball/b8ca1dcf6b0dc8a2af7a09baac8d0c48345df4ff",
|
||||
"reference": "b8ca1dcf6b0dc8a2af7a09baac8d0c48345df4ff",
|
||||
"url": "https://api.github.com/repos/doctrine/common/zipball/2053eafdf60c2172ee1373d1b9289ba1db7f1fc6",
|
||||
"reference": "2053eafdf60c2172ee1373d1b9289ba1db7f1fc6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -365,20 +365,20 @@
|
||||
"doctrine",
|
||||
"php"
|
||||
],
|
||||
"time": "2019-09-10T10:10:14+00:00"
|
||||
"time": "2020-01-10T15:49:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/dbal",
|
||||
"version": "v2.10.0",
|
||||
"version": "v2.10.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/dbal.git",
|
||||
"reference": "0c9a646775ef549eb0a213a4f9bd4381d9b4d934"
|
||||
"reference": "c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/dbal/zipball/0c9a646775ef549eb0a213a4f9bd4381d9b4d934",
|
||||
"reference": "0c9a646775ef549eb0a213a4f9bd4381d9b4d934",
|
||||
"url": "https://api.github.com/repos/doctrine/dbal/zipball/c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8",
|
||||
"reference": "c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -457,7 +457,7 @@
|
||||
"sqlserver",
|
||||
"sqlsrv"
|
||||
],
|
||||
"time": "2019-11-03T16:50:43+00:00"
|
||||
"time": "2020-01-04T12:56:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/doctrine-bundle",
|
||||
@ -972,16 +972,16 @@
|
||||
},
|
||||
{
|
||||
"name": "doctrine/migrations",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/migrations.git",
|
||||
"reference": "8e124252d2f6be1124017d746d5994dd4095d66f"
|
||||
"reference": "a3987131febeb0e9acb3c47ab0df0af004588934"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/migrations/zipball/8e124252d2f6be1124017d746d5994dd4095d66f",
|
||||
"reference": "8e124252d2f6be1124017d746d5994dd4095d66f",
|
||||
"url": "https://api.github.com/repos/doctrine/migrations/zipball/a3987131febeb0e9acb3c47ab0df0af004588934",
|
||||
"reference": "a3987131febeb0e9acb3c47ab0df0af004588934",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1050,7 +1050,7 @@
|
||||
"migrations",
|
||||
"php"
|
||||
],
|
||||
"time": "2019-11-13T11:06:31+00:00"
|
||||
"time": "2019-12-04T06:09:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
@ -1137,16 +1137,16 @@
|
||||
},
|
||||
{
|
||||
"name": "doctrine/persistence",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/persistence.git",
|
||||
"reference": "99b196bbd4715a94fa100fac664a351ffa46d6a5"
|
||||
"reference": "ff7e08b0f814be2cd20c52dc3c8a262579376b94"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/persistence/zipball/99b196bbd4715a94fa100fac664a351ffa46d6a5",
|
||||
"reference": "99b196bbd4715a94fa100fac664a351ffa46d6a5",
|
||||
"url": "https://api.github.com/repos/doctrine/persistence/zipball/ff7e08b0f814be2cd20c52dc3c8a262579376b94",
|
||||
"reference": "ff7e08b0f814be2cd20c52dc3c8a262579376b94",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1216,20 +1216,20 @@
|
||||
"orm",
|
||||
"persistence"
|
||||
],
|
||||
"time": "2019-12-13T10:43:02+00:00"
|
||||
"time": "2020-01-09T19:49:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/reflection",
|
||||
"version": "v1.0.0",
|
||||
"version": "v1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/reflection.git",
|
||||
"reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6"
|
||||
"reference": "bc420ead87fdfe08c03ecc3549db603a45b06d4c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/reflection/zipball/02538d3f95e88eb397a5f86274deb2c6175c2ab6",
|
||||
"reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6",
|
||||
"url": "https://api.github.com/repos/doctrine/reflection/zipball/bc420ead87fdfe08c03ecc3549db603a45b06d4c",
|
||||
"reference": "bc420ead87fdfe08c03ecc3549db603a45b06d4c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1237,13 +1237,15 @@
|
||||
"ext-tokenizer": "*",
|
||||
"php": "^7.1"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": "<2.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^4.0",
|
||||
"doctrine/common": "^2.8",
|
||||
"phpstan/phpstan": "^0.9.2",
|
||||
"phpstan/phpstan-phpunit": "^0.9.4",
|
||||
"phpunit/phpunit": "^7.0",
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
"doctrine/coding-standard": "^5.0",
|
||||
"doctrine/common": "^2.10",
|
||||
"phpstan/phpstan": "^0.11.0",
|
||||
"phpstan/phpstan-phpunit": "^0.11.0",
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -1261,6 +1263,10 @@
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
@ -1269,10 +1275,6 @@
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
@ -1286,12 +1288,13 @@
|
||||
"email": "ocramius@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Doctrine Reflection component",
|
||||
"description": "The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functionality on top of the reflection functionality that comes with PHP. It allows you to get the reflection information about classes, methods and properties statically.",
|
||||
"homepage": "https://www.doctrine-project.org/projects/reflection.html",
|
||||
"keywords": [
|
||||
"reflection"
|
||||
"reflection",
|
||||
"static"
|
||||
],
|
||||
"time": "2018-06-14T14:45:07+00:00"
|
||||
"time": "2020-01-08T19:53:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "exsyst/swagger",
|
||||
|
@ -54,7 +54,7 @@ class DeparturesController extends Controller
|
||||
*
|
||||
* @SWG\Parameter(
|
||||
* name="limit",
|
||||
* description="Max departures count",
|
||||
* description="Max departures count.",
|
||||
* type="integer",
|
||||
* in="query"
|
||||
* )
|
||||
|
@ -21,7 +21,7 @@ class StopInTrack implements Fillable
|
||||
private $stop;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=TrackEntity::class, fetch="EAGER")
|
||||
* @ORM\ManyToOne(targetEntity=TrackEntity::class, fetch="EAGER", inversedBy="stopsInTrack")
|
||||
* @ORM\Id
|
||||
*/
|
||||
private $track;
|
||||
|
@ -46,6 +46,7 @@ class TrackEntity implements Entity, Fillable
|
||||
* Stops in track
|
||||
* @var Collection
|
||||
* @ORM\OneToMany(targetEntity=StopInTrack::class, fetch="LAZY", mappedBy="track", cascade={"persist"})
|
||||
* @ORM\OrderBy({"order": "ASC"})
|
||||
*/
|
||||
private $stopsInTrack;
|
||||
|
||||
|
@ -5,6 +5,7 @@ namespace App\Provider\Database;
|
||||
use App\Entity\StopEntity;
|
||||
use App\Entity\StopInTrack;
|
||||
use App\Entity\TrackEntity;
|
||||
use App\Entity\TripEntity;
|
||||
use App\Entity\TripStopEntity;
|
||||
use App\Model\Departure;
|
||||
use App\Model\Line;
|
||||
@ -26,9 +27,9 @@ class GenericScheduleRepository extends DatabaseRepository implements ScheduleRe
|
||||
->createQueryBuilder()
|
||||
->select('ts', 't')
|
||||
->from(TripStopEntity::class, 'ts')
|
||||
->join('ts.trip', 't')
|
||||
->where('ts.departure >= :from')
|
||||
->andWhere('ts.stop = :stop')
|
||||
->join('ts.trip', 't')
|
||||
->orderBy('ts.departure', 'ASC')
|
||||
->setMaxResults($count)
|
||||
->getQuery();
|
||||
@ -44,7 +45,6 @@ class GenericScheduleRepository extends DatabaseRepository implements ScheduleRe
|
||||
->join('t.stopsInTrack', 's')
|
||||
->join('s.stop', 'st')
|
||||
->where('t.id in (:tracks)')
|
||||
->orderBy('s.order', 'DESC')
|
||||
->getQuery()
|
||||
->execute([
|
||||
':tracks' => $schedule->map(function (TripStopEntity $stop) {
|
||||
|
@ -65,6 +65,8 @@ class ZtmGdanskDataUpdateSubscriber implements EventSubscriberInterface
|
||||
|
||||
public function update(DataUpdateEvent $event)
|
||||
{
|
||||
ini_set('memory_limit', '2G');
|
||||
|
||||
$output = $event->getOutput();
|
||||
|
||||
$provider = ProviderEntity::createFromArray([
|
||||
@ -172,8 +174,6 @@ class ZtmGdanskDataUpdateSubscriber implements EventSubscriberInterface
|
||||
|
||||
public function getTracks(ProviderEntity $provider, DataUpdateEvent $event, $stops = [])
|
||||
{
|
||||
ini_set('memory_limit', '2G');
|
||||
|
||||
$output = $event->getOutput();
|
||||
|
||||
$output->write('Obtaining tracks from ZTM Gdańsk... ');
|
||||
@ -231,8 +231,8 @@ class ZtmGdanskDataUpdateSubscriber implements EventSubscriberInterface
|
||||
$schedule = JsonObjects::from($url, 'stopTimes.*');
|
||||
$trips = new Collection();
|
||||
|
||||
$schedule->each(function ($stop) use ($provider, &$trips) {
|
||||
$id = sprintf('%s-%d', $stop['busServiceName'], $stop['order']);
|
||||
$schedule->each(function ($stop) use ($provider, $line, &$trips, &$ids) {
|
||||
$id = sprintf('%s-%s-%d', $stop['busServiceName'], $stop['tripId'], $stop['order']);
|
||||
$trip = $trips[$id] ?? $trips[$id] = (function () use ($stop, $id, $provider) {
|
||||
$trip = TripEntity::createFromArray([
|
||||
'id' => $this->ids->generate($provider, $id),
|
||||
@ -252,7 +252,7 @@ class ZtmGdanskDataUpdateSubscriber implements EventSubscriberInterface
|
||||
})();
|
||||
|
||||
$base = Carbon::create(1899, 12, 30, 00, 00, 00);
|
||||
$date = Carbon::createFromFormat('Y-m-d', $stop['date'])->setTime(00, 00, 00);
|
||||
$date = Carbon::createFromFormat('Y-m-d', $stop['date'], 'Europe/Warsaw')->setTime(00, 00, 00);
|
||||
|
||||
$arrival = $base->diff(Carbon::createFromTimeString($stop['arrivalTime']));
|
||||
$departure = $base->diff(Carbon::createFromTimeString($stop['departureTime']));
|
||||
@ -267,11 +267,12 @@ class ZtmGdanskDataUpdateSubscriber implements EventSubscriberInterface
|
||||
$this->ids->generate($provider, $stop['stopId'])
|
||||
),
|
||||
'order' => $stop['stopSequence'],
|
||||
'arrival' => $arrival,
|
||||
'departure' => $departure,
|
||||
'arrival' => $arrival->tz('UTC'),
|
||||
'departure' => $departure->tz('UTC'),
|
||||
]);
|
||||
|
||||
$entity->setTrip($trip);
|
||||
|
||||
$this->em->persist($entity);
|
||||
});
|
||||
|
||||
|
@ -12,6 +12,7 @@ use App\Provider\LineRepository;
|
||||
use App\Provider\ScheduleRepository;
|
||||
use App\Service\Proxy\ReferenceFactory;
|
||||
use Carbon\Carbon;
|
||||
use JMS\Serializer\Tests\Fixtures\Discriminator\Car;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
use Kadet\Functional\Transforms as t;
|
||||
|
||||
@ -41,7 +42,9 @@ class ZtmGdanskDepartureRepository implements DepartureRepository
|
||||
public function getForStop(Stop $stop): Collection
|
||||
{
|
||||
$real = $this->getRealDepartures($stop);
|
||||
$scheduled = $this->getScheduledDepartures($stop, $real->isNotEmpty());
|
||||
$now = Carbon::now();
|
||||
$first = $real->map(t\getter('scheduled'))->min() ?? $now;
|
||||
$scheduled = $this->getScheduledDepartures($stop, $first < $now ? $now : $first);
|
||||
|
||||
return $this->pair($scheduled, $real);
|
||||
}
|
||||
@ -74,12 +77,9 @@ class ZtmGdanskDepartureRepository implements DepartureRepository
|
||||
})->values();
|
||||
}
|
||||
|
||||
private function getScheduledDepartures(Stop $stop, bool $hasRealData = true)
|
||||
private function getScheduledDepartures(Stop $stop, Carbon $time)
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
// If we have real data we skip 5 minutes, because sometimes trams or buses get out too quickly.
|
||||
return $this->schedule->getDeparturesForStop($stop, $hasRealData ? $now->addMinutes(5) : $now);
|
||||
return $this->schedule->getDeparturesForStop($stop, $time);
|
||||
}
|
||||
|
||||
private function pair(Collection $schedule, Collection $real)
|
||||
|
@ -73,7 +73,7 @@ final class CarbonHandler implements SubscribingHandlerInterface
|
||||
array $type,
|
||||
SerializationContext $context
|
||||
) {
|
||||
return $this->dateTimeHandler->serializeDateTime($visitor, $date, $type, $context);
|
||||
return $this->dateTimeHandler->serializeDateTime($visitor, $date->tz('Europe/Warsaw'), $type, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user