05/23 Phase 12
This commit is contained in:
+7
-1
@@ -224,10 +224,12 @@ def get_draw_count(game_id):
|
||||
conn.close()
|
||||
|
||||
|
||||
def get_draws_with_game(game_id=None, limit=None, date_from=None, date_to=None, order="DESC"):
|
||||
def get_draws_with_game(game_id=None, limit=None, date_from=None, date_to=None,
|
||||
order="DESC", number=None):
|
||||
"""
|
||||
Like get_draws() but JOINs games so each row includes game_name.
|
||||
game_id=None returns draws for all games.
|
||||
number (int|str): if given, restrict to draws containing that ball number.
|
||||
Used by the History screen.
|
||||
"""
|
||||
conn = get_connection()
|
||||
@@ -249,6 +251,10 @@ def get_draws_with_game(game_id=None, limit=None, date_from=None, date_to=None,
|
||||
if date_to:
|
||||
query += " AND d.draw_date <= ?"
|
||||
params.append(date_to)
|
||||
if number is not None:
|
||||
# Wrap stored CSV in commas so boundary matches are exact
|
||||
query += " AND ',' || d.numbers || ',' LIKE ?"
|
||||
params.append(f"%,{int(number)},%")
|
||||
|
||||
order_sql = "DESC" if order.upper() == "DESC" else "ASC"
|
||||
query += f" ORDER BY d.draw_date {order_sql}, g.name ASC"
|
||||
|
||||
Reference in New Issue
Block a user