This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-orbit-workloads.git


The following commit(s) were added to refs/heads/main by this push:
     new a4684f1  nyc_taxis: fix the two value-source defects that query 
randomization makes reachable (#20)
a4684f1 is described below

commit a4684f18c05fe2b2103aa2f39c5c87604cdc2345
Author: Serhiy Bzhezytskyy <[email protected]>
AuthorDate: Fri Sep 4 10:25:32 2026 +0300

    nyc_taxis: fix the two value-source defects that query randomization makes 
reachable (#20)
    
    * nyc_taxis: compute the money bounds in whole cents
    * nyc_taxis: let a whole-day date range cover its last day
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
---
 nyc_taxis/workload.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/nyc_taxis/workload.py b/nyc_taxis/workload.py
index e58c04a..c0d793e 100644
--- a/nyc_taxis/workload.py
+++ b/nyc_taxis/workload.py
@@ -30,14 +30,15 @@ import datetime
 
 # Common helper functions
 def random_money_values(max_value):
-    gte_cents = random.randrange(0, max_value*100)
-    lte_cents = random.randrange(gte_cents, max_value*100)
+    max_cents = round(max_value * 100)
+    gte_cents = random.randrange(0, max_cents)
+    lte_cents = random.randrange(gte_cents, max_cents)
     return {
         "gte":gte_cents/100,
         "lte":lte_cents/100
     }
 
-def random_dates(min_value, max_value, format_string):
+def random_dates(min_value, max_value, format_string, whole_days=False):
     # arguments are datetime objects
     min_timestamp = datetime.datetime.timestamp(min_value)
     max_timestamp = datetime.datetime.timestamp(max_value)
@@ -47,6 +48,9 @@ def random_dates(min_value, max_value, format_string):
 
     gte_date = datetime.datetime.fromtimestamp(min_timestamp + 
int(gte_fraction * diff))
     lte_date = datetime.datetime.fromtimestamp(min_timestamp + 
int(lte_fraction * diff))
+    if whole_days:
+        gte_date = gte_date.replace(hour=0, minute=0, second=0, microsecond=0)
+        lte_date = lte_date.replace(hour=0, minute=0, second=0, microsecond=0) 
+ datetime.timedelta(days=1)
     return {
         "gte":gte_date.strftime(format_string),
         "lte":lte_date.strftime(format_string)
@@ -63,7 +67,7 @@ def date_source_with_hours():
     return random_dates(start_date, end_date, 
format_string="%Y-%m-%dT%H:%M:%SZ")
 
 def date_source_without_hours():
-    return random_dates(start_date, end_date, 
format_string="%Y-%m-%dT00:00:00Z")
+    return random_dates(start_date, end_date, 
format_string="%Y-%m-%dT%H:%M:%SZ", whole_days=True)
 
 def trip_distance_source():
     gte = random.randint(0, 10)

Reply via email to