Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/1077 apps page reload pagination #840

Open
wants to merge 7 commits into
base: angular_fixes
Choose a base branch
from

Conversation

BeriBoss
Copy link
Contributor

@BeriBoss BeriBoss commented Feb 17, 2025

Bug: Incorrect Pagination on the Apps Page

The pagination on the Apps page was faulty. When on the page, a list of app servers with their apps was displayed, but neither the correct number of app servers (not the selected maximum results per page) nor the correct number of pages for all results was displayed.

Incorrect Behavior: If the maximum number of results per page was set to 10 and there were a total of 50 results, 7 app servers were displayed on the first page, but it was indicated that there were 5 pages. On the next page, 3 app servers were displayed, etc.

Correct Solution: 10 app servers should be displayed per page and it should be indicated that there are 5 pages.

Cause of the Error: The error was in the backend. The idea was that the frontend could make a REST call and specify the following query parameters:

  • start
  • limit
  • appServerName
  • releaseId

The endpoint should then return the filtered result with the correct offset (which page am I on) and the correct maximum number of results per page.

First Problem: The total number of results ( result.getB() ) was always returned as the number of all unfiltered Resource Entities with the ResourceType = APPLICATIONSERVER.

ch.mobi.itc.mobiliar.rest.apps.AppsRest#getApps:

return Response.status(OK).entity(appServersToResponse(result.getA())).header("X-total-count", result.getB()).build();

Solution to that would have been:

return Response.status(OK).entity(appServersToResponse(result.getA())).header("X-total-count", result.getA().size()).build();

Second Problem: Even if the total number of results had been corrected, the pagination would still not have worked. The reason for this was that the endpoint set a query that retrieved all Resource Entities with the ResourceType = APPLICATIONSERVER and the filtered name. The offset and limit were then set in the query:

   if (startIndex != null) {
            query.setFirstResult(startIndex);
        }
        
    if (maxResult != null) {
            query.setMaxResults(maxResult);
        }

The idea was to reduce the load time by only retrieving the "paginated" results directly. However, the problem was that this already paginated list of results was filtered twice in the business logic, so that the set start and limit no longer matched the final list.

Solution: The original solution would have been to correct the pagination, but this would have increased the load time (See commit: b695fa0 ). Since the DB was already under load, it was decided to remove the pagination and initially display only the first 20 app servers, as it was in the old version.

@BeriBoss BeriBoss force-pushed the bugfix/1077-apps-page-reload-pagination branch from bf3a5bb to 2f47ce9 Compare February 18, 2025 15:05
@BeriBoss BeriBoss changed the base branch from refactor/app-page to angular_fixes February 18, 2025 15:07
@BeriBoss BeriBoss marked this pull request as ready for review February 18, 2025 15:08
@BeriBoss BeriBoss closed this Feb 18, 2025
@BeriBoss BeriBoss reopened this Feb 18, 2025
@BeriBoss BeriBoss marked this pull request as draft February 20, 2025 08:28
@BeriBoss BeriBoss force-pushed the bugfix/1077-apps-page-reload-pagination branch from 2f47ce9 to a30daa2 Compare February 26, 2025 10:13
@BeriBoss BeriBoss marked this pull request as ready for review February 26, 2025 13:35
@@ -86,9 +86,8 @@ public void testGetAppServersWithApplications() throws Exception {
UserSettingsEntity userSettings = Mockito.mock(UserSettingsEntity.class);
Mockito.when(userSettingsService.getUserSettings(Mockito.anyString())).thenReturn(userSettings);
List<ResourceEntity> aslist = Arrays.asList(as);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, only a single app server is added to this list. Making the test more robust by mocking multiple application servers would be beneficial

@BeriBoss BeriBoss force-pushed the bugfix/1077-apps-page-reload-pagination branch from 9264edb to 22dea9d Compare March 3, 2025 08:44
@BeriBoss BeriBoss requested a review from llorentelemmc March 3, 2025 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants