Skip to content
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

feat: version查询数量调整#2761 #2764

Merged
merged 2 commits into from
Nov 18, 2024
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 @@ -31,5 +31,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties

@ConfigurationProperties(prefix = "conan")
data class ConanProperties(
var domain: String = "localhost"
var domain: String = "localhost",
var pageSize: Int = 500
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.tencent.bkrepo.common.artifact.api.ArtifactInfo
import com.tencent.bkrepo.common.artifact.path.PathUtils
import com.tencent.bkrepo.common.metadata.service.node.NodeService
import com.tencent.bkrepo.common.metadata.service.packages.PackageService
import com.tencent.bkrepo.conan.config.ConanProperties
import com.tencent.bkrepo.conan.constant.INDEX_JSON
import com.tencent.bkrepo.conan.pojo.IndexInfo
import com.tencent.bkrepo.conan.pojo.RevisionInfo
Expand Down Expand Up @@ -60,7 +61,9 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

@Service
class ConanExtServiceImpl : ConanExtService {
class ConanExtServiceImpl(
private val properties: ConanProperties
) : ConanExtService {

@Autowired
lateinit var nodeService: NodeService
Expand Down Expand Up @@ -113,20 +116,22 @@ class ConanExtServiceImpl : ConanExtService {
private fun packageSearch(projectId: String, repoName: String, indexRefresh: Boolean) {
// 查询包
var pageNumber = 1
var packageOption = PackageListOption(pageNumber = pageNumber, pageSize = DEFAULT_PAGE_SIZE)
var packageOption = PackageListOption(pageNumber = pageNumber, pageSize = properties.pageSize)
var packagePage = packageService.listPackagePage(projectId, repoName, option = packageOption)
while (packagePage.records.isNotEmpty()) {
packagePage.records.forEach { pkg -> versionSearch(projectId, repoName, pkg.key, indexRefresh) }
pageNumber += 1
packageOption = PackageListOption(pageNumber = pageNumber, pageSize = DEFAULT_PAGE_SIZE)
packageOption = PackageListOption(pageNumber = pageNumber, pageSize = properties.pageSize)
packagePage = packageService.listPackagePage(projectId, repoName, option = packageOption)
}
}

private fun versionSearch(projectId: String, repoName: String, key: String, indexRefresh: Boolean) {
// 查询包
var pageNumber = 1
var versionOption = VersionListOption(pageNumber = pageNumber, pageSize = DEFAULT_PAGE_SIZE)
var versionOption = VersionListOption(
pageNumber = pageNumber, pageSize = properties.pageSize, sortProperty = "createdDate"
)
var versionPage = packageService.listVersionPage(projectId, repoName, key, option = versionOption)
while (versionPage.records.isNotEmpty()) {
versionPage.records.forEach {
Expand All @@ -137,7 +142,9 @@ class ConanExtServiceImpl : ConanExtService {
}
}
pageNumber += 1
versionOption = VersionListOption(pageNumber = pageNumber, pageSize = DEFAULT_PAGE_SIZE)
versionOption = VersionListOption(
pageNumber = pageNumber, pageSize = properties.pageSize, sortProperty = "createdDate"
)
versionPage = packageService.listVersionPage(projectId, repoName, key, option = versionOption)
}
}
Expand Down Expand Up @@ -258,7 +265,7 @@ class ConanExtServiceImpl : ConanExtService {
do {
val option = NodeListOption(
pageNumber = pageNumber,
pageSize = DEFAULT_PAGE_SIZE,
pageSize = properties.pageSize,
includeFolder = true,
includeMetadata = false,
deep = false
Expand All @@ -272,7 +279,7 @@ class ConanExtServiceImpl : ConanExtService {
}
result.addAll(records.filter { it.folder }.map { Pair(it.name, it.lastModifiedDate) })
pageNumber++
} while (records.size == DEFAULT_PAGE_SIZE)
} while (records.size == properties.pageSize)
return result
}

Expand All @@ -299,6 +306,5 @@ class ConanExtServiceImpl : ConanExtService {

companion object {
val logger: Logger = LoggerFactory.getLogger(ConanExtServiceImpl::class.java)
private const val DEFAULT_PAGE_SIZE = 1000
}
}
Loading