Add ETA for fetchAnnotations
Change-Id: I7e0bc3c92309fc2713c46b3a5807f3fedce8dddd
diff --git a/R/KorAPQuery.R b/R/KorAPQuery.R
index 7d31587..cbf0169 100644
--- a/R/KorAPQuery.R
+++ b/R/KorAPQuery.R
@@ -1166,7 +1166,18 @@
df$annotation_snippet <- replicate(nrows, NA, simplify = FALSE)
+ # Initialize timing for ETA calculation
+ start_time <- Sys.time()
+ if (verbose) {
+ log_info(verbose, paste("Starting to fetch annotations for", nrows, "matches\n"))
+ }
+
for (i in seq_len(nrow(df))) {
+ # ETA logging
+ if (verbose && i > 1) {
+ eta_info <- calculate_eta(i, nrows, start_time)
+ log_info(verbose, paste("Fetching annotations for match", i, "of", nrows, eta_info, "\n"))
+ }
# Use matchID if available, otherwise fall back to constructing from matchStart/matchEnd
if ("matchID" %in% colnames(df) && !is.na(df$matchID[i])) {
# matchID format: "match-match-A00/JUN/39609-p202-203" or encrypted format like
@@ -1322,6 +1333,11 @@
})
})
+ if (verbose) {
+ elapsed_time <- Sys.time() - start_time
+ log_info(verbose, paste("Finished fetching annotations for", nrows, "matches in", format_duration(as.numeric(elapsed_time, units = "secs")), "\n"))
+ }
+
return(kqo)
})