This commit is contained in:
Tour
2025-12-09 12:29:06 +01:00
parent 70dbb21c5d
commit eb4df0d60b

View File

@@ -16,13 +16,11 @@ import java.util.stream.Collectors;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /// REST API for Auction Monitor control and status.
* REST API for Auction Monitor control and status. /// Provides endpoints for:
* Provides endpoints for: /// - Status checking
* - Status checking /// - Manual workflow triggers
* - Manual workflow triggers /// - Statistics
* - Statistics
*/
@Path("/api/monitor") @Path("/api/monitor")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@@ -36,10 +34,8 @@ public class AuctionMonitorResource {
@Inject RateLimitedHttpClient httpClient; @Inject RateLimitedHttpClient httpClient;
@Inject LotEnrichmentService enrichmentService; @Inject LotEnrichmentService enrichmentService;
/** /// GET /api/monitor/status
* GET /api/monitor/status /// Returns current monitoring status
* Returns current monitoring status
*/
@GET @GET
@Path("/status") @Path("/status")
public Response getStatus() { public Response getStatus() {
@@ -72,10 +68,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/statistics
* GET /api/monitor/statistics /// Returns detailed statistics
* Returns detailed statistics
*/
@GET @GET
@Path("/statistics") @Path("/statistics")
public Response getStatistics() { public Response getStatistics() {
@@ -165,10 +159,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/closing-soon
* GET /api/monitor/closing-soon /// Returns lots closing within the next specified hours (default: 24 hours)
* Returns lots closing within the next specified hours (default: 24 hours)
*/
@GET @GET
@Path("/closing-soon") @Path("/closing-soon")
public Response getClosingSoon(@QueryParam("hours") @DefaultValue("24") int hours) { public Response getClosingSoon(@QueryParam("hours") @DefaultValue("24") int hours) {
@@ -190,10 +182,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/lots/{lotId}/bid-history
* GET /api/monitor/lots/{lotId}/bid-history /// Returns bid history for a specific lot
* Returns bid history for a specific lot
*/
@GET @GET
@Path("/lots/{lotId}/bid-history") @Path("/lots/{lotId}/bid-history")
public Response getBidHistory(@PathParam("lotId") String lotId) { public Response getBidHistory(@PathParam("lotId") String lotId) {
@@ -208,10 +198,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// POST /api/monitor/trigger/scraper-import
* POST /api/monitor/trigger/scraper-import /// Manually trigger scraper import workflow
* Manually trigger scraper import workflow
*/
@POST @POST
@Path("/trigger/scraper-import") @Path("/trigger/scraper-import")
public Response triggerScraperImport() { public Response triggerScraperImport() {
@@ -226,10 +214,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// POST /api/monitor/trigger/image-processing
* POST /api/monitor/trigger/image-processing /// Manually trigger image processing workflow
* Manually trigger image processing workflow
*/
@POST @POST
@Path("/trigger/image-processing") @Path("/trigger/image-processing")
public Response triggerImageProcessing() { public Response triggerImageProcessing() {
@@ -244,10 +230,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// POST /api/monitor/trigger/bid-monitoring
* POST /api/monitor/trigger/bid-monitoring /// Manually trigger bid monitoring workflow
* Manually trigger bid monitoring workflow
*/
@POST @POST
@Path("/trigger/bid-monitoring") @Path("/trigger/bid-monitoring")
public Response triggerBidMonitoring() { public Response triggerBidMonitoring() {
@@ -262,10 +246,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// POST /api/monitor/trigger/closing-alerts
* POST /api/monitor/trigger/closing-alerts /// Manually trigger closing alerts workflow
* Manually trigger closing alerts workflow
*/
@POST @POST
@Path("/trigger/closing-alerts") @Path("/trigger/closing-alerts")
public Response triggerClosingAlerts() { public Response triggerClosingAlerts() {
@@ -280,10 +262,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// POST /api/monitor/trigger/graphql-enrichment
* POST /api/monitor/trigger/graphql-enrichment /// Manually trigger GraphQL enrichment for all lots or lots closing soon
* Manually trigger GraphQL enrichment for all lots or lots closing soon
*/
@POST @POST
@Path("/trigger/graphql-enrichment") @Path("/trigger/graphql-enrichment")
public Response triggerGraphQLEnrichment(@QueryParam("hoursUntilClose") @DefaultValue("24") int hours) { public Response triggerGraphQLEnrichment(@QueryParam("hoursUntilClose") @DefaultValue("24") int hours) {
@@ -310,10 +290,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/auctions
* GET /api/monitor/auctions /// Returns list of all auctions
* Returns list of all auctions
*/
@GET @GET
@Path("/auctions") @Path("/auctions")
public Response getAuctions(@QueryParam("country") String country) { public Response getAuctions(@QueryParam("country") String country) {
@@ -331,16 +309,13 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/lots
* GET /api/monitor/lots /// Returns list of active lots
* Returns list of active lots
*/
@GET @GET
@Path("/lots") @Path("/lots")
public Response getActiveLots() { public Response getActiveLots() {
try { try {
var lots = db.getActiveLots(); return Response.ok(db.getActiveLots()).build();
return Response.ok(lots).build();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Failed to get lots", e); LOG.error("Failed to get lots", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR) return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
@@ -349,10 +324,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/lots/closing-soon
* GET /api/monitor/lots/closing-soon /// Returns lots closing within specified minutes (default 30)
* Returns lots closing within specified minutes (default 30)
*/
@GET @GET
@Path("/lots/closing-soon") @Path("/lots/closing-soon")
public Response getLotsClosingSoon(@QueryParam("minutes") @DefaultValue("30") int minutes) { public Response getLotsClosingSoon(@QueryParam("minutes") @DefaultValue("30") int minutes) {
@@ -376,16 +349,13 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/lots/{lotId}/images
* GET /api/monitor/lots/{lotId}/images /// Returns images for a specific lot
* Returns images for a specific lot
*/
@GET @GET
@Path("/lots/{lotId}/images") @Path("/lots/{lotId}/images")
public Response getLotImages(@PathParam("lotId") int lotId) { public Response getLotImages(@PathParam("lotId") int lotId) {
try { try {
var images = db.getImagesForLot(lotId); return Response.ok(db.getImagesForLot(lotId)).build();
return Response.ok(images).build();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Failed to get lot images", e); LOG.error("Failed to get lot images", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR) return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
@@ -394,10 +364,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// POST /api/monitor/test-notification
* POST /api/monitor/test-notification /// Send a test notification
* Send a test notification
*/
@POST @POST
@Path("/test-notification") @Path("/test-notification")
public Response sendTestNotification(Map<String, String> request) { public Response sendTestNotification(Map<String, String> request) {
@@ -417,10 +385,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/rate-limit/stats
* GET /api/monitor/rate-limit/stats /// Returns HTTP rate limiting statistics for all hosts
* Returns HTTP rate limiting statistics for all hosts
*/
@GET @GET
@Path("/rate-limit/stats") @Path("/rate-limit/stats")
public Response getRateLimitStats() { public Response getRateLimitStats() {
@@ -453,10 +419,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/rate-limit/stats/{host}
* GET /api/monitor/rate-limit/stats/{host} /// Returns HTTP rate limiting statistics for a specific host
* Returns HTTP rate limiting statistics for a specific host
*/
@GET @GET
@Path("/rate-limit/stats/{host}") @Path("/rate-limit/stats/{host}")
public Response getRateLimitStatsForHost(@PathParam("host") String host) { public Response getRateLimitStatsForHost(@PathParam("host") String host) {
@@ -487,10 +451,8 @@ public class AuctionMonitorResource {
.build(); .build();
} }
} }
/** /// GET /api/monitor/charts/country-distribution
* GET /api/monitor/charts/country-distribution /// Returns dynamic country distribution for charts
* Returns dynamic country distribution for charts
*/
@GET @GET
@Path("/charts/country-distribution") @Path("/charts/country-distribution")
public Response getCountryDistribution() { public Response getCountryDistribution() {
@@ -512,10 +474,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/charts/category-distribution
* GET /api/monitor/charts/category-distribution /// Returns dynamic category distribution with intelligence for charts
* Returns dynamic category distribution with intelligence for charts
*/
@GET @GET
@Path("/charts/category-distribution") @Path("/charts/category-distribution")
public Response getCategoryDistribution() { public Response getCategoryDistribution() {
@@ -566,10 +526,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/charts/bidding-trend
* GET /api/monitor/charts/bidding-trend /// Returns time series data for last N hours
* Returns time series data for last N hours
*/
@GET @GET
@Path("/charts/bidding-trend") @Path("/charts/bidding-trend")
public Response getBiddingTrend(@QueryParam("hours") @DefaultValue("24") int hours) { public Response getBiddingTrend(@QueryParam("hours") @DefaultValue("24") int hours) {
@@ -605,10 +563,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/charts/insights
* GET /api/monitor/charts/insights /// Returns intelligent insights
* Returns intelligent insights
*/
@GET @GET
@Path("/charts/insights") @Path("/charts/insights")
public Response getInsights() { public Response getInsights() {
@@ -704,10 +660,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/intelligence/sleepers
* GET /api/monitor/intelligence/sleepers /// Returns "sleeper" lots (high watch count, low bids)
* Returns "sleeper" lots (high watch count, low bids)
*/
@GET @GET
@Path("/intelligence/sleepers") @Path("/intelligence/sleepers")
public Response getSleeperLots(@QueryParam("minFollowers") @DefaultValue("10") int minFollowers) { public Response getSleeperLots(@QueryParam("minFollowers") @DefaultValue("10") int minFollowers) {
@@ -731,10 +685,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/intelligence/bargains
* GET /api/monitor/intelligence/bargains /// Returns lots priced below auction house estimates
* Returns lots priced below auction house estimates
*/
@GET @GET
@Path("/intelligence/bargains") @Path("/intelligence/bargains")
public Response getBargains() { public Response getBargains() {
@@ -765,10 +717,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/intelligence/popular
* GET /api/monitor/intelligence/popular /// Returns lots by popularity level
* Returns lots by popularity level
*/
@GET @GET
@Path("/intelligence/popular") @Path("/intelligence/popular")
public Response getPopularLots(@QueryParam("level") @DefaultValue("HIGH") String level) { public Response getPopularLots(@QueryParam("level") @DefaultValue("HIGH") String level) {
@@ -798,10 +748,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/intelligence/price-analysis
* GET /api/monitor/intelligence/price-analysis /// Returns price vs estimate analysis
* Returns price vs estimate analysis
*/
@GET @GET
@Path("/intelligence/price-analysis") @Path("/intelligence/price-analysis")
public Response getPriceAnalysis() { public Response getPriceAnalysis() {
@@ -838,10 +786,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/lots/{lotId}/intelligence
* GET /api/monitor/lots/{lotId}/intelligence /// Returns detailed intelligence for a specific lot
* Returns detailed intelligence for a specific lot
*/
@GET @GET
@Path("/lots/{lotId}/intelligence") @Path("/lots/{lotId}/intelligence")
public Response getLotIntelligence(@PathParam("lotId") long lotId) { public Response getLotIntelligence(@PathParam("lotId") long lotId) {
@@ -883,10 +829,8 @@ public class AuctionMonitorResource {
} }
} }
/** /// GET /api/monitor/charts/watch-distribution
* GET /api/monitor/charts/watch-distribution /// Returns follower/watch count distribution
* Returns follower/watch count distribution
*/
@GET @GET
@Path("/charts/watch-distribution") @Path("/charts/watch-distribution")
public Response getWatchDistribution() { public Response getWatchDistribution() {