diff --git a/backend/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectPagesDAO.java b/backend/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectPagesDAO.java index d8e750977..ad67d25e5 100644 --- a/backend/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectPagesDAO.java +++ b/backend/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectPagesDAO.java @@ -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" + diff --git a/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectPageService.java b/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectPageService.java index 4b437ff04..ba2b65d0d 100644 --- a/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectPageService.java +++ b/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectPageService.java @@ -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()); diff --git a/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java b/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java index acb4c27e4..fb01d59f6 100644 --- a/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java +++ b/backend/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java @@ -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;