Merge branch 'dev' into route-processing
Conflict resolution: - build.gradle.kts: dev version (keep nstart.cloud repo + jacoco/asm mavenCentral) - settings.gradle.kts: project name from route-processing (observatio-terrae), rest from dev - config addresses (application-local, pcp-mission-planing-service, pcp-dynamic-plan application.yaml): dev versions - menu.html: merged both branches (TGU planning + bookings items) - CatalogControllerTest.kt: merged both mocks (TguPlanningService + BallisticsService) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+55
-7
@@ -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,12 +28,57 @@ class TLEController {
|
||||
private lateinit var celestrakService: CelesTrakService
|
||||
|
||||
@GetMapping()
|
||||
fun all() = tleRepository.findAll().map { tle ->
|
||||
val t = tle.tle.split("\r\n")
|
||||
TLEExtensionDTO(
|
||||
tle.satelliteId,
|
||||
tle.revolution,
|
||||
TLEDTO(t[0], t[1], t[2])
|
||||
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): 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() }
|
||||
val header = when {
|
||||
lines.size >= 3 -> lines[0]
|
||||
else -> null
|
||||
}
|
||||
val first = when {
|
||||
lines.size >= 3 -> lines[1]
|
||||
lines.size >= 2 -> lines[0]
|
||||
else -> " ".repeat(69)
|
||||
}
|
||||
val second = when {
|
||||
lines.size >= 3 -> lines[2]
|
||||
lines.size >= 2 -> lines[1]
|
||||
else -> " ".repeat(69)
|
||||
}
|
||||
|
||||
return TLEExtensionDTO(
|
||||
satelliteId,
|
||||
revolution,
|
||||
TLEDTO(header, first, second)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,4 +99,4 @@ class TLEController {
|
||||
fun tleFromSource(@RequestParam noradIn : Long, @RequestParam("message") sendMessage : Boolean) =
|
||||
celestrakService.getTleByNoradIdRaw(noradIn, false, sendMessage)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -9,6 +9,8 @@ interface TLERepository : JpaRepository<TLEEntity, Long> {
|
||||
|
||||
fun findAllBySatelliteId(id : Long) : List<TLEEntity>
|
||||
|
||||
fun findAllBySatelliteIdOrderByTimeTleAsc(id: Long): List<TLEEntity>
|
||||
|
||||
fun countBySatelliteId(id: Long): Long
|
||||
|
||||
fun deleteAllBySatelliteId(id: Long): Long
|
||||
|
||||
Reference in New Issue
Block a user