diff --git a/backend/src/main/java/io/papermc/hangar/controller/api/v1/ProjectsController.java b/backend/src/main/java/io/papermc/hangar/controller/api/v1/ProjectsController.java index a3753da1f..7a74bd0c0 100644 --- a/backend/src/main/java/io/papermc/hangar/controller/api/v1/ProjectsController.java +++ b/backend/src/main/java/io/papermc/hangar/controller/api/v1/ProjectsController.java @@ -60,9 +60,9 @@ public ResponseEntity> getProjectMembers(final St @Override @ApplicableFilters({ProjectCategoryFilter.class, ProjectPlatformFilter.class, ProjectAuthorFilter.class, ProjectQueryFilter.class, ProjectLicenseFilter.class, ProjectMCVersionFilter.class, ProjectTagFilter.class}) @ApplicableSorters({SorterRegistry.VIEWS, SorterRegistry.DOWNLOADS, SorterRegistry.NEWEST, SorterRegistry.STARS, SorterRegistry.UPDATED, SorterRegistry.RECENT_DOWNLOADS, SorterRegistry.RECENT_VIEWS, SorterRegistry.SLUG}) - public ResponseEntity> getProjects(@Deprecated(forRemoval = true) final boolean orderWithRelevance, final @NotNull RequestPagination pagination) { + public ResponseEntity> getProjects(final boolean prioritizeExactMatch, final @NotNull RequestPagination pagination) { final boolean seeHidden = this.getGlobalPermissions().has(Permission.SeeHidden); - return ResponseEntity.ok(this.projectsApiService.getProjects(pagination, seeHidden)); + return ResponseEntity.ok(this.projectsApiService.getProjects(pagination, seeHidden, prioritizeExactMatch)); } @Override diff --git a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IProjectsController.java b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IProjectsController.java index 386f3244e..b58814026 100644 --- a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IProjectsController.java +++ b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IProjectsController.java @@ -91,7 +91,7 @@ default ResponseEntity> getProjectMembers( }) @GetMapping("/projects") ResponseEntity> getProjects( - @Parameter(deprecated = true, description = "No longer functions. Sort by (recent) stars, downloads, or views instead") @RequestParam(defaultValue = "true", required = false) boolean orderWithRelevance, + @Parameter(description = "Whether to prioritize the project with an exact name match if present") @RequestParam(defaultValue = "true", required = false) boolean prioritizeExactMatch, @Parameter(description = "Pagination information") @NotNull RequestPagination pagination ); diff --git a/backend/src/main/java/io/papermc/hangar/service/api/ProjectsApiService.java b/backend/src/main/java/io/papermc/hangar/service/api/ProjectsApiService.java index 908f205c4..0890b5642 100644 --- a/backend/src/main/java/io/papermc/hangar/service/api/ProjectsApiService.java +++ b/backend/src/main/java/io/papermc/hangar/service/api/ProjectsApiService.java @@ -69,7 +69,7 @@ public PaginatedResult getProjectWatchers(final String slug, final Request @Transactional(readOnly = true) @Cacheable(CacheConfig.PROJECTS) - public PaginatedResult getProjects(final RequestPagination pagination, final boolean seeHidden) { + public PaginatedResult getProjects(final RequestPagination pagination, final boolean seeHidden, final boolean prioritizeExactMatch) { // get query from filter String query = null; for (final Filter.FilterInstance filterInstance : pagination.getFilters().values()) { @@ -78,7 +78,7 @@ public PaginatedResult getProjects(final RequestPagination pagination, } } - if (query != null && !query.isBlank()) { + if (prioritizeExactMatch && query != null && !query.isBlank()) { pagination.getSorters().put("exact_match", sb -> sb.append(" exact_match ASC")); }