From 3ae85054a5565904381ebc9e0203a903a6f68169 Mon Sep 17 00:00:00 2001 From: Djonathan Date: Wed, 20 Jul 2022 09:49:59 -0300 Subject: [PATCH] Correction of PLD implementation, Daily Values. --- app/Helpers/Helpers.php | 2 +- app/Repositories/Pld/PldRepository.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Helpers/Helpers.php b/app/Helpers/Helpers.php index e3793eb..1181072 100644 --- a/app/Helpers/Helpers.php +++ b/app/Helpers/Helpers.php @@ -21,7 +21,7 @@ class Helpers return $result; } - public static function orderByDate($result, $format ='M/Y', $field = 'mes'): array + public static function orderByDate($result, $format ='M/Y', $field = 'mes'): array { return collect($result) ->transform(fn($value) => Arr::set( diff --git a/app/Repositories/Pld/PldRepository.php b/app/Repositories/Pld/PldRepository.php index 79f5483..8f785f9 100644 --- a/app/Repositories/Pld/PldRepository.php +++ b/app/Repositories/Pld/PldRepository.php @@ -159,7 +159,8 @@ class PldRepository extends AbstractRepository implements PldContractInterface 'pld.submercado as submarket', DB::raw("AVG(pld.valor) as value"), DB::raw("pld.mes_ref as year_month"), - DB::raw("TO_CHAR(TO_DATE(pld.mes_ref, 'YYMM'::text)::timestamp with time zone, 'MM/YYYY'::text) as year_month_formatted") + DB::raw("TO_CHAR(TO_DATE(pld.mes_ref, 'YYMM'::text)::timestamp with time zone, 'MM/YYYY'::text) as year_month_formatted"), + DB::raw("TO_CHAR(TO_DATE(pld.mes_ref, 'YYMM'), 'MM/YYYY') AS mes_ref"), ]; $fields2 = ['day_formatted', @@ -181,6 +182,7 @@ class PldRepository extends AbstractRepository implements PldContractInterface ) ->orderByRaw("('1899-12-30'::date + ('1 day'::interval day * (pld.dia_num)::double precision))"); + return $this->execute($fields2, $params) ->from($query, 'plds') ->orderBy('day_calc', 'asc')