анализ TLE
This commit is contained in:
+31
-4
@@ -1,5 +1,6 @@
|
||||
package space.nstart.pcp.tle_monitoring_service.controller
|
||||
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
@@ -12,12 +13,14 @@ import space.nstart.pcp.pcp_types_lib.dto.ballistics.TLEDTO
|
||||
import space.nstart.pcp.pcp_types_lib.dto.ballistics.TLEExtensionDTO
|
||||
import space.nstart.pcp.tle_monitoring_service.repository.TLERepository
|
||||
import space.nstart.pcp.tle_monitoring_service.service.CelesTrakService
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("v1/api/tle")
|
||||
class TLEController {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
@Autowired
|
||||
private lateinit var tleRepository: TLERepository
|
||||
@@ -25,11 +28,35 @@ class TLEController {
|
||||
private lateinit var celestrakService: CelesTrakService
|
||||
|
||||
@GetMapping()
|
||||
fun all() = tleRepository.findAll().map { tle -> tle.toDto() }
|
||||
fun all(): List<TLEExtensionDTO> {
|
||||
logger.info("TLE API all records request started")
|
||||
var records = emptyList<TLEExtensionDTO>()
|
||||
val durationMs = measureTimeMillis {
|
||||
records = tleRepository.findAll().map { tle -> tle.toDto() }
|
||||
}
|
||||
logger.info(
|
||||
"TLE API all records request completed: records={}, durationMs={}",
|
||||
records.size,
|
||||
durationMs
|
||||
)
|
||||
return records
|
||||
}
|
||||
|
||||
@GetMapping("/satellite/{satelliteId}")
|
||||
fun bySatellite(@PathVariable satelliteId: Long) =
|
||||
tleRepository.findAllBySatelliteIdOrderByTimeTleAsc(satelliteId).map { tle -> tle.toDto() }
|
||||
fun bySatellite(@PathVariable satelliteId: Long): List<TLEExtensionDTO> {
|
||||
logger.info("TLE API satellite records request started: satelliteId={}", satelliteId)
|
||||
var records = emptyList<TLEExtensionDTO>()
|
||||
val durationMs = measureTimeMillis {
|
||||
records = tleRepository.findAllBySatelliteIdOrderByTimeTleAsc(satelliteId).map { tle -> tle.toDto() }
|
||||
}
|
||||
logger.info(
|
||||
"TLE API satellite records request completed: satelliteId={}, records={}, durationMs={}",
|
||||
satelliteId,
|
||||
records.size,
|
||||
durationMs
|
||||
)
|
||||
return records
|
||||
}
|
||||
|
||||
private fun space.nstart.pcp.tle_monitoring_service.entity.TLEEntity.toDto(): TLEExtensionDTO {
|
||||
val lines = tle.lines().map { it.trimEnd() }.filter { it.isNotBlank() }
|
||||
@@ -72,4 +99,4 @@ class TLEController {
|
||||
fun tleFromSource(@RequestParam noradIn : Long, @RequestParam("message") sendMessage : Boolean) =
|
||||
celestrakService.getTleByNoradIdRaw(noradIn, false, sendMessage)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user