Skip to content

Commit

Permalink
add endpoint to get platform data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Akayeshmantha committed Oct 10, 2019
1 parent 7e0fa9a commit 83abad8
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public class AggregateController {
public void init() {
logger.info("Using the following URLs: {}, {}", environment.getProperty("nimble.identity.url"), environment.getProperty("nimble.business-process.url"));
}

@ApiOperation(value = "Aggregate statistics of platform.", nickname = "getPlatformStats", response = PlatformStats.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Aggregated statistics of platform"),
Expand Down Expand Up @@ -229,4 +228,31 @@ public ResponseEntity<?> getCollabarationStatisticsForComany(@ApiParam(value = "

return ResponseEntity.ok(collabStats);
}

@ApiOperation(value = "Aggregate statistics of company collaboration.", nickname = "getCollabStats", response = CollaborationStats.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Aggregated statistics of company collaboration"),
@ApiResponse(code = 400, message = "Error while aggregating statistics.")})
@RequestMapping(value = "/platform/collabaration", produces = {"application/json"}, method = RequestMethod.GET)
public ResponseEntity<?> getCollabarationStatisticsForPlatform(@ApiParam(value = "The Bearer token provided by the identity service") @RequestHeader(value = "Authorization", required = true) String bearerToken) {


//collab time
Double averageCollabTimePurchases = businessProcessClient.getCollaborationTimeForPlatform(BUYER,bearerToken);
Double averageCollabTimeSales = businessProcessClient.getCollaborationTimeForPlatform(SELLER,bearerToken);
Double averageCollabTime = (averageCollabTimePurchases+averageCollabTimeSales)/2;
CollaborationTime collaborationTime = new CollaborationTime(averageCollabTime, averageCollabTimePurchases, averageCollabTimeSales);

//response time
Double averageResponseTime = businessProcessClient.geResponseTimeForPlatform(bearerToken);
Map<Integer,Double> averagetimeForMonths =
businessProcessClient.geResponseTimeForPlatformForMonths(bearerToken);
ResponseTime resTime = new ResponseTime(averageResponseTime,averagetimeForMonths);

// aggregate statistics
CollaborationStats collabStats = new CollaborationStats();
collabStats.setCollaborationTime(collaborationTime);
collabStats.setResponseTime(resTime);
return ResponseEntity.ok(collabStats);
}
}

0 comments on commit 83abad8

Please sign in to comment.