Skip to content

Commit

Permalink
Merge pull request #117 from sarapis/development
Browse files Browse the repository at this point in the history
code optimization and add new feature
  • Loading branch information
d9it committed Sep 23, 2023
2 parents 521a582 + 18ad508 commit b8e8db2
Show file tree
Hide file tree
Showing 386 changed files with 232,236 additions and 42,647 deletions.
4 changes: 2 additions & 2 deletions app/Console/Commands/AutoExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ public function handle()
// if ($row->weekday) {
$scheduleArray = [
'id' => $row->id,
'service_id' => $row->schedule_services,
'location_id' => $row->schedule_locations,
'service_id' => $row->services,
'location_id' => $row->locations,
'service_at_location_id' => $row->service_at_location,
'valid_from' => $row->valid_from,
'valid_to' => $row->valid_to,
Expand Down
14 changes: 13 additions & 1 deletion app/Console/Commands/AutoSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Log;
use App\Model\AdditionalTaxonomy;
use App\Model\Address;
use App\Model\CodeLedger;
use App\Model\Contact;
use App\Model\ContactPhone;
use App\Model\Detail;
Expand All @@ -18,10 +19,12 @@
use App\Model\LocationAddress;
use App\Model\LocationPhone;
use App\Model\LocationSchedule;
use App\Model\Map;
use App\Model\Organization;
use App\Model\OrganizationDetail;
use App\Model\OrganizationPhone;
use App\Model\OrganizationProgram;
use App\Model\OrganizationTag;
use App\Model\Phone;
use App\Model\Program;
use App\Model\Schedule;
Expand All @@ -34,13 +37,15 @@
use App\Model\ServicePhone;
use App\Model\ServiceProgram;
use App\Model\ServiceSchedule;
use App\Model\ServiceTag;
use App\Model\ServiceTaxonomy;
use App\Model\Taxonomy;
use App\Model\TaxonomyTerm;
use App\Model\TaxonomyType;
use Carbon\Carbon;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Session;
use OwenIt\Auditing\Models\Audit;
use Spatie\Geocoder\Geocoder;

class AutoSync extends Command
Expand Down Expand Up @@ -122,6 +127,12 @@ public function handle()
ServiceTaxonomy::truncate();
ServiceSchedule::truncate();
Taxonomy::truncate();
TaxonomyType::truncate();
TaxonomyTerm::truncate();
Audit::truncate();
CodeLedger::truncate();
OrganizationTag::truncate();
ServiceTag::truncate();
}
if ($importData && $importData->import_type == 'airtable') {
$airtableKeyInfo = Airtablekeyinfo::whereId($importData->airtable_api_key)->first();
Expand Down Expand Up @@ -209,7 +220,8 @@ public function apply_geocode()
$badgeocoded_location_info_list = Location::where('location_latitude', '=', '')->get();
$client = new \GuzzleHttp\Client();
$geocoder = new Geocoder($client);
$geocode_api_key = env('GEOCODE_GOOGLE_APIKEY');
$map = Map::find(1);
$geocode_api_key = $map && $map->api_key ? $map->api_key : null;
$geocoder->setApiKey($geocode_api_key);

if ($ungeocoded_location_info_list) {
Expand Down
2 changes: 1 addition & 1 deletion app/Exports/CodeExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CodeExport implements FromView
{

public $request;
public function __construct($request)
{
$this->request = $request;
Expand Down
1 change: 1 addition & 0 deletions app/Exports/OrganizationExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class OrganizationExport implements FromView
{
public $organizations;

public function __construct($organizations)
{
Expand Down
6 changes: 6 additions & 0 deletions app/Exports/TrackingExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public function view(): View
// });
$organizations->whereIn('organization_status_x', $extraData['status']);
}
if (isset($extraData['last_updated_by']) && $extraData['last_updated_by'] != null) {
$organizations->where('updated_by', $extraData['last_updated_by']);
}
if (isset($extraData['last_verified_by']) && $extraData['last_verified_by'] != null) {
$organizations->where('last_verified_by', $extraData['last_verified_by']);
}
}
return view('exports.trackings', [
'organizations' => $organizations->cursor(),
Expand Down
37 changes: 37 additions & 0 deletions app/Exports/zip/AccessibilityZipExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Exports\zip;

use App\Model\Accessibility;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;

class AccessibilityZipExport implements FromView, WithCustomCsvSettings
{
public $enclosure;
public function __construct($enclosure)
{
$this->enclosure = $enclosure;
}
/**
* @return View
*/
public function view(): View
{
$accessibility_for_disabilities = Accessibility::cursor();
return view('exports.zip.accessibility_for_disabilities', [
'accessibility_for_disabilities' => $accessibility_for_disabilities,
]);
}
public function getCsvSettings(): array
{
if ($this->enclosure) {
return [
'delimiter' => ',',
'enclosure' => '',
];
}
return [];
}
}
53 changes: 53 additions & 0 deletions app/Exports/zip/AddressZipExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Exports\zip;

use App\Model\Address;
use App\Model\LocationAddress;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;

class AddressZipExport implements FromView, WithCustomCsvSettings
{
public $location_recordids_temp, $enclosure;
public function __construct($location_recordids_temp, $enclosure)
{
$this->location_recordids_temp = $location_recordids_temp;
$this->enclosure = $enclosure;
}


/**
* @return View
*/
public function view(): View
{
if (isset($this->location_recordids_temp) && count($this->location_recordids_temp) > 0) {
$chunk = $this->location_recordids_temp;
$chunk = array_chunk($chunk, 500);

$table_address = collect();
for ($i = 0; $i < count($chunk); $i++) {
$address_record_ids = LocationAddress::whereIn('location_recordid', $chunk[$i])->pluck('address_recordid')->toArray();
$query = Address::whereIn('address_recordid', $address_record_ids)->get();
$addresses = $table_address->merge($query);
}
} else {
$addresses = Address::get();
}
return view('exports.zip.addresses', [
'addresses' => $addresses,
]);
}
public function getCsvSettings(): array
{
if ($this->enclosure) {
return [
'delimiter' => ',',
'enclosure' => '',
];
}
return [];
}
}
43 changes: 43 additions & 0 deletions app/Exports/zip/ContactZipExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Exports\zip;

use App\Model\Contact;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;

class ContactZipExport implements FromView, WithCustomCsvSettings
{
public $organization_ids, $enclosure;

public function __construct($organization_ids, $enclosure)
{
$this->organization_ids = $organization_ids;
$this->enclosure = $enclosure;
}
/**
* @return View
*/
public function view(): View
{
$contacts = Contact::select('*');
if ($this->organization_ids) {
$contacts->where('contact_organizations', $this->organization_ids);
}

return view('exports.zip.contacts', [
'contacts' => $contacts->cursor(),
]);
}
public function getCsvSettings(): array
{
if ($this->enclosure) {
return [
'delimiter' => ',',
'enclosure' => '',
];
}
return [];
}
}
37 changes: 37 additions & 0 deletions app/Exports/zip/LanguageZipExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Exports\zip;

use App\Model\Language;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;

class LanguageZipExport implements FromView, WithCustomCsvSettings
{
public $enclosure;
public function __construct($enclosure)
{
$this->enclosure = $enclosure;
}
/**
* @return View
*/
public function view(): View
{
$languages = Language::cursor();
return view('exports.zip.languages', [
'languages' => $languages,
]);
}
public function getCsvSettings(): array
{
if ($this->enclosure) {
return [
'delimiter' => ',',
'enclosure' => '',
];
}
return [];
}
}
45 changes: 45 additions & 0 deletions app/Exports/zip/LocationAddressZipExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Exports\zip;

use App\Model\LocationAddress;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
use Maatwebsite\Excel\Concerns\WithHeadings;

class LocationAddressZipExport implements FromCollection, WithCustomCsvSettings, WithHeadings
{
public $enclosure;
public function __construct($enclosure)
{
$this->enclosure = $enclosure;
}
public function headings(): array
{
return [
'id',
'location_recordid',
'address_recordid',
'created_at',
'updated_at',
];
}

/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return LocationAddress::all();
}
public function getCsvSettings(): array
{
if ($this->enclosure) {
return [
'delimiter' => ',',
'enclosure' => '',
];
}
return [];
}
}
45 changes: 45 additions & 0 deletions app/Exports/zip/LocationPhoneZipExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Exports\zip;

use App\Model\LocationPhone;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
use Maatwebsite\Excel\Concerns\WithHeadings;

class LocationPhoneZipExport implements FromCollection, WithCustomCsvSettings, WithHeadings
{
public $enclosure;
public function __construct($enclosure)
{
$this->enclosure = $enclosure;
}
public function headings(): array
{
return [
'id',
'location_recordid',
'phone_recordid',
'created_at',
'updated_at',
];
}

/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return LocationPhone::all();
}
public function getCsvSettings(): array
{
if ($this->enclosure) {
return [
'delimiter' => ',',
'enclosure' => '',
];
}
return [];
}
}
Loading

0 comments on commit b8e8db2

Please sign in to comment.