diff options
Diffstat (limited to 'jb/flow/tasks.py')
| -rw-r--r-- | jb/flow/tasks.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/jb/flow/tasks.py b/jb/flow/tasks.py index e7c64b9..808c8f7 100644 --- a/jb/flow/tasks.py +++ b/jb/flow/tasks.py @@ -1,5 +1,6 @@ import logging import time +from typing import TypedDict, cast from generalresearchutils.config import is_debug @@ -15,6 +16,11 @@ logger = logging.getLogger() logger.setLevel(logging.INFO) +class HitRow(TypedDict): + amt_hit_id: str + amt_hit_type_id: str + + def check_stale_hits(): # Check live hits that haven't been modified in a long time. They may not # be expired yet, but maybe something is wrong? @@ -28,7 +34,7 @@ def check_stale_hits(): LIMIT 100;""", params={"status": HitStatus.Assignable.value}, ) - for hit in res: + for hit in cast(list[HitRow], res): logging.info(f"check_stale_hits: {hit["amt_hit_id"]}") check_hit_status( amt_hit_id=hit["amt_hit_id"], @@ -49,7 +55,7 @@ def check_expired_hits(): LIMIT 100;""", params={"status": HitStatus.Assignable.value}, ) - for hit in res: + for hit in cast(list[HitRow], res): logging.info(f"check_expired_hits: {hit["amt_hit_id"]}") check_hit_status( amt_hit_id=hit["amt_hit_id"], @@ -74,8 +80,12 @@ def create_hit_from_hittype(hit_type: HitType) -> Hit: def refill_hits() -> None: + for hit_type in HTM.filter_active(): - active_count = HM.get_active_count(hit_type.id) + assert hit_type.id + assert hit_type.amt_hit_type_id + + active_count = HM.get_active_count(hit_type_id=hit_type.id) logging.info( f"HitType: {hit_type.amt_hit_type_id}, {hit_type.min_active=}, active_count={active_count}" ) |
