This is an automated email from the ASF dual-hosted git repository.
ofuks pushed a commit to branch DLAB-1571
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1571 by this push:
new bf010b4 Code refactoring
bf010b4 is described below
commit bf010b4dd0f50ada9f62db4cde9be54f5c4bb36d
Author: Oleh Fuks <[email protected]>
AuthorDate: Wed Mar 4 18:11:21 2020 +0200
Code refactoring
---
.../epam/dlab/backendapi/util/BillingUtils.java | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git
a/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
b/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
index b61eb26..98bee0a 100644
---
a/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
+++
b/services/self-service/src/main/java/com/epam/dlab/backendapi/util/BillingUtils.java
@@ -70,10 +70,10 @@ public class BillingUtils {
final String ssnId = sbn + "-ssn";
final String bucketName = sbn.replaceAll("_", "-");
return Stream.of(
-
BillingReportLine.builder().user(SHARED_RESOURCE).resourceName("SSN").dlabId(ssnId).resourceType(BillingResourceType.SSN).build(),
-
BillingReportLine.builder().user(SHARED_RESOURCE).resourceName("SSN
Volume").dlabId(String.format(VOLUME_PRIMARY_FORMAT,
ssnId)).resourceType(BillingResourceType.VOLUME).build(),
-
BillingReportLine.builder().user(SHARED_RESOURCE).resourceName("SSN
bucket").dlabId(bucketName + "-ssn" +
"-bucket").resourceType(BillingResourceType.SSN_BUCKET).build(),
-
BillingReportLine.builder().user(SHARED_RESOURCE).resourceName("Collaboration
bucket").dlabId(bucketName +
"-shared-bucket").resourceType(BillingResourceType.SHARED_BUCKET).build()
+
BillingReportLine.builder().user(SHARED_RESOURCE).project(SHARED_RESOURCE).resourceName("SSN").dlabId(ssnId).resourceType(BillingResourceType.SSN).build(),
+
BillingReportLine.builder().user(SHARED_RESOURCE).project(SHARED_RESOURCE).resourceName("SSN
Volume").dlabId(String.format(VOLUME_PRIMARY_FORMAT,
ssnId)).resourceType(BillingResourceType.VOLUME).build(),
+
BillingReportLine.builder().user(SHARED_RESOURCE).project(SHARED_RESOURCE).resourceName("SSN
bucket").dlabId(bucketName + "-ssn" +
"-bucket").resourceType(BillingResourceType.SSN_BUCKET).build(),
+
BillingReportLine.builder().user(SHARED_RESOURCE).project(SHARED_RESOURCE).resourceName("Collaboration
bucket").dlabId(bucketName +
"-shared-bucket").resourceType(BillingResourceType.SHARED_BUCKET).build()
);
}
@@ -81,7 +81,8 @@ public class BillingUtils {
final Stream<BillingReportLine> computationalStream =
userInstance.getResources()
.stream()
.filter(cr -> cr.getComputationalId() != null)
- .flatMap(cr ->
Stream.of(computationalBillableResource(userInstance, cr),
+ .flatMap(cr ->
Stream.of(withUserProject(userInstance).dlabId(cr.getComputationalId()).resourceName(cr.getComputationalName()).resourceType(BillingResourceType.COMPUTATIONAL)
+
.status(UserInstanceStatus.of(cr.getStatus())).shape(getComputationalShape(cr)).build(),
withUserProject(userInstance).resourceName(cr.getComputationalName() + ":" +
VOLUME_PRIMARY).dlabId(String.format(VOLUME_PRIMARY_FORMAT,
cr.getComputationalId()))
.resourceType(BillingResourceType.VOLUME).build()));
final String exploratoryId = userInstance.getExploratoryId();
@@ -95,17 +96,6 @@ public class BillingUtils {
return Stream.concat(computationalStream, exploratoryStream);
}
- private static BillingReportLine
computationalBillableResource(UserInstanceDTO userInstance,
-
UserComputationalResource cr) {
- return withUserProject(userInstance)
- .dlabId(cr.getComputationalId())
- .resourceName(cr.getComputationalName())
- .resourceType(BillingResourceType.COMPUTATIONAL)
- .status(UserInstanceStatus.of(cr.getStatus()))
- .shape(getComputationalShape(cr))
- .build();
- }
-
private static BillingReportLine.BillingReportLineBuilder
withUserProject(UserInstanceDTO userInstance) {
return
BillingReportLine.builder().user(userInstance.getUser()).project(userInstance.getProject());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]