Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion data-tool/flows/auth/inspect_auth_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class InspectAuthSettings:
invite_expiry_days: int = 7
invite_expiry_cutoff: datetime | None = None
invite_criteria: InviteCriteria | None = None

file_cnt_last_2yrs: int | None = None
@property
def run_verify(self) -> bool:
"""Return False so shared Auth batches only read Auth state."""
Expand Down Expand Up @@ -187,6 +187,13 @@ def validate_inspect_config(config: Any) -> InspectAuthSettings:
raise ValueError("AUTH_REPORT_BATCH_SIZE must be greater than 0")

inspect_filter = parse_inspect_filter(getattr(config, "INSPECT_AUTH_FILTER", None), "INSPECT_AUTH_FILTER")
file_cnt_raw = blank_to_none(getattr(config, "INSPECT_AUTH_FILE_CNT_LAST_2YRS", None))
file_cnt_last_2yrs = None
if file_cnt_raw is not None:
try:
file_cnt_last_2yrs = int(file_cnt_raw)
except (TypeError, ValueError) as exc:
raise ValueError("INSPECT_AUTH_FILE_CNT_LAST_2YRS must be a non-negative integer") from exc
invite_expiry_days = parse_invite_expiry_days(
getattr(config, "INSPECT_AUTH_INVITE_EXPIRY_DAYS", None)
)
Expand Down Expand Up @@ -266,6 +273,7 @@ def validate_inspect_config(config: Any) -> InspectAuthSettings:
invite_expiry_days=invite_expiry_days,
invite_expiry_cutoff=invite_expiry_cutoff,
invite_criteria=invite_criteria,
file_cnt_last_2yrs=file_cnt_last_2yrs,
)


Expand Down
10 changes: 10 additions & 0 deletions data-tool/flows/auth/verify_auth_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,16 @@ def build_candidate_queries(config: Any, settings: AuthCandidateSettings | None
auth_mig_group_ids=settings.auth_mig_group_ids,
auth_mig_batch_ids=settings.auth_mig_batch_ids,
).strip()
file_cnt_gt = getattr(settings, "file_cnt_last_2yrs", None)
if file_cnt_gt is not None:
base_sql = f"""
SELECT candidates.corp_num
FROM (
{base_sql}
) candidates
INNER JOIN mv_legacy_corps_data lcd ON lcd.corp_num = candidates.corp_num
WHERE lcd.file_cnt_last_2yrs > {int(file_cnt_gt)}
""".strip()

count_sql = f"""
SELECT COUNT(*)
Expand Down
1 change: 1 addition & 0 deletions data-tool/flows/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class _Config(): # pylint: disable=too-few-public-methods
# inspect Auth flow. HAS_CONTACT / ENTITY_WITHOUT_CONTACT mean usable contact email,
# not merely any raw contact row.
INSPECT_AUTH_FILTER = (os.getenv('INSPECT_AUTH_FILTER') or 'ALL').strip() or 'ALL'
INSPECT_AUTH_FILE_CNT_LAST_2YRS = os.getenv('INSPECT_AUTH_FILE_CNT_LAST_2YRS')
# Invitation settings stay raw here and are validated only by inspect-auth.
# INSPECT_AUTH_INVITE_CRITERIA is an AND-composed clause list such as
# count>=3, all_expired, age[1]>=90, newest_age>30. Positions are chronological
Expand Down