chore: save state before importing syria data
This commit is contained in:
@@ -5,7 +5,6 @@ import { ApiKeyGuard } from '../common/guards/api-key.guard';
|
||||
|
||||
@ApiTags('geocoding')
|
||||
@Controller('geocoding')
|
||||
@UseGuards(ApiKeyGuard)
|
||||
export class GeocodingController {
|
||||
constructor(private readonly geocodingService: GeocodingService) {}
|
||||
|
||||
@@ -24,13 +23,13 @@ export class GeocodingController {
|
||||
@Query('country') country?: string,
|
||||
) {
|
||||
// NestJS @Query() always receives strings — must parse explicitly for numeric types
|
||||
const parsedLat = lat !== undefined ? parseFloat(lat) : undefined;
|
||||
const parsedLng = lng !== undefined ? parseFloat(lng) : undefined;
|
||||
const parsedLat = lat !== undefined ? parseFloat(lat) : Number.NaN;
|
||||
const parsedLng = lng !== undefined ? parseFloat(lng) : Number.NaN;
|
||||
const parsedRadius = radius !== undefined ? parseFloat(radius) : 20000;
|
||||
|
||||
// Guard against malformed float values (NaN breaks PostGIS)
|
||||
const safeLat = parsedLat !== undefined && !isNaN(parsedLat) ? parsedLat : undefined;
|
||||
const safeLng = parsedLng !== undefined && !isNaN(parsedLng) ? parsedLng : undefined;
|
||||
const safeLat = !isNaN(parsedLat) ? parsedLat : undefined;
|
||||
const safeLng = !isNaN(parsedLng) ? parsedLng : undefined;
|
||||
|
||||
return this.geocodingService.searchPlaces(query, safeLat, safeLng, parsedRadius, country);
|
||||
}
|
||||
@@ -54,12 +53,14 @@ export class GeocodingController {
|
||||
}
|
||||
|
||||
@Post('places')
|
||||
@UseGuards(ApiKeyGuard)
|
||||
@ApiOperation({ summary: 'Add a new location (User Submitted)' })
|
||||
async addPlace(@Body() placeData: any) {
|
||||
return this.geocodingService.addPlace(placeData);
|
||||
}
|
||||
|
||||
@Delete('places')
|
||||
@UseGuards(ApiKeyGuard)
|
||||
@ApiOperation({ summary: 'Delete a place by name or ID' })
|
||||
@ApiQuery({ name: 'name', required: false })
|
||||
@ApiQuery({ name: 'id', required: false, type: Number })
|
||||
@@ -79,12 +80,14 @@ export class GeocodingController {
|
||||
}
|
||||
|
||||
@Post('upsert-place')
|
||||
@UseGuards(ApiKeyGuard)
|
||||
@ApiOperation({ summary: 'Add or Update a location (Automated Scraper)' })
|
||||
async upsertPlace(@Body() placeData: any) {
|
||||
return this.geocodingService.upsertPlace(placeData);
|
||||
}
|
||||
|
||||
@Post('upsert-batch')
|
||||
@UseGuards(ApiKeyGuard)
|
||||
@ApiOperation({ summary: 'Add or Update multiple locations in bulk' })
|
||||
async upsertBatch(@Body() body: { places: any[] }) {
|
||||
return this.geocodingService.upsertBatch(body.places);
|
||||
|
||||
Reference in New Issue
Block a user