@@ -38,14 +38,20 @@ def get_user(session: Session, email: str) -> UserSQL:
3838
3939
4040def get_all_last_api_request (
41- session : Session , include_in_url : Optional [str ] = None , exclude_in_url : Optional [str ] = None
41+ session : Session ,
42+ include_in_url : Optional [str ] = None ,
43+ exclude_in_url : Optional [str ] = None ,
44+ start_datetime : Optional [datetime ] = None ,
45+ end_datetime : Optional [datetime ] = None ,
4246) -> List [APIRequestSQL ]:
4347 """
4448 Get all last api requests for all users
4549
4650 :param session: database session
4751 :param include_in_url: Optional filter to include only URLs containing this string
4852 :param exclude_in_url: Optional filter to exclude URLs containing this string
53+ :param start_datetime: only get api requests after start datetime
54+ :param end_datetime: only get api requests before end datetime
4955 :return: List of last API requests
5056 """
5157
@@ -57,14 +63,19 @@ def get_all_last_api_request(
5763 .populate_existing ()
5864 .order_by (APIRequestSQL .user_uuid , APIRequestSQL .created_utc .desc ())
5965 )
60-
6166 # Apply URL filtering if specified
6267 if include_in_url is not None :
6368 query = query .filter (APIRequestSQL .url .like (f"%{ include_in_url } %" ))
6469
6570 if exclude_in_url is not None :
6671 query = query .filter (~ APIRequestSQL .url .like (f"%{ exclude_in_url } %" ))
6772
73+ if start_datetime is not None :
74+ query = query .filter (APIRequestSQL .created_utc >= start_datetime )
75+
76+ if end_datetime is not None :
77+ query = query .filter (APIRequestSQL .created_utc <= end_datetime )
78+
6879 return query .all ()
6980
7081
0 commit comments