Fix for the incorrect device statistics shown in the app store. #508

Merged
tcdlpds merged 6 commits from ruwin/device-mgt-core:statistics into master 2 months ago
ruwin commented 2 months ago

Purpose

Description

This pull request addresses a bug fix to the incorrect device statistics shown in the app store.

The following changes have been made:

  • Filtered and removed device ids getting for the calculation, which are in REMOVED and DELETED statuses.
## Purpose * Fixed https://roadmap.entgra.net/issues/11657 ## Description This pull request addresses a bug fix to the incorrect device statistics shown in the app store. The following changes have been made: * Filtered and removed device ids getting for the calculation, which are in REMOVED and DELETED statuses.
ruwin added 2 commits 2 months ago
arshana790 reviewed 2 months ago
List<Integer> removedIds = devices.stream()
.filter(device -> {
String status = String.valueOf(device.getEnrolmentInfo().getStatus());
return "REMOVED".equalsIgnoreCase(status) || "DELETED".equalsIgnoreCase(status);
Collaborator

use the constants. there are constants for statuses, you can use them instead hardcode them here

use the constants. there are constants for statuses, you can use them instead hardcode them here
ruwin marked this conversation as resolved
rajitha requested changes 2 months ago
List<Device> devices = HelperUtil.getGroupManagementProviderService().
getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false);
List<Integer> deviceIdsOwnByGroup = devices.stream().map(Device::getId).collect(Collectors.toList());
List<Integer> removedIds = devices.stream()
Collaborator

This filter process can be done by single step. !"REMOVED".equalsIgnoreCase(status) || !"DELETED".equalsIgnoreCase(status) use this in the filter, so u can get the required device ids after mapping them.

This filter process can be done by single step. `!"REMOVED".equalsIgnoreCase(status) || !"DELETED".equalsIgnoreCase(status)` use this in the filter, so u can get the required device ids after mapping them.
ruwin marked this conversation as resolved
ruwin added 1 commit 2 months ago
ruwin added 1 commit 2 months ago
tcdlpds requested changes 2 months ago
getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false);
List<String> deviceStatuses = Arrays.asList(EnrolmentInfo.Status.ACTIVE.name(),
EnrolmentInfo.Status.INACTIVE.name(), EnrolmentInfo.Status.UNREACHABLE.name());
List<Device> devices = HelperUtil.getGroupManagementProviderService().getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), deviceStatuses, false);
Owner

In this service method are we considering the device type of the application supported?

In this service method are we considering the device type of the application supported?
Collaborator

Yes, your point is valid, but in the latter part SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.getSubscriptionStatistic (deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); when getting the stats, we're considering the release id. So the device type constraint will be implicitly satisfied.

Yes, your point is valid, but in the latter part `SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.getSubscriptionStatistic (deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId());` when getting the stats, we're considering the release id. So the device type constraint will be implicitly satisfied.
Poster

Yes, otherwise if a scenario like triggering an android application installation to group which have both the windows and android devices assigned to it then those app irrelevant devices (in this case windows) are also being counted for the device count but they are not relevant to that app installation. Here we are getting only the completed, pending and error device count and substract it from the total device count and assign that remainder to the new device count and pass it for the calculation of percentages so, when the device type of the application supported is not considered it will count all the devices relevant to that group so the new device percentage might be wrong.

Yes, otherwise if a scenario like triggering an android application installation to group which have both the windows and android devices assigned to it then those app irrelevant devices (in this case windows) are also being counted for the device count but they are not relevant to that app installation. Here we are getting only the completed, pending and error device count and substract it from the total device count and assign that remainder to the new device count and pass it for the calculation of percentages so, when the device type of the application supported is not considered it will count all the devices relevant to that group so the new device percentage might be wrong.
tcdlpds marked this conversation as resolved
int getDeviceCount(String groupName, int tenantId) throws GroupManagementDAOException;
int getDeviceCountWithGroup(String groupName, int deviceTypeId, int tenantId) throws GroupManagementDAOException;
Owner

Add Java Doc comment

Add Java Doc comment
ruwin marked this conversation as resolved
int getDeviceCount(String groupName) throws GroupManagementException;
int getDeviceCountWithGroup(String groupName, int deviceTypeId) throws GroupManagementException;
Owner

Add Java Doc comment

Add Java Doc comment
ruwin marked this conversation as resolved
try {
GroupManagementDAOFactory.openConnection();
return groupDAO.getDeviceCountWithGroup(groupName,deviceTypeId, tenantId);
} catch (SQLException | GroupManagementDAOException e) {
Owner

Please handle this with two exceptions and add two different error messages, it will be useful when we analyze logs if we get an error with this functionality.

Please handle this with two exceptions and add two different error messages, it will be useful when we analyze logs if we get an error with this functionality.
ruwin marked this conversation as resolved
ruwin added 18 commits 2 months ago
ruwin force-pushed statistics from 16ee68d8a3 to 230192f2d9 2 months ago
tcdlpds merged commit df129651fd into master 2 months ago

Reviewers

rajitha requested changes 2 months ago
tcdlpds requested changes 2 months ago
The pull request has been merged as df129651fd.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: community/device-mgt-core#508
Loading…
There is no content yet.