Round approx
[pazpar2-moved-to-github.git] / src / client.c
index 02e592c..dcbfd6c 100644 (file)
@@ -589,8 +589,7 @@ static void client_record_ingest(struct client *cl)
         else if (ZOOM_record_error(rec, &msg, &addinfo, 0))
         {
             yaz_log(YLOG_WARN, "Record error %s (%s): %s (rec #%d)",
-                    msg, addinfo, client_get_id(cl),
-                    cl->record_offset);
+                    msg, addinfo, client_get_id(cl), cl->record_offset);
         }
         else
         {
@@ -1328,9 +1327,11 @@ Odr_int client_get_hits(struct client *cl)
 
 Odr_int client_get_approximation(struct client *cl)
 {
-    int records = cl->record_offset + cl->filtered;
-    if (records > 0)
-        return (cl->hits * cl->record_offset) / records;
+    if (cl->record_offset > 0) {
+        Odr_int approx = ((10 * cl->hits * (cl->record_offset - cl->filtered)) / cl->record_offset + 5) /10;
+        yaz_log(YLOG_LOG, "%s: Approx: %lld * %d / %d = %lld ", client_get_id(cl), cl->hits, cl->record_offset - cl->filtered, cl->record_offset, approx);
+        return approx;
+    }
     return cl->hits;
 }