diff --git a/frontend/pages/_author/_slug.vue b/frontend/pages/_author/_slug.vue index 98fd087f..b4d1be59 100644 --- a/frontend/pages/_author/_slug.vue +++ b/frontend/pages/_author/_slug.vue @@ -62,14 +62,14 @@ {{ $t('project.actions.adminActions') }} - + - {{ $t('project.actions.flagHistory', []) }} + {{ $t('project.actions.flagHistory', [project.info.flagCount]) }} - + - {{ $t('project.actions.staffNotes', []) }} + {{ $t('project.actions.staffNotes', [project.info.noteCount]) }} diff --git a/frontend/types/internal/projects.d.ts b/frontend/types/internal/projects.d.ts index cd0bd87f..f5a61a7b 100644 --- a/frontend/types/internal/projects.d.ts +++ b/frontend/types/internal/projects.d.ts @@ -11,6 +11,7 @@ declare module 'hangar-internal' { interface HangarProjectInfo { publicVersions: number; + flagCount: number; noteCount: number; starCount: number; watcherCount: number; diff --git a/src/main/java/io/papermc/hangar/db/dao/internal/HangarProjectsDAO.java b/src/main/java/io/papermc/hangar/db/dao/internal/HangarProjectsDAO.java index cf7f6ac5..7c9cd996 100644 --- a/src/main/java/io/papermc/hangar/db/dao/internal/HangarProjectsDAO.java +++ b/src/main/java/io/papermc/hangar/db/dao/internal/HangarProjectsDAO.java @@ -71,6 +71,7 @@ public interface HangarProjectsDAO { @RegisterConstructorMapper(HangarProjectInfo.class) @SqlQuery("SELECT count(pv.*) public_versions," + + " count(pf.*) flag_count," + " count(ps.*) star_count," + " count(pw.*) watcher_count," + " coalesce(jsonb_array_length(p.notes->'messages'), 0) note_count" + @@ -78,6 +79,7 @@ public interface HangarProjectsDAO { " LEFT JOIN project_versions pv ON p.id = pv.project_id AND pv.visibility = 0" + " LEFT JOIN project_stars ps ON p.id = ps.project_id" + " LEFT JOIN project_watchers pw ON p.id = pw.project_id" + + " LEFT JOIN project_flags pf ON p.id = pf.project_id" + " WHERE p.id = :projectId" + " GROUP BY p.id") HangarProjectInfo getHangarProjectInfo(long projectId); diff --git a/src/main/java/io/papermc/hangar/model/internal/HangarProject.java b/src/main/java/io/papermc/hangar/model/internal/HangarProject.java index 04d3b381..034573e5 100644 --- a/src/main/java/io/papermc/hangar/model/internal/HangarProject.java +++ b/src/main/java/io/papermc/hangar/model/internal/HangarProject.java @@ -20,7 +20,7 @@ public class HangarProject extends Project implements Joinable private final String lastVisibilityChangeUserName; private final HangarProjectInfo info; private final Collection pages; - + public HangarProject(Project project, long id, ProjectOwner owner, List> members, String lastVisibilityChangeComment, String lastVisibilityChangeUserName, HangarProjectInfo info, Collection pages) { super(project.getCreatedAt(), project.getName(), project.getNamespace(), project.getPromotedVersions(), project.getStats(), project.getCategory(), project.getDescription(), project.getLastUpdated(), project.getVisibility(), project.getUserActions(), project.getSettings()); this.id = id; @@ -82,12 +82,14 @@ public class HangarProject extends Project implements Joinable public static class HangarProjectInfo { private final int publicVersions; + private final int flagCount; private final int noteCount; private final long starCount; private final long watcherCount; - public HangarProjectInfo(int publicVersions, int noteCount, long starCount, long watcherCount) { + public HangarProjectInfo(int publicVersions, int flagCount, int noteCount, long starCount, long watcherCount) { this.publicVersions = publicVersions; + this.flagCount = flagCount; this.noteCount = noteCount; this.starCount = starCount; this.watcherCount = watcherCount; @@ -97,6 +99,11 @@ public class HangarProject extends Project implements Joinable return publicVersions; } + @RequiresPermission(NamedPermission.MOD_NOTES_AND_FLAGS) + public int getFlagCount() { + return flagCount; + } + @RequiresPermission(NamedPermission.MOD_NOTES_AND_FLAGS) public int getNoteCount() { return noteCount;