8000 Clean up code by taeyeon-Kim · Pull Request #81 · naver/scavenger · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Clean up code #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface AgentRepository : DelegatableJdbcRepository<AgentEntity, String> {
agent_state.customerId = :customerId
"""
)
fun findAgentsByCustomerId(@Param("customerId") customerId: Long): List<AgentEntity>
fun findAllAgentsByCustomerId(@Param("customerId") customerId: Long): List<AgentEntity>

@Modifying
@Query("DELETE FROM agent_state WHERE customerId = :customerId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository

@Repository
interface ApplicationRepository : DelegatableJdbcRepository<ApplicationEntity, String> {
fun findByCustomerId(customerId: Long): List<ApplicationEntity>
fun findAllByCustomerId(customerId: Long): List<ApplicationEntity>

fun findByCustomerIdAndId(customerId: Long, id: Long): ApplicationEntity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository

@Repository
interface EnvironmentRepository : DelegatableJdbcRepository<EnvironmentEntity, String> {
fun findByCustomerId(customerId: Long): List<EnvironmentEntity>
fun findAllByCustomerId(customerId: Long): List<EnvironmentEntity>

fun findByCustomerIdAndId(customerId: Long, id: Long): EnvironmentEntity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository

@Repository
interface GithubMappingRepository : DelegatableJdbcRepository<GithubMappingEntity, Long> {
fun findByCustomerId(customerId: Long): List<GithubMappingEntity>
fun findAllByCustomerId(customerId: Long): List<GithubMappingEntity>

@Modifying
@Query("DELETE FROM github_mappings WHERE customerId = :customerId AND id = :id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface MethodInvocationRepository : DelegatableJdbcRepository<MethodInvocatio
GROUP BY methods.signature
"""
)
fun findMethodInvocations(
fun findAllMethodInvocations(
@Param("customerId") customerId: Long,
@Param("applicationIdList") applicationIdList: List<Long>,
@Param("environmentIdList") environmentIdList: List<Long>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ interface SnapshotApplicationRepository : DelegatableJdbcRepository<ApplicationR
fun countByCustomerIdAndApplicationId(customerId: Long, applicationId: Long): Long

@Query("SELECT snapshotId FROM snapshot_application WHERE customerId = :customerId AND applicationId = :applicationId")
fun findByCustomerIdAndApplicationId(@Param("customerId") customerId: Long, @Param("applicationId") applicationId: Long): List<Long>
fun findAllByCustomerIdAndApplicationId(@Param("customerId") customerId: Long, @Param("applicationId") applicationId: Long): List<Long>

@Modifying
@Query("DELETE FROM snapshot_application WHERE customerId = :customerId AND snapshotId = :snapshotId")
fun deleteByCustomerIdAndSnapshotId(customerId: Long, snapshotId: Long)

@Query("SELECT snapshotId FROM snapshot_application WHERE customerId = :customerId AND snapshotId = :snapshotId")
fun findByCustomerIdAndSnapshotId(@Param("customerId") customerId: Long, @Param("snapshotId") snapshotId: Long): List<Long>
fun findAllByCustomerIdAndSnapshotId(@Param("customerId") customerId: Long, @Param("snapshotId") snapshotId: Long): List<Long>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ interface SnapshotEnvironmentRepository : DelegatableJdbcRepository<EnvironmentR
fun countByCustomerIdAndEnvironmentId(customerId: Long, environmentId: Long): Long

@Query("SELECT snapshotId FROM snapshot_environment WHERE customerId = :customerId AND environmentId = :environmentId")
fun findByCustomerIdAndEnvironmentId(@Param("customerId") customerId: Long, @Param("environmentId") environmentId: Long): List<Long>
fun findAllByCustomerIdAndEnvironmentId(@Param("customerId") customerId: Long, @Param("environmentId") environmentId: Long): List<Long>

@Modifying
@Query("DELETE FROM snapshot_environment WHERE customerId = :customerId AND snapshotId = :snapshotId")
fun deleteByCustomerIdAndSnapshotId(customerId: Long, snapshotId: Long)

@Query("SELECT snapshotId FROM snapshot_environment WHERE customerId = :customerId AND snapshotId = :snapshotId")
fun findByCustomerIdAndSnapshotId(@Param("customerId") customerId: Long, @Param("snapshotId") snapshotId: Long): List<Long>
fun findAllByCustomerIdAndSnapshotId(@Param("customerId") customerId: Long, @Param("snapshotId") snapshotId: Long): List<Long>
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SnapshotNodeDao(
snapshotId: Long
): List<SnapshotExportDbRow> {
return select(
sql.findAllExportSnapshotNode(),
sql.selectAllExportSnapshotNode(),
mapParameterSource()
.addValue("customerId", customerId)
.addValue("snapshotId", snapshotId),
Expand All @@ -34,7 +34,7 @@ class SnapshotNodeDao(
)
}

fun selectAllBySignatureContaining(
fun findAllBySignatureContaining(
customerId: Long,
snapshotId: Long,
signature: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.util.Optional

@Repository
interface SnapshotRepository : DelegatableJdbcRepository<SnapshotEntity, Long> {
fun findByCustomerId(customerId: Long): List<SnapshotEntity>
fun findAllByCustomerId(customerId: Long): List<SnapshotEntity>

fun findByCustomerIdAndId(customerId: Long, id: Long): Optional<SnapshotEntity>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.navercorp.spring.data.jdbc.plus.sql.support.SqlGeneratorSupport

class SnapshotNodeSql : SqlGeneratorSupport() {

fun findAllExportSnapshotNode(): String =
fun selectAllExportSnapshotNode(): String =
"""
SELECT
snapshots.filterInvokedAtMillis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import org.springframework.stereotype.Service
@Service
class AgentService(val agentRepository: AgentRepository) {
fun getAgents(customerId: Long): List<AgentEntity> {
return agentRepository.findAgentsByCustomerId(customerId)
return agentRepository.findAllAgentsByCustomerId(customerId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class ApplicationService(
val snapshotService: SnapshotService
) {
fun getApplications(customerId: Long): List<ApplicationDto> {
return applicationRepository.findByCustomerId(customerId).map { ApplicationDto.from(it) }
return applicationRepository.findAllByCustomerId(customerId).map { ApplicationDto.from(it) }
}

fun getApplicationsDetail(customerId: Long): List<ApplicationDetailDto> {
val applications = applicationRepository.findByCustomerId(customerId)
val applications = applicationRepository.findAllByCustomerId(customerId)
return applications
.map { applicationEntity: ApplicationEntity ->
val applicationId = applicationEntity.id
Expand All @@ -47,7 +47,7 @@ class ApplicationService(
checkNotNull(applicationRepository.findByCustomerIdAndId(customerId, applicationId)) { "잘못된 접근" }
jvmRepository.deleteByCustomerIdAndApplicationId(customerId, applicationId)
invocationRepository.deleteByCustomerIdAndApplicationId(customerId, applicationId)
snapshotApplicationRepository.findByCustomerIdAndApplicationId(customerId, applicationId)
snapshotApplicationRepository.findAllByCustomerIdAndApplicationId(customerId, applicationId)
.forEach { snapshotId -> snapshotService.deleteSnapshot(customerId, snapshotId) }
applicationRepository.deleteByCustomerIdAndId(customerId, applicationId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CustomerService(
fun deleteCustomer(groupId: String, userId: String, customerId: Long, remainCustomer: Boolean = true) {
val customer = customerRepository.findById(customerId).orElseThrow()
if (customer.groupId == groupId) {
snapshotRepository.findByCustomerId(customerId).forEach {
snapshotRepository.findAllByCustomerId(customerId).forEach {
snapshotApplicationRepository.deleteByCustomerIdAndSnapshotId(customerId, requireNotNull(it.id))
snapshotEnvironmentRepository.deleteByCustomerIdAndSnapshotId(customerId, it.id)
snapshotNodeRepository.deleteAllByCustomerIdAndSnapshotId(customerId, it.id)
Expand Down
528C
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class EnvironmentService(
val snapshotService: SnapshotService
) {
fun getEnvironments(customerId: Long): List<EnvironmentDto> {
return environmentRepository.findByCustomerId(customerId).map { EnvironmentDto.from(it) }
return environmentRepository.findAllByCustomerId(customerId).map { EnvironmentDto.from(it) }
}

fun getEnvironmentsDetail(customerId: Long): List<EnvironmentDetailDto> {
val environments = environmentRepository.findByCustomerId(customerId)
val environments = environmentRepository.findAllByCustomerId(customerId)
return environments
.map { environmentEntity: EnvironmentEntity ->
val environmentId = environmentEntity.id
Expand All @@ -47,7 +47,7 @@ class EnvironmentService(
checkNotNull(environmentRepository.findByCustomerIdAndId(customerId, environmentId)) { "잘못된 접근" }
jvmRepository.deleteByCustomerIdAndEnvironmentId(customerId, environmentId)
invocationRepository.deleteByCustomerIdAndEnvironmentId(customerId, environmentId)
snapshotEnvironmentRepository.findByCustomerIdAndEnvironmentId(customerId, environmentId)
snapshotEnvironmentRepository.findAllByCustomerIdAndEnvironmentId(customerId, environmentId)
.forEach { snapshotId -> snapshotService.deleteSnapshot(customerId, snapshotId) }
environmentRepository.deleteByCustomerIdAndId(customerId, environmentId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.springframework.stereotype.Service
class GithubMappingService(val githubMappingRepository: GithubMappingRepository) {

fun getGithubMappings(customerId: Long): List<GithubMappingDto> {
return githubMappingRepository.findByCustomerId(customerId).map { GithubMappingDto.from(it) }
return githubMappingRepository.findAllByCustomerId(customerId).map { GithubMappingDto.from(it) }
}

fun createGithubMapping(customerId: Long, basePackage: String, url: String): GithubMappingDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SnapshotNodeService(
signature: String,
snapshotNodeId: Long? = null
): List<SnapshotNodeEntity> {
return snapshotNodeDao.selectAllBySignatureContaining(customerId, snapshotId, signature, snapshotNodeId)
return snapshotNodeDao.findAllBySignatureContaining(customerId, snapshotId, signature, snapshotNodeId)
}

private fun filterByPackagesAntMatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SnapshotService(
filterInvokedAtMillis: Long,
packages: String
): SnapshotDto {
val methodInvocations = methodInvocationRepository.findMethodInvocations(customerId, applicationIdList, environmentIdList)
val methodInvocations = methodInvocationRepository.findAllMethodInvocations(customerId, applicationIdList, environmentIdList)
val snapshotEntity = SnapshotEntity(
name = name,
customerId = customerId,
Expand All @@ -58,7 +58,7 @@ class SnapshotService(
packages: String
): SnapshotDto {
val existing = snapshotDao.findByCustomerIdAndId(customerId, snapshotId).orElseThrow()
val methodInvocations = methodInvocationRepository.findMethodInvocations(existing.customerId, applicationIdList, environmentIdList)
val methodInvocations = methodInvocationRepository.findAllMethodInvocations(existing.customerId, applicationIdList, environmentIdList)
val snapshot = existing.copy(packages = packages, name = name, filterInvokedAtMillis = filterInvokedAtMillis)

snapshotDao.updateSnapshot(snapshot)
Expand Down Expand Up @@ -86,7 +86,7 @@ class SnapshotService(
val snapshot = snapshotDao.findByCustomerIdAndId(customerId, snapshotId).orElseThrow()
val applicationIdList: List<Long> = snapshot.applications.map { it.applicationId }
val environmentIdList: List<Long> = snapshot.environments.map { it.environmentId }
val methodInvocations = methodInvocationRepository.findMethodInvocations(snapshot.customerId, applicationIdList, environmentIdList)
val methodInvocations = methodInvocationRepository.findAllMethodInvocations(snapshot.customerId, applicationIdList, environmentIdList)

snapshotNodeService.deleteSnapshotNode(snapshot.customerId, snapshotId)
snapshotNodeService.createAndSaveSnapshotNodes(snapshot, methodInvocations)
Expand All @@ -111,7 +111,7 @@ class SnapshotService(
}

fun listSnapshots(customerId: Long): List<SnapshotDto> {
return snapshotDao.findByCustomerId(customerId).map { SnapshotDto.from(it) }
return snapshotDao.findAllByCustomerId(customerId).map { SnapshotDto.from(it) }
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AgentRepositoryTest {
private lateinit var sut: AgentRepository

@Test
fun findAgentsByCustomerId() {
assertThat(sut.findAgentsByCustomerId(1)).isNotNull
fun findAllAgentsByCustomerId() {
assertThat(sut.findAllAgentsByCustomerId(1)).isNotNull
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class ApplicationRepositoryTest {
private lateinit var sut: ApplicationRepository

@Test
fun findByCustomerId() {
assertThat(sut.findByCustomerId(1)).hasSize(1)
fun findAllByCustomerId() {
assertThat(sut.findAllByCustomerId(1)).hasSize(1)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class EnvironmentRepositoryTest {
private lateinit var sut: EnvironmentRepository

@Test
fun findByCustomerId() {
assertThat(sut.findByCustomerId(1)).hasSize(1)
fun findAllByCustomerId() {
assertThat(sut.findAllByCustomerId(1)).hasSize(1)
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions ...ger-api/src/test/kotlin/com/navercorp/scavenger/repository/GithubMappingRepositoryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class GithubMappingRepositoryTest {
private lateinit var sut: GithubMappingRepository

@Test
fun findByCustomerId() {
assertThat(sut.findByCustomerId(1)).hasSize(1)
fun findAllByCustomerId() {
assertThat(sut.findAllByCustomerId(1)).hasSize(1)
}

@Test
@Transactional
fun deleteByCustomerIdAndId() {
sut.deleteByCustomerIdAndId(1, 1)

assertThat(sut.findByCustomerId(1)).hasSize(0)
assertThat(sut.findAllByCustomerId(1)).hasSize(0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MethodInvocationRepositoryTest {
private lateinit var sut: MethodInvocationRepository

@Test
fun findMethodInvocations() {
assertThat(sut.findMethodInvocations(1, listOf(1), listOf(1))).hasSizeGreaterThanOrEqualTo(0)
fun findAllMethodInvocations() {
assertThat(sut.findAllMethodInvocations(1, listOf(1), listOf(1))).hasSizeGreaterThanOrEqualTo(0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class SnapshotApplicationRepositoryTest {
}

@Test
fun findByCustomerIdAndApplicationId() {
assertThat(sut.findByCustomerIdAndApplicationId(customerId, applicationId)).hasSizeGreaterThan(0)
fun findAllByCustomerIdAndApplicationId() {
assertThat(sut.findAllByCustomerIdAndApplicationId(customerId, applicationId)).hasSizeGreaterThan(0)
}

@Test
@Transactional
fun deleteByCustomerIdAndSnapshotId() {
sut.deleteByCustomerIdAndSnapshotId(customerId, snapshotId)
assertThat(sut.findByCustomerIdAndSnapshotId(customerId, snapshotId)).hasSize(0)
assertThat(sut.findAllByCustomerIdAndSnapshotId(customerId, snapshotId)).hasSize(0)
}

@Test
Expand All @@ -42,6 +42,6 @@ class SnapshotApplicationRepositoryTest {
).toSet()
sut.insertAll(param)

assertThat(sut.findByCustomerIdAndApplicationId(0, 1)).hasSize(2)
assertThat(sut.findAllByCustomerIdAndApplicationId(0, 1)).hasSize(2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class SnapshotEnvironmentRepositoryTest {
}

@Test
fun findByCustomerIdAndApplicationId() {
assertThat(sut.findByCustomerIdAndEnvironmentId(customerId, environmentId)).hasSizeGreaterThan(0)
fun findAllByCustomerIdAndEnvironmentId() {
assertThat(sut.findAllByCustomerIdAndEnvironmentId(customerId, environmentId)).hasSizeGreaterThan(0)
}

@Test
@Transactional
fun deleteByCustomerIdAndSnapshotId() {
sut.deleteByCustomerIdAndSnapshotId(customerId, snapshotId)
assertThat(sut.findByCustomerIdAndSnapshotId(customerId, snapshotId)).hasSize(0)
assertThat(sut.findAllByCustomerIdAndSnapshotId(customerId, snapshotId)).hasSize(0)
}

@Test
Expand All @@ -42,6 +42,6 @@ class SnapshotEnvironmentRepositoryTest {
).toSet()
sut.insertAll(param)

assertThat(sut.findByCustomerIdAndEnvironmentId(0, 1)).hasSize(2)
assertThat(sut.findAllByCustomerIdAndEnvironmentId(0, 1)).hasSize(2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ class SnapshotNodeRepositoryTest {
}

@Test
fun selectAllBySignatureContaining() {
val result = sut.selectAllBySignatureContaining(customerId, snapshotId, parent)
fun findAllBySignatureContaining() {
val result = sut.findAllBySignatureContaining(customerId, snapshotId, parent)
assertThat(result).hasSizeGreaterThan(0)

assertThat(sut.selectAllBySignatureContaining(customerId, snapshotId, parent, result.last().id)).hasSize(0)
assertThat(sut.findAllBySignatureContaining(customerId, snapshotId, parent, result.last().id)).hasSize(0)

assertThat(sut.selectAllBySignatureContaining(customerId, snapshotId, "hello")).hasSize(1)
assertThat(sut.findAllBySignatureContaining(customerId, snapshotId, "hello")).hasSize(1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class SnapshotRepositoryTest {
private lateinit var sut: SnapshotDao

@Test
fun findByCustomerId() {
assertThat(sut.findByCustomerId(1)).hasSizeGreaterThan(0)
fun findAllByCustomerId() {
assertThat(sut.findAllByCustomerId(1)).hasSizeGreaterThan(0)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class AgentStateDao(
AgentStateRepository by agentStateRepository {
private val sql: AgentStateSql = super.sqls(::AgentStateSql)

fun findGarbageLastPolledAtBefore(customerId: Long, lastPolledAt: Instant): List<AgentStateEntity> {
fun findAllGarbageLastPolledAtBefore(customerId: Long, lastPolledAt: Instant): List<AgentStateEntity> {
return select(
sql.selectGarbageLastPolledAtBefore(),
sql.selectAllGarbageLastPolledAtBefore(),
mapParameterSource()
.addValue("customerId", customerId)
.addValue("lastPolledAt", lastPolledAt),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AgentStateSql : SqlGeneratorSupport() {
AND jvmUuid = :jvmUuid
""".trimIndent()

fun selectGarbageLastPolledAtBefore(): String =
fun selectAllGarbageLastPolledAtBefore(): String =
"""
SELECT
${sql.columns(AgentStateEntity::class.java)}
Expand Down
Loading
0