Skip to content

Fix version sorting by using SemVer instead of publishedDate#168

Merged
Moustachauve merged 5 commits intomainfrom
hotfix/version-sorting
May 6, 2026
Merged

Fix version sorting by using SemVer instead of publishedDate#168
Moustachauve merged 5 commits intomainfrom
hotfix/version-sorting

Conversation

@Moustachauve
Copy link
Copy Markdown
Owner

Fixes #167

@Moustachauve Moustachauve added fix patch For fixes. labels May 5, 2026
@github-actions github-actions Bot added the bug Something isn't working label May 5, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the retrieval of the latest stable and beta versions by replacing specific SQL queries with a general repository fetch followed by client-side filtering and sorting using a new semantic versioning comparator. Feedback focuses on improving performance and memory efficiency by fetching version metadata before loading assets and optimizing the comparator to avoid redundant parsing of version tags.

@Moustachauve
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates the logic for identifying the latest stable and beta versions from SQL queries in the DAO to the repository layer. It introduces a SemVerComparator using the semver4j library to ensure versions are compared correctly, with a fallback to the publication date for invalid semantic tags. Unit tests have been added to validate this new sorting behavior. The review feedback suggests improving code readability and idiomaticity by using imports instead of fully qualified names, adopting camelCase for property names, and utilizing when expressions.

@Moustachauve
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates the logic for identifying the latest stable and beta versions from SQL queries in VersionDao to Kotlin code within VersionWithAssetsRepository. It introduces a semVerComparator that uses the Semver library to accurately compare version tags, falling back to publication dates when necessary. Unit tests were added to verify the sorting logic. The reviewer suggested changing the visibility of the new comparator and helper function to internal to maintain a cleaner public API.

versionDao.getVersionByTagName(repositoryId, tagName)

companion object {
val semVerComparator =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The semVerComparator is currently public. Since it is an implementation detail used for sorting versions within this repository and its associated tests, consider changing its visibility to internal to maintain a cleaner public API.

Suggested change
val semVerComparator =
internal val semVerComparator =

}
}

fun getLatestVersion(versions: List<Version>): Version? = versions.map {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The getLatestVersion function is currently public. Consider making it internal to restrict its scope to the module, as it is primarily a helper for the repository's public methods and for unit testing.

Suggested change
fun getLatestVersion(versions: List<Version>): Version? = versions.map {
internal fun getLatestVersion(versions: List<Version>): Version? = versions.map {

@Moustachauve Moustachauve merged commit 9ac2a6a into main May 6, 2026
4 checks passed
@Moustachauve Moustachauve deleted the hotfix/version-sorting branch May 6, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix patch For fixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Versions ordered based on Github publishedAt can be wrong

1 participant