File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change 88
99from arango .typings import Json
1010from attrs import evolve
11- from math import floor
12-
1311from fixcore .constants import less_greater_then_operations as lgt_ops , arangodb_matches_null_ops
1412from fixcore .db import EstimatedSearchCost , EstimatedQueryCostRating as Rating
1513from fixcore .db .arango_query_rewrite import rewrite_query
@@ -148,14 +146,13 @@ def history_query_timeline(
148146 )
149147 crs = ctx .next_crs ()
150148 gran = granularity .total_seconds ()
151- at = after .timestamp ()
152- offset = ctx .add_bind_var ((at - int (floor (at / gran ) * gran )) * 1000 )
153- slot = ctx .add_bind_var (gran * 1000 )
154- slot_fn = f"DATE_ISO8601((FLOOR(DATE_TIMESTAMP({ crs } .changed_at) / @{ slot } ) * @{ slot } ) + @{ offset } )"
149+ atms = after .timestamp () * 1000
150+ slotter = ctx .add_bind_var (gran * 1000 )
151+ slot_fn = f"(FLOOR((DATE_TIMESTAMP({ crs } .changed_at)-{ atms } ) / @{ slotter } ))"
155152 query_str += (
156153 f" FOR { crs } IN { in_cursor } "
157- f"COLLECT change={ crs } .change, at ={ slot_fn } WITH COUNT INTO v SORT at ASC "
158- 'RETURN {"at": at , "group": {"change": change}, "v": v}'
154+ f"COLLECT change={ crs } .change, slot ={ slot_fn } WITH COUNT INTO v SORT slot ASC "
155+ f 'RETURN {{ "at": DATE_ISO8601((slot*@ { slotter } ) + { atms } ) , "group": {{ "change": change}} , "v": v} }'
159156 )
160157 return query_str , ctx .bind_vars
161158
You can’t perform that action at this time.
0 commit comments