chore: Adding host as a parameter for get home page workspaces API (#38392)

## Description
Helper refactor for Seat based pricing feature for recording the
deployment host
Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/test sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12515621363>
> Commit: 481dcbce46d2fbcbb915a087f41e9c4db9de71e0
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12515621363&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Fri, 27 Dec 2024 12:14:36 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced workspace retrieval functionality to support optional
hostname parameter in user workspace requests.

- **Bug Fixes**
- Improved handling of user workspaces based on recently used order with
the inclusion of hostname.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Trisha Anand 2024-12-27 18:05:31 +05:30 committed by GitHub
parent 0255bce037
commit d36c2d87a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 6 deletions

View File

@ -108,9 +108,10 @@ public class WorkspaceControllerCE {
@JsonView(Views.Public.class)
@GetMapping("/home")
public Mono<ResponseDTO<List<Workspace>>> workspacesForHome() {
public Mono<ResponseDTO<List<Workspace>>> workspacesForHome(
@RequestHeader(name = "Host", required = false) String hostname) {
return userWorkspaceService
.getUserWorkspacesByRecentlyUsedOrder()
.getUserWorkspacesByRecentlyUsedOrder(hostname)
.map(workspaces -> new ResponseDTO<>(HttpStatus.OK.value(), workspaces, null));
}
}

View File

@ -24,5 +24,5 @@ public interface UserWorkspaceServiceCE {
Boolean isLastAdminRoleEntity(PermissionGroup permissionGroup);
Mono<List<Workspace>> getUserWorkspacesByRecentlyUsedOrder();
Mono<List<Workspace>> getUserWorkspacesByRecentlyUsedOrder(String hostname);
}

View File

@ -393,7 +393,7 @@ public class UserWorkspaceServiceCEImpl implements UserWorkspaceServiceCE {
* @return Mono of list of workspaces
*/
@Override
public Mono<List<Workspace>> getUserWorkspacesByRecentlyUsedOrder() {
public Mono<List<Workspace>> getUserWorkspacesByRecentlyUsedOrder(String hostname) {
Mono<List<String>> workspaceIdsMono = userDataService
.getForCurrentUser()

View File

@ -247,7 +247,7 @@ public class UserWorkspaceServiceUnitTest {
cleanup();
createDummyWorkspaces().blockLast();
StepVerifier.create(userWorkspaceService.getUserWorkspacesByRecentlyUsedOrder())
StepVerifier.create(userWorkspaceService.getUserWorkspacesByRecentlyUsedOrder(null))
.assertNext(workspaces -> {
assertThat(workspaces).hasSize(4);
workspaces.forEach(workspace -> {
@ -274,7 +274,7 @@ public class UserWorkspaceServiceUnitTest {
userData.setRecentlyUsedEntityIds(recentlyUsedEntityDTOs);
doReturn(Mono.just(userData)).when(userDataService).getForCurrentUser();
StepVerifier.create(userWorkspaceService.getUserWorkspacesByRecentlyUsedOrder())
StepVerifier.create(userWorkspaceService.getUserWorkspacesByRecentlyUsedOrder(null))
.assertNext(workspaces -> {
assertThat(workspaces).hasSize(4);
List<String> fetchedWorkspaceIds = new ArrayList<>();