From ec200c3d1394a2d966dba86bcc03b20b86be6b0c Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Tue, 11 Jun 2024 10:06:21 -0400 Subject: [PATCH 1/4] [TM-851] convert to post request for polygon validation --- .../paths/Terrafund/get-v2-terrafund-validation-polygon.yml | 2 +- openapi-src/V2/paths/_index.yml | 4 ++-- resources/docs/swagger-v2.yml | 6 +++--- routes/api_v2.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openapi-src/V2/paths/Terrafund/get-v2-terrafund-validation-polygon.yml b/openapi-src/V2/paths/Terrafund/get-v2-terrafund-validation-polygon.yml index 1f565764b..310abf699 100644 --- a/openapi-src/V2/paths/Terrafund/get-v2-terrafund-validation-polygon.yml +++ b/openapi-src/V2/paths/Terrafund/get-v2-terrafund-validation-polygon.yml @@ -1,4 +1,4 @@ -summary: Get validation results for a polygon +summary: Run validation for a polygon parameters: - in: query name: uuid diff --git a/openapi-src/V2/paths/_index.yml b/openapi-src/V2/paths/_index.yml index c4d6c211a..4a3158a6a 100644 --- a/openapi-src/V2/paths/_index.yml +++ b/openapi-src/V2/paths/_index.yml @@ -2515,13 +2515,13 @@ get: $ref: './Exports/get-v2-entity-export-uuid.yml' '/v2/terrafund/validation/polygon': - get: + post: $ref: './Terrafund/get-v2-terrafund-validation-polygon.yml' '/v2/terrafund/validation/criteria-data': get: $ref: './Terrafund/get-v2-terrafund-validation-criteria-data.yml' '/v2/terrafund/validation/sitePolygons': - get: + post: $ref: './Terrafund/get-v2-terrafund-validation-sitepolygons.yml' '/v2/terrafund/validation/site': get: diff --git a/resources/docs/swagger-v2.yml b/resources/docs/swagger-v2.yml index 968bbc625..1965c3011 100644 --- a/resources/docs/swagger-v2.yml +++ b/resources/docs/swagger-v2.yml @@ -94312,8 +94312,8 @@ paths: schema: type: file /v2/terrafund/validation/polygon: - get: - summary: Get validation results for a polygon + post: + summary: Run validation for a polygon parameters: - in: query name: uuid @@ -94380,7 +94380,7 @@ paths: type: integer description: 'Indicates if the criteria is valid or not (1 for valid, 0 for invalid)' /v2/terrafund/validation/sitePolygons: - get: + post: summary: Run validation for all polygons in a site parameters: - in: query diff --git a/routes/api_v2.php b/routes/api_v2.php index c4caa12ff..9aedba714 100644 --- a/routes/api_v2.php +++ b/routes/api_v2.php @@ -638,8 +638,8 @@ Route::get('/validation/overlapping', [TerrafundCreateGeometryController::class, 'validateOverlapping']); Route::get('/validation/estimated-area', [TerrafundCreateGeometryController::class, 'validateEstimatedArea']); Route::get('/validation/table-data', [TerrafundCreateGeometryController::class, 'validateDataInDB']); - Route::get('/validation/polygon', [TerrafundCreateGeometryController::class, 'getValidationPolygon']); - Route::get('/validation/sitePolygons', [TerrafundCreateGeometryController::class, 'getSiteValidationPolygon']); + Route::post('/validation/polygon', [TerrafundCreateGeometryController::class, 'getValidationPolygon']); + Route::post('/validation/sitePolygons', [TerrafundCreateGeometryController::class, 'getSiteValidationPolygon']); Route::get('/validation/site', [TerrafundCreateGeometryController::class, 'getCurrentSiteValidation']); Route::get('/polygon/{uuid}', [TerrafundEditGeometryController::class, 'getSitePolygonData']); From bc262b2d3e96ca28509dd10b5d76bb5457ce468f Mon Sep 17 00:00:00 2001 From: JORGE Date: Tue, 11 Jun 2024 11:47:53 -0400 Subject: [PATCH 2/4] [TM-851] Fix info log for updating centroids --- .../V2/Terrafund/TerrafundEditGeometryController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php index fb11c14ee..c755bcb8b 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php @@ -84,7 +84,12 @@ public function updateProjectCentroid($polygonGeometry) } else { Log::warning("Centroid data for project UUID: $project->uuid is malformed."); } - Log::info("Updated project centroid for project UUID: $project->uuid with lat: {$centroid['lat']}, lng: {$centroid['lng']}"); + if (is_array($centroid) && isset($centroid['lat']) && isset($centroid['lng'])) { + Log::info("Updated project centroid for project UUID: $project->uuid with lat: {$centroid['lat']}, lng: {$centroid['lng']}"); + } else { + Log::error("Centroid is not properly defined. Centroid data: " . print_r($centroid, true)); + } + } else { Log::warning("Project with UUID $relatedSite->project_id not found."); } From 854df2ef811173cf92a95750743ad9c5f296ab6a Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Tue, 11 Jun 2024 12:12:04 -0400 Subject: [PATCH 3/4] [TM-851] make lint fix --- .../V2/Terrafund/TerrafundEditGeometryController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php index c755bcb8b..88bcbfabc 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundEditGeometryController.php @@ -85,9 +85,9 @@ public function updateProjectCentroid($polygonGeometry) Log::warning("Centroid data for project UUID: $project->uuid is malformed."); } if (is_array($centroid) && isset($centroid['lat']) && isset($centroid['lng'])) { - Log::info("Updated project centroid for project UUID: $project->uuid with lat: {$centroid['lat']}, lng: {$centroid['lng']}"); + Log::info("Updated project centroid for project UUID: $project->uuid with lat: {$centroid['lat']}, lng: {$centroid['lng']}"); } else { - Log::error("Centroid is not properly defined. Centroid data: " . print_r($centroid, true)); + Log::error('Centroid is not properly defined. Centroid data: ' . print_r($centroid, true)); } } else { From 3b0e3b82e6e269298a8ca96c0b6d9ea76e24739d Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Tue, 11 Jun 2024 12:15:50 -0400 Subject: [PATCH 4/4] [TM-851] remove createdby when saving criteria site --- app/Services/PolygonService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Services/PolygonService.php b/app/Services/PolygonService.php index 9e8c5ab8a..fd323c3a5 100644 --- a/app/Services/PolygonService.php +++ b/app/Services/PolygonService.php @@ -83,7 +83,6 @@ public function createCriteriaSite($polygonId, $criteriaId, $valid): bool|string $criteriaSite->polygon_id = $polygonId; $criteriaSite->criteria_id = $criteriaId; $criteriaSite->valid = $valid; - $criteriaSite->created_by = Auth::user()?->id; try { $criteriaSite->save();