Skip to content

Commit

Permalink
Simplify subscription query
Browse files Browse the repository at this point in the history
The artificial limit of 100 years was just set because the old SQL query
wouldn't deal with `null` well. Comparing with null always is always
false and returns nothing.

But Rails is now clever enough to interpret `begins_at..nil` as open
end query. This shouldn't have any practical impact as there's unlikely
to be an order cycle closing in more than 100 years. And if there was,
it would be confusing that it's not treated like other order cycles
ending in 80 years.
  • Loading branch information
mkllnk committed Jan 9, 2025
1 parent 49ec9a3 commit f9d436b
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ def not_closed_in_range_order_cycles
end

def in_range_order_cycles
ends_at_or_limit = ends_at || 100.years.from_now
order_cycles.where(orders_close_at: begins_at..ends_at_or_limit )
order_cycles.where(orders_close_at: begins_at..ends_at)
end
end
end
Expand Down

0 comments on commit f9d436b

Please sign in to comment.