Fix mock tests

This commit is contained in:
Tour
2025-12-04 20:07:54 +01:00
parent d52bd8f94e
commit 2ff6fcca17
9 changed files with 639 additions and 552 deletions

34
.idea/compiler.xml generated
View File

@@ -8,11 +8,43 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" /> <outputRelativeToContentRoot value="true" />
</profile> </profile>
<profile name="Annotation profile for Troostwijk Auction Scraper" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.40/lombok-1.18.40.jar" />
<entry name="$MAVEN_REPOSITORY$/io/quarkus/quarkus-extension-processor/3.17.7/quarkus-extension-processor-3.17.7.jar" />
<entry name="$MAVEN_REPOSITORY$/org/jboss/jdeparser/jdeparser/2.0.3.Final/jdeparser-2.0.3.Final.jar" />
<entry name="$MAVEN_REPOSITORY$/org/jsoup/jsoup/1.15.3/jsoup-1.15.3.jar" />
<entry name="$MAVEN_REPOSITORY$/com/github/javaparser/javaparser-core/3.26.2/javaparser-core-3.26.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.18.2/jackson-databind-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-annotations/2.18.2/jackson-annotations-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.18.2/jackson-core-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.18.2/jackson-dataformat-yaml-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/org/yaml/snakeyaml/2.3/snakeyaml-2.3.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/module/jackson-module-parameter-names/2.18.2/jackson-module-parameter-names-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/io/quarkus/quarkus-bootstrap-app-model/3.17.7/quarkus-bootstrap-app-model-3.17.7.jar" />
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.40/lombok-1.18.40.jar" />
<entry name="$MAVEN_REPOSITORY$/io/quarkus/quarkus-extension-processor/3.17.7/quarkus-extension-processor-3.17.7.jar" />
<entry name="$MAVEN_REPOSITORY$/org/jboss/jdeparser/jdeparser/2.0.3.Final/jdeparser-2.0.3.Final.jar" />
<entry name="$MAVEN_REPOSITORY$/org/jsoup/jsoup/1.15.3/jsoup-1.15.3.jar" />
<entry name="$MAVEN_REPOSITORY$/com/github/javaparser/javaparser-core/3.26.2/javaparser-core-3.26.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.18.2/jackson-databind-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-annotations/2.18.2/jackson-annotations-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.18.2/jackson-core-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.18.2/jackson-dataformat-yaml-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/org/yaml/snakeyaml/2.3/snakeyaml-2.3.jar" />
<entry name="$MAVEN_REPOSITORY$/com/fasterxml/jackson/module/jackson-module-parameter-names/2.18.2/jackson-module-parameter-names-2.18.2.jar" />
<entry name="$MAVEN_REPOSITORY$/io/quarkus/quarkus-bootstrap-app-model/3.17.7/quarkus-bootstrap-app-model-3.17.7.jar" />
</processorPath>
<module name="auctiora" />
</profile>
</annotationProcessing> </annotationProcessing>
</component> </component>
<component name="JavacSettings"> <component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE"> <option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="auctiora" options="-Xdiags:verbose -Xlint:all -proc:none" /> <module name="auctiora" options="-Xdiags:verbose -Xlint:all -parameters" />
</option> </option>
</component> </component>
</project> </project>

56
pom.xml
View File

@@ -215,6 +215,59 @@
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-scheduler</artifactId> <artifactId>quarkus-scheduler</artifactId>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Force Netty 4.1.124.Final to avoid sun.misc.Unsafe warnings -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
<version>4.1.124.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns</artifactId>
<version>4.1.124.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
@@ -279,6 +332,7 @@
<properties> <properties>
<build.timestamp>${maven.build.timestamp}</build.timestamp> <build.timestamp>${maven.build.timestamp}</build.timestamp>
</properties> </properties>
<jvmArgs>--enable-native-access=ALL-UNNAMED --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true</jvmArgs>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@@ -316,7 +370,7 @@
<compilerArgs> <compilerArgs>
<arg>-Xdiags:verbose</arg> <arg>-Xdiags:verbose</arg>
<arg>-Xlint:all</arg> <arg>-Xlint:all</arg>
<arg>-proc:none</arg> <arg>-parameters</arg>
</compilerArgs> </compilerArgs>
<fork>true</fork> <fork>true</fork>
<excludes> <excludes>

View File

@@ -33,16 +33,16 @@ public class Main {
log.info("=== Troostwijk Auction Monitor ===\n"); log.info("=== Troostwijk Auction Monitor ===\n");
// Parse command line arguments // Parse command line arguments
String mode = args.length > 0 ? args[0] : "workflow"; var mode = args.length > 0 ? args[0] : "workflow";
// Configuration - Windows paths // Configuration - Windows paths
String databaseFile = System.getenv().getOrDefault("DATABASE_FILE", "C:\\mnt\\okcomputer\\output\\cache.db"); var databaseFile = System.getenv().getOrDefault("DATABASE_FILE", "C:\\mnt\\okcomputer\\output\\cache.db");
String notificationConfig = System.getenv().getOrDefault("NOTIFICATION_CONFIG", "desktop"); var notificationConfig = System.getenv().getOrDefault("NOTIFICATION_CONFIG", "desktop");
// YOLO model paths (optional - monitor works without object detection) // YOLO model paths (optional - monitor works without object detection)
String yoloCfg = "models/yolov4.cfg"; var yoloCfg = "models/yolov4.cfg";
String yoloWeights = "models/yolov4.weights"; var yoloWeights = "models/yolov4.weights";
String yoloClasses = "models/coco.names"; var yoloClasses = "models/coco.names";
// Load native OpenCV library (only if models exist) // Load native OpenCV library (only if models exist)
try { try {
@@ -85,7 +85,7 @@ public class Main {
log.info("🚀 Starting in WORKFLOW MODE (Orchestrated Scheduling)\n"); log.info("🚀 Starting in WORKFLOW MODE (Orchestrated Scheduling)\n");
WorkflowOrchestrator orchestrator = new WorkflowOrchestrator( var orchestrator = new WorkflowOrchestrator(
dbPath, notifConfig, yoloCfg, yoloWeights, yoloClasses dbPath, notifConfig, yoloCfg, yoloWeights, yoloClasses
); );
@@ -127,7 +127,7 @@ public class Main {
log.info("🔄 Starting in ONCE MODE (Single Execution)\n"); log.info("🔄 Starting in ONCE MODE (Single Execution)\n");
WorkflowOrchestrator orchestrator = new WorkflowOrchestrator( var orchestrator = new WorkflowOrchestrator(
dbPath, notifConfig, yoloCfg, yoloWeights, yoloClasses dbPath, notifConfig, yoloCfg, yoloWeights, yoloClasses
); );
@@ -179,7 +179,7 @@ public class Main {
log.info("📊 Checking Status...\n"); log.info("📊 Checking Status...\n");
WorkflowOrchestrator orchestrator = new WorkflowOrchestrator( var orchestrator = new WorkflowOrchestrator(
dbPath, notifConfig, yoloCfg, yoloWeights, yoloClasses dbPath, notifConfig, yoloCfg, yoloWeights, yoloClasses
); );

View File

@@ -43,9 +43,9 @@ public class ObjectDetectionService {
if (!Files.exists(cfgFile) || !Files.exists(weightsFile) || !Files.exists(classNamesFile)) { if (!Files.exists(cfgFile) || !Files.exists(weightsFile) || !Files.exists(classNamesFile)) {
log.info("⚠️ Object detection disabled: YOLO model files not found"); log.info("⚠️ Object detection disabled: YOLO model files not found");
log.info(" Expected files:"); log.info(" Expected files:");
log.info(" - " + cfgPath); log.info(" - {}", cfgPath);
log.info(" - " + weightsPath); log.info(" - {}", weightsPath);
log.info(" - " + classNamesPath); log.info(" - {}", classNamesPath);
log.info(" Scraper will continue without image analysis."); log.info(" Scraper will continue without image analysis.");
this.enabled = false; this.enabled = false;
this.net = null; this.net = null;

View File

@@ -44,7 +44,7 @@ public class QuarkusWorkflowScheduler {
void importScraperData() { void importScraperData() {
try { try {
LOG.info("📥 [WORKFLOW 1] Importing scraper data..."); LOG.info("📥 [WORKFLOW 1] Importing scraper data...");
long start = System.currentTimeMillis(); var start = System.currentTimeMillis();
// Import auctions // Import auctions
var auctions = db.importAuctionsFromScraper(); var auctions = db.importAuctionsFromScraper();
@@ -58,7 +58,7 @@ public class QuarkusWorkflowScheduler {
var images = db.getUnprocessedImagesFromScraper(); var images = db.getUnprocessedImagesFromScraper();
LOG.infof(" → Found %d unprocessed images", images.size()); LOG.infof(" → Found %d unprocessed images", images.size());
long duration = System.currentTimeMillis() - start; var duration = System.currentTimeMillis() - start;
LOG.infof(" ✓ Scraper import completed in %dms", duration); LOG.infof(" ✓ Scraper import completed in %dms", duration);
// Trigger notification if significant data imported // Trigger notification if significant data imported
@@ -84,7 +84,7 @@ public class QuarkusWorkflowScheduler {
void processImages() { void processImages() {
try { try {
LOG.info("🖼️ [WORKFLOW 2] Processing pending images..."); LOG.info("🖼️ [WORKFLOW 2] Processing pending images...");
long start = System.currentTimeMillis(); var start = System.currentTimeMillis();
// Get unprocessed images // Get unprocessed images
var unprocessedImages = db.getUnprocessedImagesFromScraper(); var unprocessedImages = db.getUnprocessedImagesFromScraper();
@@ -96,13 +96,13 @@ public class QuarkusWorkflowScheduler {
LOG.infof(" → Processing %d images", unprocessedImages.size()); LOG.infof(" → Processing %d images", unprocessedImages.size());
int processed = 0; var processed = 0;
int detected = 0; var detected = 0;
for (var imageRecord : unprocessedImages) { for (var imageRecord : unprocessedImages) {
try { try {
// Download image // Download image
String filePath = imageProcessor.downloadImage( var filePath = imageProcessor.downloadImage(
imageRecord.url(), imageRecord.url(),
imageRecord.saleId(), imageRecord.saleId(),
imageRecord.lotId() imageRecord.lotId()
@@ -141,7 +141,7 @@ public class QuarkusWorkflowScheduler {
} }
} }
long duration = System.currentTimeMillis() - start; var duration = System.currentTimeMillis() - start;
LOG.infof(" ✓ Processed %d images, detected objects in %d (%.1fs)", LOG.infof(" ✓ Processed %d images, detected objects in %d (%.1fs)",
processed, detected, duration / 1000.0); processed, detected, duration / 1000.0);
@@ -159,7 +159,7 @@ public class QuarkusWorkflowScheduler {
void monitorBids() { void monitorBids() {
try { try {
LOG.info("💰 [WORKFLOW 3] Monitoring bids..."); LOG.info("💰 [WORKFLOW 3] Monitoring bids...");
long start = System.currentTimeMillis(); var start = System.currentTimeMillis();
var activeLots = db.getActiveLots(); var activeLots = db.getActiveLots();
LOG.infof(" → Checking %d active lots", activeLots.size()); LOG.infof(" → Checking %d active lots", activeLots.size());
@@ -168,7 +168,7 @@ public class QuarkusWorkflowScheduler {
// For now, we just track what's in the database // For now, we just track what's in the database
// The external scraper updates bids, we just notify // The external scraper updates bids, we just notify
long duration = System.currentTimeMillis() - start; var duration = System.currentTimeMillis() - start;
LOG.infof(" ✓ Bid monitoring completed in %dms", duration); LOG.infof(" ✓ Bid monitoring completed in %dms", duration);
} catch (Exception e) { } catch (Exception e) {
@@ -185,19 +185,19 @@ public class QuarkusWorkflowScheduler {
void checkClosingTimes() { void checkClosingTimes() {
try { try {
LOG.info("⏰ [WORKFLOW 4] Checking closing times..."); LOG.info("⏰ [WORKFLOW 4] Checking closing times...");
long start = System.currentTimeMillis(); var start = System.currentTimeMillis();
var activeLots = db.getActiveLots(); var activeLots = db.getActiveLots();
int alertsSent = 0; var alertsSent = 0;
for (var lot : activeLots) { for (var lot : activeLots) {
if (lot.closingTime() == null) continue; if (lot.closingTime() == null) continue;
long minutesLeft = lot.minutesUntilClose(); var minutesLeft = lot.minutesUntilClose();
// Alert for lots closing in 5 minutes // Alert for lots closing in 5 minutes
if (minutesLeft <= 5 && minutesLeft > 0 && !lot.closingNotified()) { if (minutesLeft <= 5 && minutesLeft > 0 && !lot.closingNotified()) {
String message = String.format("Kavel %d sluit binnen %d min.", var message = String.format("Kavel %d sluit binnen %d min.",
lot.lotId(), minutesLeft); lot.lotId(), minutesLeft);
notifier.sendNotification(message, "Lot Closing Soon", 1); notifier.sendNotification(message, "Lot Closing Soon", 1);
@@ -215,7 +215,7 @@ public class QuarkusWorkflowScheduler {
} }
} }
long duration = System.currentTimeMillis() - start; var duration = System.currentTimeMillis() - start;
LOG.infof(" → Sent %d closing alerts in %dms", alertsSent, duration); LOG.infof(" → Sent %d closing alerts in %dms", alertsSent, duration);
} catch (Exception e) { } catch (Exception e) {

View File

@@ -57,7 +57,7 @@ public class RateLimitedHttpClient {
* Sends a GET request with automatic rate limiting based on host. * Sends a GET request with automatic rate limiting based on host.
*/ */
public HttpResponse<String> sendGet(String url) throws IOException, InterruptedException { public HttpResponse<String> sendGet(String url) throws IOException, InterruptedException {
HttpRequest request = HttpRequest.newBuilder() var request = HttpRequest.newBuilder()
.uri(URI.create(url)) .uri(URI.create(url))
.timeout(Duration.ofSeconds(timeoutSeconds)) .timeout(Duration.ofSeconds(timeoutSeconds))
.GET() .GET()
@@ -70,7 +70,7 @@ public class RateLimitedHttpClient {
* Sends a request for binary data (like images) with rate limiting. * Sends a request for binary data (like images) with rate limiting.
*/ */
public HttpResponse<byte[]> sendGetBytes(String url) throws IOException, InterruptedException { public HttpResponse<byte[]> sendGetBytes(String url) throws IOException, InterruptedException {
HttpRequest request = HttpRequest.newBuilder() var request = HttpRequest.newBuilder()
.uri(URI.create(url)) .uri(URI.create(url))
.timeout(Duration.ofSeconds(timeoutSeconds)) .timeout(Duration.ofSeconds(timeoutSeconds))
.GET() .GET()
@@ -85,21 +85,21 @@ public class RateLimitedHttpClient {
public <T> HttpResponse<T> send(HttpRequest request, HttpResponse.BodyHandler<T> bodyHandler) public <T> HttpResponse<T> send(HttpRequest request, HttpResponse.BodyHandler<T> bodyHandler)
throws IOException, InterruptedException { throws IOException, InterruptedException {
String host = extractHost(request.uri()); var host = extractHost(request.uri());
RateLimiter limiter = getRateLimiter(host); var limiter = getRateLimiter(host);
RequestStats stats = getRequestStats(host); var stats = getRequestStats(host);
// Enforce rate limit (blocks if necessary) // Enforce rate limit (blocks if necessary)
limiter.acquire(); limiter.acquire();
// Track request // Track request
stats.incrementTotal(); stats.incrementTotal();
long startTime = System.currentTimeMillis(); var startTime = System.currentTimeMillis();
try { try {
HttpResponse<T> response = httpClient.send(request, bodyHandler); var response = httpClient.send(request, bodyHandler);
long duration = System.currentTimeMillis() - startTime; var duration = System.currentTimeMillis() - startTime;
stats.recordSuccess(duration); stats.recordSuccess(duration);
LOG.debugf("HTTP %d %s %s (%dms)", LOG.debugf("HTTP %d %s %s (%dms)",
@@ -125,7 +125,7 @@ public class RateLimitedHttpClient {
*/ */
private RateLimiter getRateLimiter(String host) { private RateLimiter getRateLimiter(String host) {
return rateLimiters.computeIfAbsent(host, h -> { return rateLimiters.computeIfAbsent(host, h -> {
int maxRps = getMaxRequestsPerSecond(h); var maxRps = getMaxRequestsPerSecond(h);
LOG.infof("Initializing rate limiter for %s: %d req/s", h, maxRps); LOG.infof("Initializing rate limiter for %s: %d req/s", h, maxRps);
return new RateLimiter(maxRps); return new RateLimiter(maxRps);
}); });
@@ -174,6 +174,7 @@ public class RateLimitedHttpClient {
* Allows burst traffic up to maxRequestsPerSecond, then enforces steady rate. * Allows burst traffic up to maxRequestsPerSecond, then enforces steady rate.
*/ */
private static class RateLimiter { private static class RateLimiter {
private final Semaphore semaphore; private final Semaphore semaphore;
private final int maxRequestsPerSecond; private final int maxRequestsPerSecond;
private final long intervalNanos; private final long intervalNanos;
@@ -191,18 +192,18 @@ public class RateLimitedHttpClient {
semaphore.acquire(); semaphore.acquire();
// Enforce minimum delay between requests // Enforce minimum delay between requests
long delayMillis = intervalNanos / 1_000_000; var delayMillis = intervalNanos / 1_000_000;
if (delayMillis > 0) { if (delayMillis > 0) {
Thread.sleep(delayMillis); Thread.sleep(delayMillis);
} }
} }
private void startRefillThread() { private void startRefillThread() {
Thread refillThread = new Thread(() -> { var refillThread = new Thread(() -> {
while (!Thread.currentThread().isInterrupted()) { while (!Thread.currentThread().isInterrupted()) {
try { try {
Thread.sleep(1000); // Refill every second Thread.sleep(1000); // Refill every second
int toRelease = maxRequestsPerSecond - semaphore.availablePermits(); var toRelease = maxRequestsPerSecond - semaphore.availablePermits();
if (toRelease > 0) { if (toRelease > 0) {
semaphore.release(toRelease); semaphore.release(toRelease);
} }
@@ -221,6 +222,7 @@ public class RateLimitedHttpClient {
* Statistics tracker for HTTP requests per host. * Statistics tracker for HTTP requests per host.
*/ */
public static class RequestStats { public static class RequestStats {
private final String host; private final String host;
private final AtomicLong totalRequests = new AtomicLong(0); private final AtomicLong totalRequests = new AtomicLong(0);
private final AtomicLong successfulRequests = new AtomicLong(0); private final AtomicLong successfulRequests = new AtomicLong(0);
@@ -256,7 +258,7 @@ public class RateLimitedHttpClient {
public long getFailedRequests() { return failedRequests.get(); } public long getFailedRequests() { return failedRequests.get(); }
public long getRateLimitedRequests() { return rateLimitedRequests.get(); } public long getRateLimitedRequests() { return rateLimitedRequests.get(); }
public long getAverageDurationMs() { public long getAverageDurationMs() {
long successful = successfulRequests.get(); var successful = successfulRequests.get();
return successful > 0 ? totalDurationMs.get() / successful : 0; return successful > 0 ? totalDurationMs.get() / successful : 0;
} }

View File

@@ -19,19 +19,19 @@ public class ScraperDataAdapter {
static AuctionInfo fromScraperAuction(ResultSet rs) throws SQLException { static AuctionInfo fromScraperAuction(ResultSet rs) throws SQLException {
// Parse "A7-39813" → auctionId=39813, type="A7" // Parse "A7-39813" → auctionId=39813, type="A7"
String auctionIdStr = rs.getString("auction_id"); var auctionIdStr = rs.getString("auction_id");
int auctionId = extractNumericId(auctionIdStr); var auctionId = extractNumericId(auctionIdStr);
String type = extractTypePrefix(auctionIdStr); var type = extractTypePrefix(auctionIdStr);
// Split "Cluj-Napoca, RO" → city="Cluj-Napoca", country="RO" // Split "Cluj-Napoca, RO" → city="Cluj-Napoca", country="RO"
String location = rs.getString("location"); var location = rs.getString("location");
String[] locationParts = parseLocation(location); var locationParts = parseLocation(location);
String city = locationParts[0]; var city = locationParts[0];
String country = locationParts[1]; var country = locationParts[1];
// Map field names // Map field names
int lotCount = getIntOrDefault(rs, "lots_count", 0); var lotCount = getIntOrDefault(rs, "lots_count", 0);
LocalDateTime closingTime = parseTimestamp(getStringOrNull(rs, "first_lot_closing_time")); var closingTime = parseTimestamp(getStringOrNull(rs, "first_lot_closing_time"));
return new AuctionInfo( return new AuctionInfo(
auctionId, auctionId,

View File

@@ -94,18 +94,18 @@ public class WorkflowOrchestrator {
// Import auctions // Import auctions
var auctions = db.importAuctionsFromScraper(); var auctions = db.importAuctionsFromScraper();
log.info(" → Imported " + auctions.size() + " auctions"); log.info(" → Imported {} auctions", auctions.size());
// Import lots // Import lots
var lots = db.importLotsFromScraper(); var lots = db.importLotsFromScraper();
log.info(" → Imported " + lots.size() + " lots"); log.info(" → Imported {} lots", lots.size());
// Import image URLs // Import image URLs
var images = db.getUnprocessedImagesFromScraper(); var images = db.getUnprocessedImagesFromScraper();
log.info(" → Found " + images.size() + " unprocessed images"); log.info(" → Found {} unprocessed images", images.size());
long duration = System.currentTimeMillis() - start; long duration = System.currentTimeMillis() - start;
log.info(" ✓ Scraper import completed in " + duration + "ms\n"); log.info(" ✓ Scraper import completed in {}ms\n", duration);
// Trigger notification if significant data imported // Trigger notification if significant data imported
if (auctions.size() > 0 || lots.size() > 10) { if (auctions.size() > 0 || lots.size() > 10) {
@@ -117,7 +117,7 @@ public class WorkflowOrchestrator {
} }
} catch (Exception e) { } catch (Exception e) {
log.info(" ❌ Scraper import failed: " + e.getMessage()); log.info(" ❌ Scraper import failed: {}", e.getMessage());
} }
}, 0, 30, TimeUnit.MINUTES); }, 0, 30, TimeUnit.MINUTES);
@@ -143,7 +143,7 @@ public class WorkflowOrchestrator {
return; return;
} }
log.info(" → Processing " + unprocessedImages.size() + " images"); log.info(" → Processing {} images", unprocessedImages.size());
int processed = 0; int processed = 0;
int detected = 0; int detected = 0;
@@ -186,7 +186,7 @@ public class WorkflowOrchestrator {
Thread.sleep(500); Thread.sleep(500);
} catch (Exception e) { } catch (Exception e) {
log.info(" Failed to process image: " + e.getMessage()); log.info("\uFE0F Failed to process image: {}", e.getMessage());
} }
} }
@@ -195,7 +195,7 @@ public class WorkflowOrchestrator {
processed, detected, duration / 1000.0)); processed, detected, duration / 1000.0));
} catch (Exception e) { } catch (Exception e) {
log.info(" ❌ Image processing failed: " + e.getMessage()); log.info(" ❌ Image processing failed: {}", e.getMessage());
} }
}, 5, 60, TimeUnit.MINUTES); }, 5, 60, TimeUnit.MINUTES);
@@ -214,7 +214,7 @@ public class WorkflowOrchestrator {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
var activeLots = db.getActiveLots(); var activeLots = db.getActiveLots();
log.info(" → Checking " + activeLots.size() + " active lots"); log.info(" → Checking {} active lots", activeLots.size());
int bidChanges = 0; int bidChanges = 0;
@@ -228,7 +228,7 @@ public class WorkflowOrchestrator {
log.info(String.format(" ✓ Bid monitoring completed in %dms\n", duration)); log.info(String.format(" ✓ Bid monitoring completed in %dms\n", duration));
} catch (Exception e) { } catch (Exception e) {
log.info(" ❌ Bid monitoring failed: " + e.getMessage()); log.info(" ❌ Bid monitoring failed: {}", e.getMessage());
} }
}, 2, 15, TimeUnit.MINUTES); }, 2, 15, TimeUnit.MINUTES);
@@ -279,7 +279,7 @@ public class WorkflowOrchestrator {
alertsSent, duration)); alertsSent, duration));
} catch (Exception e) { } catch (Exception e) {
log.info(" ❌ Closing alerts failed: " + e.getMessage()); log.info(" ❌ Closing alerts failed: {}", e.getMessage());
} }
}, 1, 5, TimeUnit.MINUTES); }, 1, 5, TimeUnit.MINUTES);
@@ -298,7 +298,7 @@ public class WorkflowOrchestrator {
log.info("[1/4] Importing scraper data..."); log.info("[1/4] Importing scraper data...");
var auctions = db.importAuctionsFromScraper(); var auctions = db.importAuctionsFromScraper();
var lots = db.importLotsFromScraper(); var lots = db.importLotsFromScraper();
log.info(" ✓ Imported " + auctions.size() + " auctions, " + lots.size() + " lots"); log.info(" ✓ Imported {} auctions, {} lots", auctions.size(), lots.size());
// Step 2: Process images // Step 2: Process images
log.info("[2/4] Processing pending images..."); log.info("[2/4] Processing pending images...");
@@ -308,7 +308,7 @@ public class WorkflowOrchestrator {
// Step 3: Check bids // Step 3: Check bids
log.info("[3/4] Monitoring bids..."); log.info("[3/4] Monitoring bids...");
var activeLots = db.getActiveLots(); var activeLots = db.getActiveLots();
log.info(" ✓ Monitored " + activeLots.size() + " lots"); log.info(" ✓ Monitored {} lots", activeLots.size());
// Step 4: Check closing times // Step 4: Check closing times
log.info("[4/4] Checking closing times..."); log.info("[4/4] Checking closing times...");
@@ -318,12 +318,12 @@ public class WorkflowOrchestrator {
closingSoon++; closingSoon++;
} }
} }
log.info(" ✓ Found " + closingSoon + " lots closing soon"); log.info(" ✓ Found {} lots closing soon", closingSoon);
log.info("\n✓ Complete workflow finished successfully\n"); log.info("\n✓ Complete workflow finished successfully\n");
} catch (Exception e) { } catch (Exception e) {
log.info("\n❌ Workflow failed: " + e.getMessage() + "\n"); log.info("\n❌ Workflow failed: {}\n", e.getMessage());
} }
} }
@@ -331,7 +331,7 @@ public class WorkflowOrchestrator {
* Event-driven trigger: New auction discovered * Event-driven trigger: New auction discovered
*/ */
public void onNewAuctionDiscovered(AuctionInfo auction) { public void onNewAuctionDiscovered(AuctionInfo auction) {
log.info("📣 EVENT: New auction discovered - " + auction.title()); log.info("\uD83D\uDCE3 EVENT: New auction discovered - {}", auction.title());
try { try {
db.upsertAuction(auction); db.upsertAuction(auction);
@@ -344,7 +344,7 @@ public class WorkflowOrchestrator {
); );
} catch (Exception e) { } catch (Exception e) {
log.info(" ❌ Failed to handle new auction: " + e.getMessage()); log.info(" ❌ Failed to handle new auction: {}", e.getMessage());
} }
} }
@@ -366,7 +366,7 @@ public class WorkflowOrchestrator {
); );
} catch (Exception e) { } catch (Exception e) {
log.info(" ❌ Failed to handle bid change: " + e.getMessage()); log.info(" ❌ Failed to handle bid change: {}", e.getMessage());
} }
} }
@@ -386,7 +386,7 @@ public class WorkflowOrchestrator {
); );
} }
} catch (Exception e) { } catch (Exception e) {
log.info(" ❌ Failed to send detection notification: " + e.getMessage()); log.info(" ❌ Failed to send detection notification: {}", e.getMessage());
} }
} }
@@ -395,16 +395,16 @@ public class WorkflowOrchestrator {
*/ */
public void printStatus() { public void printStatus() {
log.info("\n📊 Workflow Status:"); log.info("\n📊 Workflow Status:");
log.info(" Running: " + (isRunning ? "Yes" : "No")); log.info(" Running: {}", isRunning ? "Yes" : "No");
try { try {
var auctions = db.getAllAuctions(); var auctions = db.getAllAuctions();
var lots = db.getAllLots(); var lots = db.getAllLots();
int images = db.getImageCount(); int images = db.getImageCount();
log.info(" Auctions: " + auctions.size()); log.info(" Auctions: {}", auctions.size());
log.info(" Lots: " + lots.size()); log.info(" Lots: {}", lots.size());
log.info(" Images: " + images); log.info(" Images: {}", images);
// Count closing soon // Count closing soon
int closingSoon = 0; int closingSoon = 0;
@@ -413,10 +413,10 @@ public class WorkflowOrchestrator {
closingSoon++; closingSoon++;
} }
} }
log.info(" Closing soon (< 30 min): " + closingSoon); log.info(" Closing soon (< 30 min): {}", closingSoon);
} catch (Exception e) { } catch (Exception e) {
log.info(" Could not retrieve status: " + e.getMessage()); log.info("\uFE0F Could not retrieve status: {}", e.getMessage());
} }
IO.println(); IO.println();

View File

@@ -33,7 +33,6 @@ quarkus.log.console.level=INFO
# JVM Arguments for native access (Jansi, OpenCV, etc.) # JVM Arguments for native access (Jansi, OpenCV, etc.)
quarkus.native.additional-build-args=--enable-native-access=ALL-UNNAMED quarkus.native.additional-build-args=--enable-native-access=ALL-UNNAMED
quarkus.jvm.args=--enable-native-access=ALL-UNNAMED
# Production optimizations # Production optimizations
%prod.quarkus.package.type=fast-jar %prod.quarkus.package.type=fast-jar