-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into merge/main-staging-po…
…st-rr
- Loading branch information
Showing
6 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\V2\PolygonGeometry; | ||
use App\Models\V2\Sites\SitePolygon; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class DeleteDummyBufferedPolygons extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'delete:dummy-buffered-polygons {siteId : The UUID of the site to delete polygons for}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Delete dummy buffered polygons for a specified site'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$siteId = $this->argument('siteId'); | ||
|
||
DB::beginTransaction(); | ||
|
||
try { | ||
|
||
$sitePolygons = SitePolygon::where('site_id', $siteId)->get(); | ||
|
||
foreach ($sitePolygons as $sitePolygon) { | ||
$polygonGeometry = PolygonGeometry::where('uuid', $sitePolygon->poly_id)->first(); | ||
if ($polygonGeometry) { | ||
$polygonGeometry->deleteWithRelated(); | ||
} | ||
} | ||
|
||
DB::commit(); | ||
|
||
$this->info("Dummy buffered polygons for site ID $siteId have been successfully deleted."); | ||
|
||
} catch (\Exception $e) { | ||
DB::rollBack(); | ||
$this->error('Failed to delete dummy buffered polygons: ' . $e->getMessage()); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/Http/Controllers/V2/Exports/GeneratePreSignedURLDownloadReportController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\V2\Exports; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
class GeneratePreSignedURLDownloadReportController extends Controller | ||
{ | ||
public function __invoke(Request $request, string $entity, string $framework) | ||
{ | ||
$fileKey = 'exports/all-entity-records/'.$entity.'-'.$framework.'.csv'; | ||
|
||
$expiration = now()->addMinutes(60); | ||
|
||
$presignedUrl = Storage::disk('s3')->temporaryUrl($fileKey, $expiration); | ||
|
||
return response()->json(['url' => $presignedUrl]); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
openapi-src/V2/paths/Exports/get-v2-admin-entity-presigned-url-framework.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
operationId: get-v2-admin-entity-presigned-url-framework.yml | ||
summary: Export entities data | ||
tags: | ||
- V2 Projects | ||
- V2 Sites | ||
- V2 Nurseries | ||
- V2 Project Reports | ||
- V2 Site Reports | ||
- V2 Nursery Reports | ||
- Exports | ||
parameters: | ||
- type: string | ||
name: ENTITY | ||
in: path | ||
required: true | ||
description: allowed values projects/sites/nurseries/project-reports/site-reports/nursery-reports | ||
- type: string | ||
name: FRAMEWORK | ||
in: path | ||
required: true | ||
description: allowed values terrafund/ppc | ||
responses: | ||
'200': | ||
description: OK | ||
schema: | ||
type: object | ||
properties: | ||
url: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters