Skip to content

Commit

Permalink
feat: version查询数量调整#2761
Browse files Browse the repository at this point in the history
* feat: version查询数量调整#2761

* feat: version查询数量调整#2761
  • Loading branch information
zacYL authored Nov 18, 2024
1 parent a997b6e commit fd3e10e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
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
}
}

0 comments on commit fd3e10e

Please sign in to comment.