Skip to content

Commit

Permalink
Fix the auto-updating of the project version
Browse files Browse the repository at this point in the history
  • Loading branch information
N7ghtm4r3 committed Jan 19, 2024
1 parent 24228c0 commit f130add
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ private String manageUpdateStatus(String id, String token, String projectId, Str
if (isPublishing) {
if (status != IN_DEVELOPMENT)
return failedResponse("An update to be published must be IN_DEVELOPMENT first");
projectsHelper.publishUpdate(projectId, updateId, id);
projectsHelper.publishUpdate(projectId, updateId, id, update.getTargetVersion());
} else {
if (status != SCHEDULED)
return failedResponse("An update to be published must be SCHEDULED first");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,11 @@ public void startUpdate(String projectId, String updateId, String userId) {
* @param projectId: the project identifier
* @param updateId: the update identifier
* @param userId: the user identifier who publish the update
* @param updateVersion: the version of the update to set as last version of the project
*/
public void publishUpdate(String projectId, String updateId, String userId) {
public void publishUpdate(String projectId, String updateId, String userId, String updateVersion) {
updatesRepository.publishUpdate(updateId, System.currentTimeMillis(), userId);
projectsRepository.updateProjectVersion(userId, projectId, updateVersion);
if (projectsRepository.getProjectById(projectId).hasGroups()) {
changelogsCreator.updatePublished(updatesRepository.getUpdateById(projectId, updateId).getTargetVersion(),
projectId, userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ void editProject(
@Param(PROJECT_REPOSITORY_KEY) String repository
);

/**
* Method to execute the query to update to the last published update version
* the version of the {@link Project}
*
* @param author: the author of the project
* @param projectId: the project identifier
* @param version: the last version of the project
*/
@Modifying(clearAutomatically = true)
@Transactional
@Query(
value = "UPDATE " + PROJECTS_KEY + " SET "
+ PROJECT_VERSION_KEY + "=:" + PROJECT_VERSION_KEY
+ " WHERE " + AUTHOR_KEY + "=:" + AUTHOR_KEY + " AND "
+ IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY,
nativeQuery = true
)
void updateProjectVersion(
@Param(AUTHOR_KEY) String author,
@Param(IDENTIFIER_KEY) String projectId,
@Param(PROJECT_VERSION_KEY) String version
);

/**
* Method to execute the query to select an existing {@link Project}
*
Expand Down

0 comments on commit f130add

Please sign in to comment.