Add statistics for Distribution Set (#1388)
* Add Statistics for Rollouts and Actions count by Status for a Distribution Set Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com> * remove unused imports Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com> * Refactoring and additional statistics for auto assignments Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com> * Fixed review findings and added tests Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com> * Added tests for the Management API Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com> * Remove unused imports Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com> * refactoring Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com> --------- Signed-off-by: Denislav Prinov <denislav.prinov@bosch.com>
This commit is contained in:
@@ -26,6 +26,7 @@ import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPut;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetStatistics;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtInvalidateDistributionSetRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody;
|
||||
@@ -414,6 +415,40 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
softwaremodules.getTotalElements()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<MgmtDistributionSetStatistics> getRolloutsCountByStatusForDistributionSet(Long distributionSetId) {
|
||||
MgmtDistributionSetStatistics.Builder statistics = new MgmtDistributionSetStatistics.Builder();
|
||||
distributionSetManagement.countRolloutsByStatusForDistributionSet(distributionSetId).forEach(statistic ->
|
||||
statistics.addTotalRolloutPerStatus(String.valueOf(statistic.getName()), Long.parseLong(statistic.getData().toString())));
|
||||
return ResponseEntity.ok(statistics.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<MgmtDistributionSetStatistics> getActionsCountByStatusForDistributionSet(Long distributionSetId) {
|
||||
MgmtDistributionSetStatistics.Builder statistics = new MgmtDistributionSetStatistics.Builder();
|
||||
distributionSetManagement.countActionsByStatusForDistributionSet(distributionSetId).forEach(statistic ->
|
||||
statistics.addTotalActionPerStatus(String.valueOf(statistic.getName()), Long.parseLong(statistic.getData().toString())));
|
||||
return ResponseEntity.ok(statistics.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<MgmtDistributionSetStatistics> getAutoAssignmentsCountForDistributionSet(Long distributionSetId) {
|
||||
MgmtDistributionSetStatistics.Builder statistics = new MgmtDistributionSetStatistics.Builder();
|
||||
statistics.addTotalAutoAssignments(distributionSetManagement.countAutoAssignmentsForDistributionSet(distributionSetId));
|
||||
return ResponseEntity.ok(statistics.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<MgmtDistributionSetStatistics> getStatisticsForDistributionSet(Long distributionSetId) {
|
||||
MgmtDistributionSetStatistics.Builder statistics = new MgmtDistributionSetStatistics.Builder();
|
||||
distributionSetManagement.countRolloutsByStatusForDistributionSet(distributionSetId).forEach(statistic ->
|
||||
statistics.addTotalRolloutPerStatus(String.valueOf(statistic.getName()), Long.parseLong(statistic.getData().toString())));
|
||||
distributionSetManagement.countActionsByStatusForDistributionSet(distributionSetId).forEach(statistic ->
|
||||
statistics.addTotalActionPerStatus(String.valueOf(statistic.getName()), Long.parseLong(statistic.getData().toString())));
|
||||
statistics.addTotalAutoAssignments(distributionSetManagement.countAutoAssignmentsForDistributionSet(distributionSetId));
|
||||
return ResponseEntity.ok(statistics.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> invalidateDistributionSet(
|
||||
@PathVariable("distributionSetId") final Long distributionSetId,
|
||||
|
||||
Reference in New Issue
Block a user