Skip to content

Commit

Permalink
Merge pull request #99 from fleetbase/dev-v0.4.22
Browse files Browse the repository at this point in the history
v0.4.222
  • Loading branch information
roncodes authored Mar 19, 2024
2 parents 90dad6b + 29328b6 commit db46be9
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/fleetops-api",
"version": "0.4.21",
"version": "0.4.22",
"description": "Fleet & Transport Management Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Fleet-Ops",
"version": "0.4.21",
"version": "0.4.22",
"description": "Fleet & Transport Management Extension for Fleetbase",
"repository": "https://github.com/fleetbase/fleetops",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/fleetops-engine",
"version": "0.4.21",
"version": "0.4.22",
"description": "Fleet & Transport Management Extension for Fleetbase",
"fleetbase": {
"route": "fleet-ops"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function handle()
['model' => \Fleetbase\FleetOps\Models\Order::class, 'columns' => ['customer_type', 'facilitator_type']],
['model' => \Fleetbase\FleetOps\Models\Place::class, 'columns' => ['owner_type']],
['model' => \Fleetbase\FleetOps\Models\Entity::class, 'columns' => ['customer_type']],
['model' => \Fleetbase\FleetOps\Models\PurchaseRate::class, 'columns' => ['customer_type']],
];

foreach ($models as $modelConfig) {
Expand Down
24 changes: 21 additions & 3 deletions server/src/Console/Commands/TrackOrderDistanceAndTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public function handle()
date_default_timezone_set('UTC');

// Determine the provider
$provider = $this->option('provider') ?? config('fleetops.distance_matrix.provider');
$provider = $this->option('provider');
if (!$provider) {
$provider = config('fleetops.distance_matrix.provider');
}
$this->info("Using '{$provider}' as the provider for calculations.");

// Get all active/ready orders
Expand All @@ -60,15 +63,30 @@ public function handle()
}

/**
* Fetches active orders.
* Retrieves active orders that meet specific criteria.
*
* This method returns a collection of active orders with the following conditions:
* - Not in 'completed' or 'canceled' status.
* - Not marked as deleted (`deleted_at` is null).
* - Associated with a company (`company_uuid` is not null).
* - The order process has started (`started` is not null).
* - Contains a payload (`payload` relationship exists).
* - Created within the past month.
*
* @return \Illuminate\Database\Eloquent\Collection
* The result includes related payload data, waypoints, and information about pickup and dropoff points.
* Global scopes are not applied to this query.
*
* @return \Illuminate\Database\Eloquent\Collection collection of relevant Order objects
*/
protected function getActiveOrders()
{
$oneMonthAgo = Carbon::now()->subMonth();

return Order::whereNotIn('status', ['completed', 'canceled'])
->whereNull('deleted_at')
->whereNotNull('company_uuid')
->whereNotNull('started')
->where('created_at', '>=', $oneMonthAgo)
->whereHas('payload')
->with(['payload', 'payload.waypoints', 'payload.pickup', 'payload.dropoff'])
->withoutGlobalScopes()
Expand Down
6 changes: 4 additions & 2 deletions server/src/Models/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Fleetbase\FleetOps\Models;

use Fleetbase\Casts\Json;
use Fleetbase\Casts\PolymorphicType;
use Fleetbase\FleetOps\Casts\Point;
use Fleetbase\FleetOps\Support\Geocoding;
use Fleetbase\FleetOps\Support\Utils;
Expand Down Expand Up @@ -114,8 +115,9 @@ class Place extends Model
* @var array
*/
protected $casts = [
'meta' => Json::class,
'location' => Point::class,
'meta' => Json::class,
'location' => Point::class,
'owner_type' => PolymorphicType::class,
];

/**
Expand Down
4 changes: 3 additions & 1 deletion server/src/Models/PurchaseRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Fleetbase\FleetOps\Models;

use Fleetbase\Casts\Json;
use Fleetbase\Casts\PolymorphicType;
use Fleetbase\FleetOps\Support\Utils;
use Fleetbase\Models\Model;
use Fleetbase\Traits\HasApiModelBehavior;
Expand Down Expand Up @@ -57,7 +58,8 @@ class PurchaseRate extends Model
* @var array
*/
protected $casts = [
'meta' => Json::class,
'meta' => Json::class,
'customer_type' => PolymorphicType::class,
];

/**
Expand Down

0 comments on commit db46be9

Please sign in to comment.