Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
build: .
container_name: analytics-app
ports:
- "8080:8080"
- "8083:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/analytics_db_dev
SPRING_DATASOURCE_USERNAME: postgres
Expand All @@ -20,7 +20,7 @@ services:
image: postgres
container_name: analytics-db
ports:
- "5432:5432"
- "5435:5432"
environment:
POSTGRES_DB: analytics_db_dev
POSTGRES_USER: postgres
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>com.github.Podzilla</groupId>
<artifactId>podzilla-utils-lib</artifactId>
<version>v1.1.6</version>
<version>v1.1.11</version>
</dependency>

<!-- Validation API & Implementation -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Tag(name = "Courier Reports", description = "Endpoints for courier"
+ " analytics and performance metrics")
@RestController
@RequestMapping("/courier-analytics")
@RequiredArgsConstructor
@Slf4j
public final class CourierReportController {

private final CourierAnalyticsService courierAnalyticsService;
Expand All @@ -37,6 +39,8 @@ public final class CourierReportController {
@GetMapping("/delivery-counts")
public ResponseEntity<List<CourierDeliveryCountResponse>> getDeliveryCounts(
@Valid @ModelAttribute final DateRangeRequest dateRange) {
log.info("Request on: /courier-analytics/delivery-counts "
+ "with attributes: {}", dateRange);
List<CourierDeliveryCountResponse> counts = courierAnalyticsService
.getCourierDeliveryCounts(dateRange.getStartDate(),
dateRange.getEndDate());
Expand All @@ -48,6 +52,9 @@ public ResponseEntity<List<CourierDeliveryCountResponse>> getDeliveryCounts(
@GetMapping("/success-rate")
public ResponseEntity<List<CourierSuccessRateResponse>> getSuccessRate(
@Valid @ModelAttribute final DateRangeRequest dateRange) {
log.info("Request on: /courier-analytics/success-rate "
+ "with attributes: {}",
dateRange);
List<CourierSuccessRateResponse> rates = courierAnalyticsService
.getCourierSuccessRate(dateRange.getStartDate(),
dateRange.getEndDate());
Expand All @@ -59,6 +66,8 @@ public ResponseEntity<List<CourierSuccessRateResponse>> getSuccessRate(
@GetMapping("/average-rating")
public ResponseEntity<List<CourierAverageRatingResponse>> getAverageRating(
@Valid @ModelAttribute final DateRangeRequest dateRange) {
log.info("Request on: /courier-analytics/average-rating "
+ "with attributes: {}", dateRange);
List<CourierAverageRatingResponse> ratings = courierAnalyticsService
.getCourierAverageRating(dateRange.getStartDate(),
dateRange.getEndDate());
Expand All @@ -70,6 +79,8 @@ public ResponseEntity<List<CourierAverageRatingResponse>> getAverageRating(
@GetMapping("/performance-report")
public ResponseEntity<List<CourierPerformanceReportResponse>> getReport(
@Valid @ModelAttribute final DateRangeRequest dateRange) {
log.info("Request on: /courier-analytics/performance-report "
+ "with attributes: {}", dateRange);
List<CourierPerformanceReportResponse> report = courierAnalyticsService
.getCourierPerformanceReport(dateRange.getStartDate(),
dateRange.getEndDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

Expand All @@ -21,6 +22,7 @@
@RequiredArgsConstructor
@RestController
@RequestMapping("/customer-analytics")
@Slf4j
public class CustomerReportController {
private final CustomerAnalyticsService customerAnalyticsService;

Expand All @@ -30,6 +32,8 @@ public class CustomerReportController {
@GetMapping("/top-spenders")
public List<CustomersTopSpendersResponse> getTopSpenders(
@Valid @ModelAttribute final DateRangePaginationRequest request) {
log.info("Request on: /customer-analytics/top-spenders "
+ "with attributes: {}", request);
return customerAnalyticsService.getTopSpenders(
request.getStartDate(),
request.getEndDate(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.Podzilla.analytics.api.controllers;

import org.springframework.http.ResponseEntity;
// import org.springframework.web.bind.MethodArgumentNotValidException;
// import org.springframework.web.bind.MissingServletRequestParameterException;
// import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
// import org.springframework.web.method.annotation.
// MethodArgumentTypeMismatchException;

import com.Podzilla.analytics.api.dtos.fulfillment.FulfillmentPlaceToShipRequest;
import com.Podzilla.analytics.api.dtos.fulfillment.FulfillmentShipToDeliverRequest;
Expand All @@ -30,40 +25,41 @@
public class FulfillmentReportController {
private final FulfillmentAnalyticsService fulfillmentAnalyticsService;

@Operation(
summary = "Get average time from order placement to shipping",
description = "Returns the average time (in hours) between when"
@Operation(summary = "Get average time from order placement to shipping",
description = "Returns the average time (in hours) between when"
+ " an order was placed and when it was shipped, grouped"
+ " by the specified dimension"
)
+ " by the specified dimension")
@GetMapping("/place-to-ship-time")
public ResponseEntity<List<FulfillmentTimeResponse>> getPlaceToShipTime(
@Valid @ModelAttribute final FulfillmentPlaceToShipRequest req) {

log.info("Request on: /fulfillment-analytics/place-to-ship-time "
+ "with attributes: {}", req);

final List<FulfillmentTimeResponse> reportData =
fulfillmentAnalyticsService.getPlaceToShipTimeResponse(
req.getStartDate(),
req.getEndDate(),
req.getGroupBy());
fulfillmentAnalyticsService.getPlaceToShipTimeResponse(
req.getStartDate(),
req.getEndDate(),
req.getGroupBy());
return ResponseEntity.ok(reportData);
}


@Operation(
summary = "Get average time from shipping to delivery",
description = "Returns the average time (in hours) between when"
@Operation(summary = "Get average time from shipping to delivery",
description = "Returns the average time (in hours) between when"
+ " an order was shipped and when it was delivered, grouped"
+ " by the specified dimension"
)
+ " by the specified dimension")
@GetMapping("/ship-to-deliver-time")
public ResponseEntity<List<FulfillmentTimeResponse>> getShipToDeliverTime(
@Valid @ModelAttribute final FulfillmentShipToDeliverRequest req) {

log.info("Request on: /fulfillment-analytics/ship-to-deliver-time "
+ "with attributes: {}", req);

final List<FulfillmentTimeResponse> reportData =
fulfillmentAnalyticsService.getShipToDeliverTimeResponse(
req.getStartDate(),
req.getEndDate(),
req.getGroupBy());
fulfillmentAnalyticsService.getShipToDeliverTimeResponse(
req.getStartDate(),
req.getEndDate(),
req.getGroupBy());
return ResponseEntity.ok(reportData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

Expand All @@ -23,6 +24,7 @@
@RequiredArgsConstructor
@RestController
@RequestMapping("/inventory-analytics")
@Slf4j
public class InventoryReportController {
private final InventoryAnalyticsService inventoryAnalyticsService;

Expand All @@ -31,7 +33,10 @@ public class InventoryReportController {
+ "the total value of inventory "
+ "grouped by product categories")
@GetMapping("/value/by-category")
public List<InventoryValueByCategoryResponse> getInventoryValueByCategor() {
public List<InventoryValueByCategoryResponse> getInventoryValueByCategory(

) {
log.info("Request on: /inventory-analytics/value/by-category");
return inventoryAnalyticsService.getInventoryValueByCategory();
}

Expand All @@ -40,6 +45,8 @@ public List<InventoryValueByCategoryResponse> getInventoryValueByCategor() {
@GetMapping("/low-stock")
public Page<LowStockProductResponse> getLowStockProducts(
@Valid @ModelAttribute final PaginationRequest paginationRequest) {
log.info("Request on: /inventory-analytics/low-stock"
+ " with attributes: {}", paginationRequest);
return inventoryAnalyticsService.getLowStockProducts(
paginationRequest.getPage(),
paginationRequest.getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.springframework.http.ResponseEntity;
import java.util.List;
Expand All @@ -19,56 +20,56 @@
import com.Podzilla.analytics.api.dtos.order.OrderRegionResponse;
import com.Podzilla.analytics.api.dtos.order.OrderStatusResponse;


@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/order-analytics")
public class OrderReportController {
private final OrderAnalyticsService orderAnalyticsService;

@Operation(summary = "Get order counts and revenue by region",
description = "Returns the total number of orders"
+ "placed in each region and their corresponding average revenue")
description = "Returns the total number of orders"
+ "placed in each region and their corresponding average revenue")
@GetMapping("/by-region")
public ResponseEntity<List<OrderRegionResponse>> getOrdersByRegion(
@Valid @ModelAttribute final DateRangeRequest dateRange
) {
List<OrderRegionResponse> ordersByRegion =
orderAnalyticsService.getOrdersByRegion(
dateRange.getStartDate(),
dateRange.getEndDate()
);
@Valid @ModelAttribute final DateRangeRequest dateRange) {
log.info("Request on: /order-analytics/by-region"
+ " with attributes: {}", dateRange);
List<OrderRegionResponse> ordersByRegion = orderAnalyticsService
.getOrdersByRegion(
dateRange.getStartDate(),
dateRange.getEndDate());
return ResponseEntity.ok(ordersByRegion);
}

@Operation(summary = "Get order status counts",
description = "Returns the total number of orders"
+ "in each status (e.g., COMPLETED, SHIPPED, FAILED)")
description = "Returns the total number of orders"
+ "in each status (e.g., COMPLETED, SHIPPED, FAILED)")
@GetMapping("/status-counts")
public ResponseEntity<List<OrderStatusResponse>> getOrdersStatusCounts(
@Valid @ModelAttribute final DateRangeRequest dateRange
) {
List<OrderStatusResponse> orderStatusCounts =
orderAnalyticsService.getOrdersStatusCounts(
dateRange.getStartDate(),
dateRange.getEndDate()
);
@Valid @ModelAttribute final DateRangeRequest dateRange) {
log.info("Request on: /order-analytics/status-counts"
+ " with attributes: {}", dateRange);
List<OrderStatusResponse> orderStatusCounts = orderAnalyticsService
.getOrdersStatusCounts(
dateRange.getStartDate(),
dateRange.getEndDate());
return ResponseEntity.ok(orderStatusCounts);
}

@Operation(summary = "Get order failures",
description = "Returns the percentage of failed orders"
+ "and a list of the failure reasons"
+ "with their corresponding frequency")
description = "Returns the percentage of failed orders"
+ "and a list of the failure reasons"
+ "with their corresponding frequency")
@GetMapping("/failures")
public ResponseEntity<OrderFailureResponse> getOrdersFailures(
@Valid @ModelAttribute final DateRangeRequest dateRange
) {
OrderFailureResponse orderFailures =
orderAnalyticsService.getOrdersFailures(
dateRange.getStartDate(),
dateRange.getEndDate()
);
@Valid @ModelAttribute final DateRangeRequest dateRange) {
log.info("Request on: /order-analytics/failures"
+ " with attributes: {}", dateRange);
OrderFailureResponse orderFailures = orderAnalyticsService
.getOrdersFailures(
dateRange.getStartDate(),
dateRange.getEndDate());
return ResponseEntity.ok(orderFailures);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@RequiredArgsConstructor
@RestController

@Slf4j
@RequestMapping("/product-analytics")
public class ProductReportController {

Expand All @@ -27,6 +28,9 @@ public class ProductReportController {
public ResponseEntity<List<TopSellerResponse>> getTopSellers(
@Valid @ModelAttribute final TopSellerRequest requestDTO) {

log.info("Request on: /product-analytics/top-sellers"
+ " with attributes: {}", requestDTO);

List<TopSellerResponse> topSellersList = productAnalyticsService
.getTopSellers(requestDTO.getStartDate(),
requestDTO.getEndDate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import com.Podzilla.analytics.services.ProfitAnalyticsService;

import io.swagger.v3.oas.annotations.Operation;
// import io.swagger.v3.oas.annotations.responses.ApiResponse;
// import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -30,17 +28,18 @@
public class ProfitReportController {
private final ProfitAnalyticsService profitAnalyticsService;


@Operation(
summary = "Get profit by product category",
description = "Returns the revenue, cost, and profit metrics "
+ "grouped by product category")
@Operation(summary = "Get profit by product category",
description = "Returns the revenue, cost, and profit metrics "
+ "grouped by product category")
@GetMapping("/by-category")
public ResponseEntity<List<ProfitByCategory>> getProfitByCategory(
@Valid @ModelAttribute final DateRangeRequest request) {

List<ProfitByCategory> profitData =
profitAnalyticsService.getProfitByCategory(
log.info("Request on: /profit-analytics/by-category"
+ " with attributes: {}", request);

List<ProfitByCategory> profitData = profitAnalyticsService
.getProfitByCategory(
request.getStartDate(),
request.getEndDate());
return ResponseEntity.ok(profitData);
Expand Down
Loading