Skip to content

feat(marketplace): add new get drivers endpoint#518

Open
smarcet wants to merge 1 commit intoproduction_oiffrom
feature/marketplace-drivers-api
Open

feat(marketplace): add new get drivers endpoint#518
smarcet wants to merge 1 commit intoproduction_oiffrom
feature/marketplace-drivers-api

Conversation

@smarcet
Copy link
Collaborator

@smarcet smarcet commented Mar 12, 2026

GET /api/public/v1/marketplace/drivers

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e0805544-0ab3-40f4-90ff-d8b9bc6c43cc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/marketplace-drivers-api

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new public Marketplace API endpoint to list “drivers” (with filtering/ordering and optional release expansion), along with the underlying Doctrine entities/repository and serializers.

Changes:

  • Added GET /api/public/v1/marketplace/drivers route and DriversApiController@getAll implementation.
  • Introduced Driver / DriverRelease Doctrine entities plus IDriverRepository + DoctrineDriverRepository with active-only filtering and release join filtering.
  • Registered new serializers (DriverSerializer, DriverReleaseSerializer) and added an integration-style BrowserKit test suite for the endpoint.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/OAuth2DriversApiTest.php Adds integration tests covering list, filtering, ordering, and expand=releases.
routes/public_api.php Wires the new public marketplace drivers route to the controller.
app/Repositories/RepositoriesProvider.php Registers the driver repository binding in the container.
app/Repositories/Marketplace/DoctrineDriverRepository.php Implements filter/order mappings and an “active drivers only” constraint.
app/Models/Foundation/Marketplace/IDriverRepository.php Adds the repository interface for drivers.
app/Models/Foundation/Marketplace/DriverRelease.php Adds the DriverRelease entity and its relationship back to drivers.
app/Models/Foundation/Marketplace/Driver.php Adds the Driver entity plus many-to-many releases association and active-release getter.
app/ModelSerializers/SerializerRegistry.php Registers new serializers in the global registry.
app/ModelSerializers/Marketplace/DriverSerializer.php Defines the public serialization shape for drivers and release expansion mapping.
app/ModelSerializers/Marketplace/DriverReleaseSerializer.php Defines the public serialization shape for driver releases.
app/Http/Controllers/Apis/Marketplace/DriversApiController.php Adds the new public “get all drivers” endpoint using ParametrizedGetAll.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

use App\Models\Foundation\Main\Repositories\ISupportingCompanyRepository;
use App\Models\Foundation\Main\Repositories\IUserStoryRepository;
use App\Models\Foundation\Marketplace\ICompanyServiceRepository;
use App\Models\Foundation\Marketplace\IDriverRepository;
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDriverRepository is imported but not used (the singleton binding below uses the interface as a quoted string). Either switch the binding to use IDriverRepository::class (to leverage the import and refactor-safety) or drop the unused use App\Models\Foundation\Marketplace\IDriverRepository; import.

Suggested change
use App\Models\Foundation\Marketplace\IDriverRepository;

Copilot uses AI. Check for mistakes.
Comment on lines +129 to +133
// clean junction table first, then entities
DB::connection('model')->delete("DELETE FROM Driver_Releases");
DB::connection('model')->delete("DELETE FROM Driver WHERE Name LIKE 'Test Driver%' OR Name = 'Inactive Driver'");
DB::connection('model')->delete("DELETE FROM DriverRelease WHERE Name IN ('Rocky','Stein')");
if (isset(self::$em) && self::$em->isOpen()) {
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearDriverTestData() deletes all rows from Driver_Releases and deletes DriverRelease rows by real release names ('Rocky', 'Stein'). This can wipe seeded/shared data and make the test flaky/order-dependent. Please scope cleanup to only the rows created by this test (eg, use unique test-only release names and delete only junction rows referencing the persisted test IDs), or remove entities via the EntityManager instead of blanket SQL deletes.

Suggested change
// clean junction table first, then entities
DB::connection('model')->delete("DELETE FROM Driver_Releases");
DB::connection('model')->delete("DELETE FROM Driver WHERE Name LIKE 'Test Driver%' OR Name = 'Inactive Driver'");
DB::connection('model')->delete("DELETE FROM DriverRelease WHERE Name IN ('Rocky','Stein')");
if (isset(self::$em) && self::$em->isOpen()) {
if (isset(self::$em) && self::$em->isOpen()) {
// remove only the entities created by this test
$entities = [
self::$driver1,
self::$driver2,
self::$inactiveDriver,
self::$release1,
self::$release2,
];
foreach ($entities as $entity) {
if ($entity instanceof SilverstripeBaseModel) {
$id = $entity->getId();
if ($id > 0) {
$managed = self::$em->find(get_class($entity), $id);
if (null !== $managed) {
self::$em->remove($managed);
}
}
}
}
self::$em->flush();

Copilot uses AI. Check for mistakes.
'type' => Many2OneExpandSerializer::class,
'getter' => 'getReleases',
],
];
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DriverSerializer declares releases in $allowed_relations, but unlike other serializers for collection relations (eg TrainingServiceSerializer), it doesn’t add a releases field containing related IDs when relations=releases is requested. As a result, clients asking for relation IDs may get no releases attribute unless they use expand=releases. Consider overriding serialize() to include the release IDs when releases is in $relations (mirroring the pattern used in TrainingServiceSerializer).

Suggested change
];
];
/**
* @param null|string $expand
* @param array $fields
* @param array $relations
* @param array $params
* @return array
*/
public function serialize($expand = null, array $fields = [], array $relations = [], array $params = [])
{
$values = parent::serialize($expand, $fields, $relations, $params);
$driver = $this->object;
if (is_null($driver)) {
return $values;
}
if (in_array('releases', $relations) && !isset($values['releases'])) {
$values['releases'] = [];
foreach ($driver->getReleases() as $release) {
$values['releases'][] = (int)$release->getId();
}
}
return $values;
}

Copilot uses AI. Check for mistakes.
@smarcet smarcet force-pushed the feature/marketplace-drivers-api branch from b100a31 to 718a091 Compare March 12, 2026 02:07
GET /api/public/v1/marketplace/drivers
@smarcet smarcet force-pushed the feature/marketplace-drivers-api branch from 718a091 to 5bba0da Compare March 12, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants