From 18b19fd90abaf8c181ca4825119bbf86e3e28ef3 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Sat, 11 Sep 2021 17:26:02 +0800 Subject: [PATCH 01/11] Join table from frontend --- .../General/Eloquent/AbstractGetRecord.php | 18 +++++++++-- .../General/Eloquent/AbstractListRecord.php | 31 +++++++++++++++++-- .../orders/elements/ParcelComponent.vue | 2 +- .../views/pages/warehouse_list.blade.php | 4 +-- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/app/Classes/General/Eloquent/AbstractGetRecord.php b/app/Classes/General/Eloquent/AbstractGetRecord.php index f927d818..e2972eb0 100644 --- a/app/Classes/General/Eloquent/AbstractGetRecord.php +++ b/app/Classes/General/Eloquent/AbstractGetRecord.php @@ -12,6 +12,8 @@ abstract class AbstractGetRecord /** @var array */ private const DECORATION_FILTERS = ['per_page', 'order_by']; + private const JOIN_FILTERS = ['joins']; + /** @var Collection */ private $filters; @@ -20,7 +22,7 @@ abstract class AbstractGetRecord * @return Collection */ private function getQueryFilters(){ - return $this->filters->except(self::DECORATION_FILTERS); + return $this->filters->except(array_merge(self::DECORATION_FILTERS, self::JOIN_FILTERS)); } /** @@ -30,6 +32,10 @@ abstract class AbstractGetRecord return $this->filters->only(self::DECORATION_FILTERS); } + public function getJoinFilters(){ + return $this->filters->only(self::JOIN_FILTERS); + } + /** * @param null|string $json * @return array @@ -43,7 +49,13 @@ abstract class AbstractGetRecord */ private function applyFiltersToQuery(): Builder { - return (new ApplyFiltersToQuery())->execute($this->getRepository(), $this->getQueryFilters()->toArray()); + $table = $this->getRepository()->getModel()->getTable(); + $a = $this->getQueryFilters()->toArray(); + $r=[]; + + array_walk($a, function ($v, $k) use ($table, &$r) { $r[$table.".".$k]=$v; }); + + return (new ApplyFiltersToQuery())->execute($this->getRepository(), $r); } /** @@ -67,4 +79,4 @@ abstract class AbstractGetRecord */ abstract function getResults(Builder $query); -} \ No newline at end of file +} diff --git a/app/Classes/General/Eloquent/AbstractListRecord.php b/app/Classes/General/Eloquent/AbstractListRecord.php index c5d2e6e6..830dad3c 100644 --- a/app/Classes/General/Eloquent/AbstractListRecord.php +++ b/app/Classes/General/Eloquent/AbstractListRecord.php @@ -6,6 +6,7 @@ namespace App\Classes\General\Eloquent; use App\Classes\Exceptions\MalformedRequestException; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\QueryException; +use Illuminate\Support\Facades\Schema; abstract class AbstractListRecord extends AbstractGetRecord { @@ -33,14 +34,40 @@ abstract class AbstractListRecord extends AbstractGetRecord * @return mixed */ public function getResults(Builder $query) { + + $filters = $this->getJoinFilters(); + $table = $query->getModel()->getTable(); + $selects = []; + + $selects[] = $table.".*,"; + + if($filters->has('joins')){ + + foreach($filters->get('joins') as $join){ + $join_table = $join->table; + $columns = Schema::getColumnListing($join_table); + + $r=[]; + array_walk($columns, function ($v, $k) use ($join_table, &$r) { $r[] = $join_table.".".$v." ".$join_table."_".$v; }); + $selects[] = implode(",",$r); + + $query = $query->join($join->table, function($q) use($join, $query) { + $q->on($query->getModel()->getTable().'.id', '=', $join->table.'.owner_id'); + }); + }; + + $query = $query->selectRaw(implode("",$selects)); + } + $filters = $this->getDecorationFilters(); if($filters->has('order_by')){ - $query = $query->orderBy($filters->get('order_by')->column, $filters->get('order_by')->DESC ? 'DESC': 'ASC'); + $orderByTable = (strpos($filters->get('order_by')->column,".")===false) ? $query->getModel()->getTable()."." : ""; + $query = $query->orderBy($orderByTable.$filters->get('order_by')->column, $filters->get('order_by')->DESC ? 'DESC': 'ASC'); } return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get(); } -} \ No newline at end of file +} diff --git a/resources/assets/vue/components/orders/elements/ParcelComponent.vue b/resources/assets/vue/components/orders/elements/ParcelComponent.vue index 17e29d63..44303afb 100644 --- a/resources/assets/vue/components/orders/elements/ParcelComponent.vue +++ b/resources/assets/vue/components/orders/elements/ParcelComponent.vue @@ -93,4 +93,4 @@ }, mixins: [componentHandler] } - \ No newline at end of file + diff --git a/resources/views/pages/warehouse_list.blade.php b/resources/views/pages/warehouse_list.blade.php index a57fc834..6f6ad64f 100644 --- a/resources/views/pages/warehouse_list.blade.php +++ b/resources/views/pages/warehouse_list.blade.php @@ -2,11 +2,11 @@ @section('inner_content')
- +
-@endsection \ No newline at end of file +@endsection From a203c5bf123269f61c62ba85425b2e7ce967ef78 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Sun, 12 Sep 2021 12:46:26 +0800 Subject: [PATCH 02/11] Add timer, moved schedule to commands --- ...inersStatusUpdateFromVTPortalProcessor.php | 19 ++++++- ...FetchDeliveryListFromVTPortalProcessor.php | 19 ++++++- ...hLoadedContainersFromVTPortalProcessor.php | 23 +++++++- .../FetchPackingListFromVTPortalProcessor.php | 20 +++++++ ...ehouseReceiveListFromVTPortalProcessor.php | 23 +++++++- app/Console/Commands/CurlVTCommand.php | 57 +++++++++++++++++++ app/Console/Kernel.php | 31 +++------- ...2021_09_12_124121_alter_table_packages.php | 30 ++++++++++ 8 files changed, 194 insertions(+), 28 deletions(-) create mode 100644 app/Console/Commands/CurlVTCommand.php create mode 100644 database/migrations/2021_09_12_124121_alter_table_packages.php diff --git a/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php index 0a0c0158..1a2ab2f1 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php @@ -68,6 +68,10 @@ class FetchContainersStatusUpdateFromVTPortalProcessor */ public function execute(){ + $time_start = microtime(true); + $task_name = "FetchContainersStatusUpdateFromVTPortalProcessor"; + self::timer($task_name, $time_start); + try { $containers = Container::where('status', '=', ApprovalStatus::PENDING_VERIFICATION)->get(); @@ -147,9 +151,22 @@ class FetchContainersStatusUpdateFromVTPortalProcessor Log::error($exception); } + $time_end = microtime(true); + self::timer($task_name, $time_start, $time_end); + return []; } - + private static function timer($task="", $time_start=0, $time_end=0){ + if ($time_end > 0) { + $execution_time = ($time_end - $time_start)/60; + $execution_time = round($execution_time,2); + $date = date("Y-m-d H:i a", $time_end); + echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; + } else { + $date = date("Y-m-d H:i a", $time_start); + echo "$task starts at $date". PHP_EOL; + } + } } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php index fbab0c5b..98aadfbd 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php @@ -54,6 +54,10 @@ class FetchDeliveryListFromVTPortalProcessor */ public function execute(){ + $time_start = microtime(true); + $task_name = "FetchDeliveryListFromVTPortalProcessor"; + self::timer($task_name, $time_start); + try { $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::SUSPENDED])->get(); @@ -95,9 +99,22 @@ class FetchDeliveryListFromVTPortalProcessor Log::error($exception); } + $time_end = microtime(true); + self::timer($task_name, $time_start, $time_end); + return []; } - + private static function timer($task="", $time_start=0, $time_end=0){ + if ($time_end > 0) { + $execution_time = ($time_end - $time_start)/60; + $execution_time = round($execution_time,2); + $date = date("Y-m-d H:i a", $time_end); + echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; + } else { + $date = date("Y-m-d H:i a", $time_start); + echo "$task starts at $date". PHP_EOL; + } + } } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php index 4069a40d..e3313f48 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php @@ -124,7 +124,12 @@ class FetchLoadedContainersFromVTPortalProcessor */ public function execute(?Carbon $start = null, ?Carbon $end = null){ + $time_start = microtime(true); + $task_name = "FetchLoadedContainersFromVTPortalProcessor"; + self::timer($task_name, $time_start); + DB::beginTransaction(); + try { $start = $start ? $start : Carbon::now()->subMonth(); @@ -217,17 +222,29 @@ class FetchLoadedContainersFromVTPortalProcessor } } - } } catch (\Exception $exception){ Log::error($exception); } - DB::commit(); + + $time_end = microtime(true); + self::timer($task_name, $time_start, $time_end); + return []; } - + private static function timer($task="", $time_start=0, $time_end=0){ + if ($time_end > 0) { + $execution_time = ($time_end - $time_start)/60; + $execution_time = round($execution_time,2); + $date = date("Y-m-d H:i a", $time_end); + echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; + } else { + $date = date("Y-m-d H:i a", $time_start); + echo "$task starts at $date". PHP_EOL; + } + } } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php index ecc9c9f0..d9b61644 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php @@ -46,6 +46,10 @@ class FetchPackingListFromVTPortalProcessor */ public function execute(){ + $time_start = microtime(true); + $task_name = "FetchPackingListFromVTPortalProcessor"; + self::timer($task_name, $time_start); + $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){ $query->where('status', '=', ApprovalStatus::COMPLETED); })->get(); @@ -79,9 +83,25 @@ class FetchPackingListFromVTPortalProcessor } + $time_end = microtime(true); + self::timer($task_name, $time_start, $time_end); + return []; } + private static function timer($task="", $time_start=0, $time_end=0){ + if ($time_end > 0) { + $execution_time = ($time_end - $time_start)/60; + $execution_time = round($execution_time,2); + $date = date("Y-m-d H:i a", $time_end); + echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; + } else { + $date = date("Y-m-d H:i a", $time_start); + echo "$task starts at $date". PHP_EOL; + } + } } + + diff --git a/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php index b9043479..6756dd2e 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php @@ -112,6 +112,10 @@ class FetchWarehouseReceiveListFromVTPortalProcessor */ public function execute(?Carbon $start = null, ?Carbon $end = null){ + $time_start = microtime(true); + $task_name = "FetchWarehouseReceiveListFromVTPortalProcessor"; + self::timer($task_name, $time_start); + DB::beginTransaction(); try { @@ -132,6 +136,9 @@ class FetchWarehouseReceiveListFromVTPortalProcessor $response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest); + $time_elapsed_secs = microtime(true) - $timer; + echo 'Time '.$timer. PHP_EOL; + foreach ($response->Rows as $parcel){ $marking = explode('/', explode('CIEF/', $parcel[5])[1]); @@ -233,9 +240,23 @@ class FetchWarehouseReceiveListFromVTPortalProcessor } DB::commit(); + + $time_end = microtime(true); + self::timer($task_name, $time_start, $time_end); + return []; } - + private static function timer($task="", $time_start=0, $time_end=0){ + if ($time_end > 0) { + $execution_time = ($time_end - $time_start)/60; + $execution_time = round($execution_time,2); + $date = date("Y-m-d H:i a", $time_end); + echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; + } else { + $date = date("Y-m-d H:i a", $time_start); + echo "$task starts at $date". PHP_EOL; + } + } } diff --git a/app/Console/Commands/CurlVTCommand.php b/app/Console/Commands/CurlVTCommand.php new file mode 100644 index 00000000..e779cd5c --- /dev/null +++ b/app/Console/Commands/CurlVTCommand.php @@ -0,0 +1,57 @@ +dispatch(); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 623233c2..b9aad421 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -17,9 +17,7 @@ class Kernel extends ConsoleKernel * * @var array */ - protected $commands = [ - // - ]; + protected $commands = []; /** * Define the application's command schedule. @@ -29,26 +27,15 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { + $schedule->command('command:curlVTCommand') + ->everyMinute()//dailyAt('15:00') + ->withoutOverlapping() + ->appendOutputTo (storage_path().'/logs/curlvt.log'); - $schedule->call(function(){ - return FetchWarehouseReceiveListFromVTPortalJob::withChain([ - new FetchLoadedContainersFromVTPortalJob, - new FetchPackingListFromVTPortalJob, - new FetchContainersStatusUpdateFromVTPortalJob, - new FetchDeliveryListFromVTPortalJob - ])->dispatch(); - })->dailyAt('15:00'); - - $schedule->call(function(){ - return FetchWarehouseReceiveListFromVTPortalJob::withChain([ - new FetchLoadedContainersFromVTPortalJob, - new FetchPackingListFromVTPortalJob, - new FetchContainersStatusUpdateFromVTPortalJob, - new FetchDeliveryListFromVTPortalJob - ])->dispatch(); - })->dailyAt('21:00'); - - + $schedule->command('command:curlVTCommand') + ->dailyAt('21:00') + ->withoutOverlapping() + ->appendOutputTo (storage_path().'/logs/curlvt.log'); } /** diff --git a/database/migrations/2021_09_12_124121_alter_table_packages.php b/database/migrations/2021_09_12_124121_alter_table_packages.php new file mode 100644 index 00000000..f0c4c311 --- /dev/null +++ b/database/migrations/2021_09_12_124121_alter_table_packages.php @@ -0,0 +1,30 @@ +text('description')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} From e80dbf4b49965e25a64d5373d0a94ac38aa0dda7 Mon Sep 17 00:00:00 2001 From: Fairuz Date: Sun, 12 Sep 2021 12:48:28 +0800 Subject: [PATCH 03/11] Add timer, moved schedule to commands --- app/Console/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index b9aad421..2e082565 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -28,7 +28,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { $schedule->command('command:curlVTCommand') - ->everyMinute()//dailyAt('15:00') + ->dailyAt('15:00') ->withoutOverlapping() ->appendOutputTo (storage_path().'/logs/curlvt.log'); From 0884bcf47aaa40ef1030c94d518d490902fcd652 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 12 Sep 2021 17:12:59 +0800 Subject: [PATCH 04/11] fix long reload issue for container on packing list status update --- .../elements/ContainerComponent.vue | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index 4ed82551..75b5305c 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -51,15 +51,15 @@
-
+
{{packingList.packages.reduce((total, obj) => obj.quantity + total, 0)}}
{{(Math.ceil((packingList.packages.reduce((total, obj) => obj.cbm + total, 0)) * 10000) / 10000).toFixed(3)}}
{{packingList.status === 5 ? 'On Hold' : 'Release'}}
{{packingList.order.address.street_one+' '+(packingList.order.address.street_two ? packingList.order.address.street_two : '')+', '+ packingList.order.address.district.name+', '+packingList.order.address.post_code+' '+packingList.order.address.state.name+', '+packingList.order.address.country.name}}
-
Release
-
Hold
+
Release
+
Hold
@@ -76,12 +76,22 @@ export default { data(){ return { - expanded: false + expanded: false, + index: null, } }, methods: { - successHandler(){ - this.$store.dispatch('reloadList', {'name': 'containerListSection'}); + updateStatus(index, status){ + this.index = index; + this.submit(this.route('api.packing_list.status.update', this.item.packing_lists[index].id, status), 'put', 'containerListSection', true, true) + }, + successHandler(response){ + this.item.packing_lists[this.index] = response.payload.data; + this.$forceUpdate(); + this.index = null; + }, + errorHandler(){ + this.index = null; } }, mixins: [componentHandler] From a7c6c29c259fbcf3952c62071374e6c4fdda5f3b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 14 Sep 2021 12:15:17 +0800 Subject: [PATCH 05/11] delete packages change migration --- ...2021_09_12_124121_alter_table_packages.php | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 database/migrations/2021_09_12_124121_alter_table_packages.php diff --git a/database/migrations/2021_09_12_124121_alter_table_packages.php b/database/migrations/2021_09_12_124121_alter_table_packages.php deleted file mode 100644 index f0c4c311..00000000 --- a/database/migrations/2021_09_12_124121_alter_table_packages.php +++ /dev/null @@ -1,30 +0,0 @@ -text('description')->change(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // - } -} From 41554be892ddec5da3189d6d1a07f6cfc6e71fc7 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 14 Sep 2021 12:32:18 +0800 Subject: [PATCH 06/11] revert changes for join table --- .../General/Eloquent/AbstractGetRecord.php | 18 ++---------- .../General/Eloquent/AbstractListRecord.php | 29 +------------------ 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/app/Classes/General/Eloquent/AbstractGetRecord.php b/app/Classes/General/Eloquent/AbstractGetRecord.php index e2972eb0..f927d818 100644 --- a/app/Classes/General/Eloquent/AbstractGetRecord.php +++ b/app/Classes/General/Eloquent/AbstractGetRecord.php @@ -12,8 +12,6 @@ abstract class AbstractGetRecord /** @var array */ private const DECORATION_FILTERS = ['per_page', 'order_by']; - private const JOIN_FILTERS = ['joins']; - /** @var Collection */ private $filters; @@ -22,7 +20,7 @@ abstract class AbstractGetRecord * @return Collection */ private function getQueryFilters(){ - return $this->filters->except(array_merge(self::DECORATION_FILTERS, self::JOIN_FILTERS)); + return $this->filters->except(self::DECORATION_FILTERS); } /** @@ -32,10 +30,6 @@ abstract class AbstractGetRecord return $this->filters->only(self::DECORATION_FILTERS); } - public function getJoinFilters(){ - return $this->filters->only(self::JOIN_FILTERS); - } - /** * @param null|string $json * @return array @@ -49,13 +43,7 @@ abstract class AbstractGetRecord */ private function applyFiltersToQuery(): Builder { - $table = $this->getRepository()->getModel()->getTable(); - $a = $this->getQueryFilters()->toArray(); - $r=[]; - - array_walk($a, function ($v, $k) use ($table, &$r) { $r[$table.".".$k]=$v; }); - - return (new ApplyFiltersToQuery())->execute($this->getRepository(), $r); + return (new ApplyFiltersToQuery())->execute($this->getRepository(), $this->getQueryFilters()->toArray()); } /** @@ -79,4 +67,4 @@ abstract class AbstractGetRecord */ abstract function getResults(Builder $query); -} +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/AbstractListRecord.php b/app/Classes/General/Eloquent/AbstractListRecord.php index 830dad3c..01e66c29 100644 --- a/app/Classes/General/Eloquent/AbstractListRecord.php +++ b/app/Classes/General/Eloquent/AbstractListRecord.php @@ -6,7 +6,6 @@ namespace App\Classes\General\Eloquent; use App\Classes\Exceptions\MalformedRequestException; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\QueryException; -use Illuminate\Support\Facades\Schema; abstract class AbstractListRecord extends AbstractGetRecord { @@ -34,36 +33,10 @@ abstract class AbstractListRecord extends AbstractGetRecord * @return mixed */ public function getResults(Builder $query) { - - $filters = $this->getJoinFilters(); - $table = $query->getModel()->getTable(); - $selects = []; - - $selects[] = $table.".*,"; - - if($filters->has('joins')){ - - foreach($filters->get('joins') as $join){ - $join_table = $join->table; - $columns = Schema::getColumnListing($join_table); - - $r=[]; - array_walk($columns, function ($v, $k) use ($join_table, &$r) { $r[] = $join_table.".".$v." ".$join_table."_".$v; }); - $selects[] = implode(",",$r); - - $query = $query->join($join->table, function($q) use($join, $query) { - $q->on($query->getModel()->getTable().'.id', '=', $join->table.'.owner_id'); - }); - }; - - $query = $query->selectRaw(implode("",$selects)); - } - $filters = $this->getDecorationFilters(); if($filters->has('order_by')){ - $orderByTable = (strpos($filters->get('order_by')->column,".")===false) ? $query->getModel()->getTable()."." : ""; - $query = $query->orderBy($orderByTable.$filters->get('order_by')->column, $filters->get('order_by')->DESC ? 'DESC': 'ASC'); + $query = $query->orderBy($filters->get('order_by')->column, $filters->get('order_by')->DESC ? 'DESC': 'ASC'); } return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get(); From 3e23fa680954e6422ef7568f0f4a45ae02880846 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 14 Sep 2021 12:40:37 +0800 Subject: [PATCH 07/11] revert changes for join table --- resources/views/pages/warehouse_list.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/pages/warehouse_list.blade.php b/resources/views/pages/warehouse_list.blade.php index 6f6ad64f..a57fc834 100644 --- a/resources/views/pages/warehouse_list.blade.php +++ b/resources/views/pages/warehouse_list.blade.php @@ -2,11 +2,11 @@ @section('inner_content')
- +
-@endsection +@endsection \ No newline at end of file From a3ecda8f8e6fefe5a70f9eb88e146b3bf15bc984 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 14 Sep 2021 17:26:33 +0800 Subject: [PATCH 08/11] round up cbm in container component --- .../vue/components/containers/elements/ContainerComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index 75b5305c..e8af2c65 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -54,7 +54,7 @@
{{packingList.packages.reduce((total, obj) => obj.quantity + total, 0)}}
-
{{(Math.ceil((packingList.packages.reduce((total, obj) => obj.cbm + total, 0)) * 10000) / 10000).toFixed(3)}}
+
{{ (Math.ceil((packingList.packages.reduce((total, obj) => obj.cbm + total, 0)) * 1000) / 1000).toFixed(3)}}
{{packingList.status === 5 ? 'On Hold' : 'Release'}}
{{packingList.order.address.street_one+' '+(packingList.order.address.street_two ? packingList.order.address.street_two : '')+', '+ packingList.order.address.district.name+', '+packingList.order.address.post_code+' '+packingList.order.address.state.name+', '+packingList.order.address.country.name}}
From 1f05c4b56f415b46c499827c738dd5887b979dee Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 15 Sep 2021 18:17:03 +0800 Subject: [PATCH 09/11] remove timer from vt fetch jobs --- ...inersStatusUpdateFromVTPortalProcessor.php | 19 +-------------- ...FetchDeliveryListFromVTPortalProcessor.php | 19 +-------------- ...hLoadedContainersFromVTPortalProcessor.php | 23 +++---------------- .../FetchPackingListFromVTPortalProcessor.php | 20 ---------------- ...ehouseReceiveListFromVTPortalProcessor.php | 23 +------------------ 5 files changed, 6 insertions(+), 98 deletions(-) diff --git a/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php index 1a2ab2f1..0a0c0158 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchContainersStatusUpdateFromVTPortalProcessor.php @@ -68,10 +68,6 @@ class FetchContainersStatusUpdateFromVTPortalProcessor */ public function execute(){ - $time_start = microtime(true); - $task_name = "FetchContainersStatusUpdateFromVTPortalProcessor"; - self::timer($task_name, $time_start); - try { $containers = Container::where('status', '=', ApprovalStatus::PENDING_VERIFICATION)->get(); @@ -151,22 +147,9 @@ class FetchContainersStatusUpdateFromVTPortalProcessor Log::error($exception); } - $time_end = microtime(true); - self::timer($task_name, $time_start, $time_end); - return []; } - private static function timer($task="", $time_start=0, $time_end=0){ - if ($time_end > 0) { - $execution_time = ($time_end - $time_start)/60; - $execution_time = round($execution_time,2); - $date = date("Y-m-d H:i a", $time_end); - echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; - } else { - $date = date("Y-m-d H:i a", $time_start); - echo "$task starts at $date". PHP_EOL; - } - } + } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php index 98aadfbd..fbab0c5b 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchDeliveryListFromVTPortalProcessor.php @@ -54,10 +54,6 @@ class FetchDeliveryListFromVTPortalProcessor */ public function execute(){ - $time_start = microtime(true); - $task_name = "FetchDeliveryListFromVTPortalProcessor"; - self::timer($task_name, $time_start); - try { $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::SUSPENDED])->get(); @@ -99,22 +95,9 @@ class FetchDeliveryListFromVTPortalProcessor Log::error($exception); } - $time_end = microtime(true); - self::timer($task_name, $time_start, $time_end); - return []; } - private static function timer($task="", $time_start=0, $time_end=0){ - if ($time_end > 0) { - $execution_time = ($time_end - $time_start)/60; - $execution_time = round($execution_time,2); - $date = date("Y-m-d H:i a", $time_end); - echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; - } else { - $date = date("Y-m-d H:i a", $time_start); - echo "$task starts at $date". PHP_EOL; - } - } + } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php index e3313f48..4069a40d 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchLoadedContainersFromVTPortalProcessor.php @@ -124,12 +124,7 @@ class FetchLoadedContainersFromVTPortalProcessor */ public function execute(?Carbon $start = null, ?Carbon $end = null){ - $time_start = microtime(true); - $task_name = "FetchLoadedContainersFromVTPortalProcessor"; - self::timer($task_name, $time_start); - DB::beginTransaction(); - try { $start = $start ? $start : Carbon::now()->subMonth(); @@ -222,29 +217,17 @@ class FetchLoadedContainersFromVTPortalProcessor } } + } } catch (\Exception $exception){ Log::error($exception); } + DB::commit(); - - $time_end = microtime(true); - self::timer($task_name, $time_start, $time_end); - return []; } - private static function timer($task="", $time_start=0, $time_end=0){ - if ($time_end > 0) { - $execution_time = ($time_end - $time_start)/60; - $execution_time = round($execution_time,2); - $date = date("Y-m-d H:i a", $time_end); - echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; - } else { - $date = date("Y-m-d H:i a", $time_start); - echo "$task starts at $date". PHP_EOL; - } - } + } diff --git a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php index d9b61644..ecc9c9f0 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchPackingListFromVTPortalProcessor.php @@ -46,10 +46,6 @@ class FetchPackingListFromVTPortalProcessor */ public function execute(){ - $time_start = microtime(true); - $task_name = "FetchPackingListFromVTPortalProcessor"; - self::timer($task_name, $time_start); - $packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){ $query->where('status', '=', ApprovalStatus::COMPLETED); })->get(); @@ -83,25 +79,9 @@ class FetchPackingListFromVTPortalProcessor } - $time_end = microtime(true); - self::timer($task_name, $time_start, $time_end); - return []; } - private static function timer($task="", $time_start=0, $time_end=0){ - if ($time_end > 0) { - $execution_time = ($time_end - $time_start)/60; - $execution_time = round($execution_time,2); - $date = date("Y-m-d H:i a", $time_end); - echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; - } else { - $date = date("Y-m-d H:i a", $time_start); - echo "$task starts at $date". PHP_EOL; - } - } } - - diff --git a/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php index 6756dd2e..b9043479 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchWarehouseReceiveListFromVTPortalProcessor.php @@ -112,10 +112,6 @@ class FetchWarehouseReceiveListFromVTPortalProcessor */ public function execute(?Carbon $start = null, ?Carbon $end = null){ - $time_start = microtime(true); - $task_name = "FetchWarehouseReceiveListFromVTPortalProcessor"; - self::timer($task_name, $time_start); - DB::beginTransaction(); try { @@ -136,9 +132,6 @@ class FetchWarehouseReceiveListFromVTPortalProcessor $response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest); - $time_elapsed_secs = microtime(true) - $timer; - echo 'Time '.$timer. PHP_EOL; - foreach ($response->Rows as $parcel){ $marking = explode('/', explode('CIEF/', $parcel[5])[1]); @@ -240,23 +233,9 @@ class FetchWarehouseReceiveListFromVTPortalProcessor } DB::commit(); - - $time_end = microtime(true); - self::timer($task_name, $time_start, $time_end); - return []; } - private static function timer($task="", $time_start=0, $time_end=0){ - if ($time_end > 0) { - $execution_time = ($time_end - $time_start)/60; - $execution_time = round($execution_time,2); - $date = date("Y-m-d H:i a", $time_end); - echo "$task ends at $date (took $execution_time minutes)". PHP_EOL; - } else { - $date = date("Y-m-d H:i a", $time_start); - echo "$task starts at $date". PHP_EOL; - } - } + } From 2be9a3dcfed75204e5f6f09be3e10060ff8314e3 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 15 Sep 2021 18:26:54 +0800 Subject: [PATCH 10/11] remove logger from logout logic --- .../Modules/Accounts/ControllersLogic/LogoutUserLogic.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Classes/Modules/Accounts/ControllersLogic/LogoutUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/LogoutUserLogic.php index bfa1f20a..aea1f932 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/LogoutUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/LogoutUserLogic.php @@ -37,7 +37,6 @@ class LogoutUserLogic extends AbstractControllerLogic */ protected function logic(Request $request): JsonResponse { - logger("logout"); $this->invalidatesAuthenticationToken->execute(); return $this->response(); From 4626eb937ed77044757c90cd9bfb8624e19ccc68 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 15 Sep 2021 18:29:34 +0800 Subject: [PATCH 11/11] change container list to 5 per page --- resources/views/pages/containers.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/containers.blade.php b/resources/views/pages/containers.blade.php index 6c2eb286..642d8c33 100644 --- a/resources/views/pages/containers.blade.php +++ b/resources/views/pages/containers.blade.php @@ -9,7 +9,7 @@
- +