Skip to content

Commit

Permalink
Driver Rating, LoadBoard Filtering,
Browse files Browse the repository at this point in the history
  • Loading branch information
nkamuo committed Oct 8, 2023
1 parent 6a8c030 commit 8636289
Show file tree
Hide file tree
Showing 16 changed files with 476 additions and 12 deletions.
1 change: 1 addition & 0 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ framework:
Symfony\Component\Mailer\Messenger\SendEmailMessage: async
Symfony\Component\Notifier\Message\ChatMessage: async
Symfony\Component\Notifier\Message\SmsMessage: async
App\Message\Account\CalculateDriverRating: async

# Route your messages to the transports
# 'App\Message\YourMessage': async
31 changes: 31 additions & 0 deletions migrations/Version20231008174204.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231008174204 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE shipment_order ADD pickedup_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE shipment_order DROP pickedup_at, DROP delivered_at');
}
}
31 changes: 31 additions & 0 deletions migrations/Version20231008213009.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231008213009 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE driver ADD review_rating NUMERIC(2, 1) DEFAULT NULL, ADD review_count INT DEFAULT 0 NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE driver DROP review_rating, DROP review_count');
}
}
14 changes: 14 additions & 0 deletions src/Entity/Account/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class Driver
#[ORM\OneToOne(inversedBy: 'driver', cascade: ['persist', 'remove'])]
private ?DriverLicense $drivingLicense = null;

#[GQL\Field()]
#[ORM\Embedded(columnPrefix: 'review_')]
private ?ReviewSummary $review = null;

public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
Expand Down Expand Up @@ -179,4 +183,14 @@ public function setDrivingLicense(?DriverLicense $drivingLicense): static

return $this;
}


public function getReview(): ?ReviewSummary{
return $this->review;
}

public function setReview(ReviewSummary $review): static{
$this->review = $review;
return $this;
}
}
49 changes: 49 additions & 0 deletions src/Entity/Account/ReviewSummary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\Entity\Account;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Overblog\GraphQLBundle\Annotation as GQL;

#[GQL\Type()]
#[ORM\Embeddable()]
class ReviewSummary
{

#[GQL\Field(type:'Float')]
#[ORM\Column(type: Types::DECIMAL, precision: 2, scale: 1, nullable: true)]
private ?string $rating = null;

#[GQL\Field()]
#[ORM\Column(
options:[
'default' => 0
]
)]
private ?int $count = 0;

public function getRating(): ?string
{
return $this->rating;
}

public function setRating(?string $rating): static
{
$this->rating = $rating;

return $this;
}

public function getCount(): ?int
{
return $this->count;
}

public function setCount(int $count): static
{
$this->count = $count;

return $this;
}
}
32 changes: 32 additions & 0 deletions src/Entity/Shipment/ShipmentOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ class ShipmentOrder
#[ORM\Column]
private ?int $documentsCount = 0;

#[GQL\Field(type: 'DateTime')]
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $pickedupAt = null;

#[GQL\Field(type: 'DateTime')]
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deliveredAt = null;


public function __construct()
{
Expand Down Expand Up @@ -518,4 +526,28 @@ public function getDocumentsCount(): ?int
{
return $this->documentsCount;
}

public function getPickedupAt(): ?\DateTimeImmutable
{
return $this->pickedupAt;
}

public function setPickedupAt(?\DateTimeImmutable $pickedupAt): static
{
$this->pickedupAt = $pickedupAt;

return $this;
}

public function getDeliveredAt(): ?\DateTimeImmutable
{
return $this->deliveredAt;
}

public function setDeliveredAt(?\DateTimeImmutable $deliveredAt): static
{
$this->deliveredAt = $deliveredAt;

return $this;
}
}
6 changes: 6 additions & 0 deletions src/GraphQL/Shipment/Resolver/ClientShipmentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\GraphQL\Shipment\Resolver;

use App\CQRS\CommandBusInterface;
use App\Entity\Account\User;
use App\Entity\Addressing\UserAddress;
use App\Entity\Catalog\UserProduct;
Expand All @@ -23,6 +24,7 @@
use App\GraphQL\Shipment\Type\ShipmentDriverBidConnection;
use App\GraphQL\Shipment\Type\ShipmentDriverBidEdge;
use App\GraphQL\Shipment\Type\ShipmentEdge;
use App\Message\Account\CalculateDriverRating;
use App\Repository\Addressing\UserAddressRepository;
use App\Repository\Catalog\UserProductRepository;
use App\Repository\Shipment\Assessment\AssessmentParameterRepository;
Expand Down Expand Up @@ -63,6 +65,7 @@ public function __construct(
private AssessmentParameterRepository $assessmentParameterRepository,
private DirectionsServiceInterface $directionsService,
private CodeGeneratorInterface $codeGenerator,
private CommandBusInterface $commandBus,
) {
}

Expand Down Expand Up @@ -301,6 +304,9 @@ public function reviewShipment(Ulid $id, ?ShipmentOrderReviewInput $input): Ship
$this->entityManager->persist($shipment);
$this->entityManager->flush();

$driver = $order->getDriver();
$this->commandBus->dispatch(new CalculateDriverRating($driver));

return $shipment;
}

Expand Down
2 changes: 2 additions & 0 deletions src/GraphQL/Shipment/Resolver/DriverShipmentOrderResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public function executeShipmentOrderPickup(Ulid $id, ShipmentOrderNodeExecutionI
input: $input->document,
);
$order->setPickupConfirmation($document);
$order->setPickedupAt(new DateTimeImmutable());
$order->setStatus(ShipmentOrderStatus::INTRANSIT);
$shipment->setStatus(ShipmentStatus::INTRANSIT);

Expand Down Expand Up @@ -264,6 +265,7 @@ public function executeShipmentOrderDelivery(Ulid $id, ShipmentOrderNodeExecutio
input: $input->document,
);
$order->setProofOfDelivery($document);
$order->setDeliveredAt(new DateTimeImmutable());
$order->setStatus(ShipmentOrderStatus::DELIVERED);
$shipment->setStatus(ShipmentStatus::DELIVERED);

Expand Down
Loading

0 comments on commit 8636289

Please sign in to comment.