bhliva commented on a change in pull request #392: [DLAB-1230] Fixed billing
issues [Azure]
URL: https://github.com/apache/incubator-dlab/pull/392#discussion_r344686065
##########
File path:
services/billing-azure/src/main/java/com/epam/dlab/billing/azure/AzureBillableResourcesService.java
##########
@@ -160,62 +161,56 @@ private String
getConfigurationSettingValueOrEmpty(String key) {
private Set<AzureDlabBillableResource> getEdgeAndStorageAccount() {
Set<AzureDlabBillableResource> billableResources = new
HashSet<>();
- try {
-
- final FindIterable<Document> prjDocuments =
mongoDbBillingClient.getDatabase()
- .getCollection("Projects").find();
- final List<Document> edges =
StreamSupport.stream(prjDocuments.spliterator(), false)
- .flatMap(d -> ((List<Document>)
d.get("endpoints")).stream())
- .map(d -> (Document) d.get("edgeInfo"))
- .collect(Collectors.toList());
- List<EdgeInfoAzure> edgeInfoList =
objectMapper.readValue(
- objectMapper.writeValueAsString(edges),
- new
com.fasterxml.jackson.core.type.TypeReference<List<EdgeInfoAzure>>() {
- });
-
- if (edgeInfoList != null && !edgeInfoList.isEmpty()) {
- for (EdgeInfoAzure edgeInfoAzure :
edgeInfoList) {
-
billableResources.addAll(getEdgeAndStorageAccount(edgeInfoAzure));
- }
+ Map<String, List<Document>> projectEndpoints =
StreamSupport.stream(mongoDbBillingClient.getDatabase()
+
.getCollection("Projects").find().spliterator(), false)
+ .collect(Collectors.toMap(key ->
key.getString("name").toLowerCase(),
+ value -> (List<Document>)
value.get("endpoints")));
+
+ projectEndpoints.forEach((key, value) -> value.forEach(endpoint
-> {
Review comment:
pls name vars accordingly: e.g. key - projectName, value -> endpoints
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]