Fix broadband traffic import, when new services cannot be found. Fix broadband update so that start_at = connect_at
This commit is contained in:
parent
5b4aa5c73e
commit
1667b8c1df
@ -12,6 +12,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
@ -391,6 +392,7 @@ class ServiceController extends Controller
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Service $o
|
* @param Service $o
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function update(Request $request,Service $o)
|
public function update(Request $request,Service $o)
|
||||||
{
|
{
|
||||||
@ -418,8 +420,17 @@ class ServiceController extends Controller
|
|||||||
$o->invoice_next_at = $request->invoice_next_at;
|
$o->invoice_next_at = $request->invoice_next_at;
|
||||||
|
|
||||||
// Also update our service start_at date.
|
// Also update our service start_at date.
|
||||||
|
// @todo We may want to make start_at/stop_at dynamic values calculated by the type records
|
||||||
if ($request->post('start_at'))
|
if ($request->post('start_at'))
|
||||||
$o->start_at = $request->start_at;
|
$o->start_at = $request->start_at;
|
||||||
|
else {
|
||||||
|
// For broadband, start_at is connect_at in the type record
|
||||||
|
switch ($o->category) {
|
||||||
|
case 'broadband':
|
||||||
|
$o->start_at = $o->type->connect_at;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$o->save();
|
$o->save();
|
||||||
|
|
||||||
|
@ -106,7 +106,6 @@ final class BroadbandTraffic implements ShouldQueue
|
|||||||
->single();
|
->single();
|
||||||
|
|
||||||
$to = new UsageBroadband;
|
$to = new UsageBroadband;
|
||||||
$to->site_id = $oo->site_id;
|
|
||||||
$to->date = $last_update;
|
$to->date = $last_update;
|
||||||
$to->supplier_id = $this->o->id;
|
$to->supplier_id = $this->o->id;
|
||||||
$to->up_peak = $row[$o->getColumnKey('Peak upload')];
|
$to->up_peak = $row[$o->getColumnKey('Peak upload')];
|
||||||
@ -122,8 +121,10 @@ final class BroadbandTraffic implements ShouldQueue
|
|||||||
Log::error(sprintf('%s:Too many services return for [%s]',self::LOGKEY,$row[$o->getColumnKey('Login')]),['date'=>$date,'count'=>$oo->count()]);
|
Log::error(sprintf('%s:Too many services return for [%s]',self::LOGKEY,$row[$o->getColumnKey('Login')]),['date'=>$date,'count'=>$oo->count()]);
|
||||||
|
|
||||||
$to->service = $row[$o->getColumnKey('Login')];
|
$to->service = $row[$o->getColumnKey('Login')];
|
||||||
|
$to->site_id = 1; // @todo This needs to be worked out a better way
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$to->site_id = $oo->site_id;
|
||||||
$to->service_item_id = $oo->id;
|
$to->service_item_id = $oo->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,9 +132,8 @@ final class BroadbandTraffic implements ShouldQueue
|
|||||||
$u++;
|
$u++;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
dump($to);
|
|
||||||
Log::error(sprintf('%s:Exception occurred when storing traffic record for [%s].',self::LOGKEY,$row[$o->getColumnKey('Login')]),['row'=>$row,'line'=>$line]);
|
Log::error(sprintf('%s:Exception occurred when storing traffic record for [%s].',self::LOGKEY,$row[$o->getColumnKey('Login')]),['row'=>$row,'line'=>$line]);
|
||||||
throw new \Exception('Error while storing traffic date');
|
throw new \Exception('Error while storing traffic data: '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log::info(sprintf('%s: Records Imported [%d] for [%s]',self::LOGKEY,$u,$last_update->format('Y-m-d')));
|
Log::info(sprintf('%s: Records Imported [%d] for [%s]',self::LOGKEY,$u,$last_update->format('Y-m-d')));
|
||||||
|
Loading…
Reference in New Issue
Block a user