diff options
| author | Max Nanis | 2026-03-07 21:06:45 -0500 |
|---|---|---|
| committer | Max Nanis | 2026-03-07 21:06:45 -0500 |
| commit | b2e56ec3ebc5eb91eb10cc37cc9e02102f441660 (patch) | |
| tree | bc6fa4d29ed83e2294f79e24977f77e7263997a1 /generalresearch/grliq/managers/forensic_results.py | |
| parent | 9833e57ccd2f9ec2090ab1f7da97500a071664b9 (diff) | |
| download | generalresearch-b2e56ec3ebc5eb91eb10cc37cc9e02102f441660.tar.gz generalresearch-b2e56ec3ebc5eb91eb10cc37cc9e02102f441660.zip | |
Simple typing changes, Ruff import formatter.
Diffstat (limited to 'generalresearch/grliq/managers/forensic_results.py')
| -rw-r--r-- | generalresearch/grliq/managers/forensic_results.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/generalresearch/grliq/managers/forensic_results.py b/generalresearch/grliq/managers/forensic_results.py index dd1b039..30db53d 100644 --- a/generalresearch/grliq/managers/forensic_results.py +++ b/generalresearch/grliq/managers/forensic_results.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Optional, List, Collection, Dict, Tuple +from typing import Any, Collection, Dict, List, Optional, Tuple from generalresearch.grliq.models.forensic_result import ( GrlIqForensicCategoryResult, @@ -25,9 +25,10 @@ class GrlIqCategoryResultsReader: created_between: Optional[Tuple[datetime, datetime]] = None, user: Optional[User] = None, limit: Optional[int] = None, - ) -> List[Dict]: + ) -> List[Dict[str, Any]]: """ For retrieving GrlIqForensicCategoryResult objects from db. + :return: List of Dict. Keys are below in the 'select_str'. """ select_str = ( @@ -37,10 +38,11 @@ class GrlIqCategoryResultsReader: " category_result, is_attempt_allowed, fraud_score" ) if not limit: - limit = 5000 + limit = 5_000 filters = [] params = {} + if session_uuid: params["session_uuid"] = session_uuid filters.append("d.session_uuid = %(session_uuid)s") @@ -77,6 +79,7 @@ class GrlIqCategoryResultsReader: filters.append( "(d.product_id = %(product_id)s AND d.product_user_id = %(product_user_id)s)" ) + filter_str = " AND ".join(filters) filter_str = "WHERE " + filter_str if filter_str else "" query = f""" @@ -85,6 +88,7 @@ class GrlIqCategoryResultsReader: {filter_str} ORDER BY created_at DESC LIMIT {limit} """ + with self.postgres_config.make_connection() as conn: with conn.cursor() as c: c.execute(query, params) |
