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 09ffe7c  Admin per project
09ffe7c is described below

commit 09ffe7cc3eafd68701336b140f9ad1df4bdf566d
Author: Oleh Fuks <[email protected]>
AuthorDate: Tue Mar 31 14:12:18 2020 +0300

    Admin per project
---
 .../dlab/backendapi/service/impl/BillingServiceImpl.java | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java
 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java
index 3601d21..08502a2 100644
--- 
a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java
+++ 
b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/BillingServiceImpl.java
@@ -147,28 +147,28 @@ public class BillingServiceImpl implements BillingService 
{
 
     private Map<String, BillingReportLine> getBillableResources(UserInfo user, 
Set<ProjectDTO> projects) {
         Stream<BillingReportLine> billableAdminResources = Stream.empty();
-        final Stream<BillingReportLine> billableEdges = projects
-                .stream()
-                .collect(Collectors.toMap(ProjectDTO::getName, 
ProjectDTO::getEndpoints))
-                .entrySet()
-                .stream()
-                .flatMap(e -> projectEdges(sbn, e.getKey(), e.getValue()));
         final Stream<BillingReportLine> billableUserInstances = 
exploratoryService.findAll(projects)
                 .stream()
                 .filter(userInstance -> 
Objects.nonNull(userInstance.getExploratoryId()))
                 .flatMap(ui -> BillingUtils.exploratoryBillingDataStream(ui, 
configuration.getMaxSparkInstanceCount()));
 
         if (UserRoles.isAdmin(user)) {
+            final Stream<BillingReportLine> billableEdges = projects
+                    .stream()
+                    .collect(Collectors.toMap(ProjectDTO::getName, 
ProjectDTO::getEndpoints))
+                    .entrySet()
+                    .stream()
+                    .flatMap(e -> projectEdges(sbn, e.getKey(), e.getValue()));
             final Stream<BillingReportLine> ssnBillingDataStream = 
BillingUtils.ssnBillingDataStream(sbn);
             final Stream<BillingReportLine> billableSharedEndpoints = 
endpointService.getEndpoints()
                     .stream()
                     .flatMap(endpoint -> 
BillingUtils.sharedEndpointBillingDataStream(endpoint.getName(), sbn));
 
-            billableAdminResources = Stream.of(ssnBillingDataStream, 
billableSharedEndpoints)
+            billableAdminResources = Stream.of(billableEdges, 
ssnBillingDataStream, billableSharedEndpoints)
                     .flatMap(s -> s);
         }
 
-        final Map<String, BillingReportLine> billableResources = 
Stream.of(billableEdges, billableUserInstances, billableAdminResources)
+        final Map<String, BillingReportLine> billableResources = 
Stream.of(billableUserInstances, billableAdminResources)
                 .flatMap(s -> s)
                 .collect(Collectors.toMap(BillingReportLine::getDlabId, b -> 
b));
         log.debug("Billable resources are: {}", billableResources);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to