fix(backend): display proper project main page

This commit is contained in:
MiniDigger | Martin 2023-01-19 21:54:44 +01:00
parent 82f3040283
commit a9d145cd1c
3 changed files with 13 additions and 1 deletions

View File

@ -31,6 +31,14 @@ public interface HangarProjectPagesDAO {
" WHERE pp.id = :id")
ExtendedProjectPage getProjectPage(long id);
@SqlQuery("""
SELECT pp.*, true as home
FROM project_pages pp
JOIN project_home_pages php ON pp.id = php.page_id
WHERE php.project_id = :projectId
""")
ExtendedProjectPage getProjectHomePage(long projectId);
@SqlQuery("SELECT pp.*, TRUE AS home " +
" FROM project_pages pp" +
" JOIN projects p ON pp.project_id = p.id" +

View File

@ -130,6 +130,10 @@ public class ProjectPageService extends HangarComponent {
return this.hangarProjectPagesDAO.getProjectPage(id);
}
public ExtendedProjectPage getProjectHomePage(final long projectId) {
return this.hangarProjectPagesDAO.getProjectHomePage(projectId);
}
@Transactional
public String createProjectPage(final long projectId, final NewProjectPage newProjectPage) {
String slug = StringUtils.slugify(newProjectPage.getName());

View File

@ -132,7 +132,7 @@ public class ProjectService extends HangarComponent {
}
}
final ExtendedProjectPage projectPage = projectPageService.getProjectPage(project.getRight().getId());
final ExtendedProjectPage projectPage = this.projectPageService.getProjectHomePage(project.getRight().getId());
final HangarProject hangarProject = new HangarProject(project.getRight(), projectOwner, members, lastVisibilityChangeComment, lastVisibilityChangeUserName, info, pages.values(), pinnedVersions, mainChannelVersions, projectPage);
hangarProject.setAvatarUrl(this.avatarService.getProjectAvatarUrl(hangarProject.getProjectId(), hangarProject.getNamespace().getOwner()));
return hangarProject;