@@ -728,6 +728,7 @@ def try_add_open_or_closed_pr(
728728 pr_raw : Dict ,
729729 pr_state : str ,
730730 lookback_date_filter : datetime ,
731+ registration_cutoff : Optional [datetime ] = None ,
731732) -> None :
732733 """
733734 Attempts to add an OPEN or CLOSED PR to miner_eval if eligible.
@@ -737,6 +738,7 @@ def try_add_open_or_closed_pr(
737738 pr_raw: Raw PR data from GraphQL
738739 pr_state: GitHub PR state (OPEN, CLOSED, MERGED)
739740 lookback_date_filter: Date filter for lookback period
741+ registration_cutoff: Skip closed PRs whose closed_at is earlier than this cutoff
740742 """
741743 # Ignore all maintainer contributions
742744 if not os .environ .get ('DEV_MODE' ) and pr_raw .get ('authorAssociation' ) in MAINTAINER_ASSOCIATIONS :
@@ -764,6 +766,9 @@ def try_add_open_or_closed_pr(
764766 if created_dt < lookback_date_filter :
765767 return
766768
769+ if registration_cutoff is not None and closed_dt < registration_cutoff :
770+ return
771+
767772 if closed_dt >= lookback_date_filter :
768773 miner_eval .add_closed_pull_request (pr_raw )
769774
@@ -773,6 +778,7 @@ def should_skip_merged_pr(
773778 repository_full_name : str ,
774779 repo_config : RepositoryConfig ,
775780 lookback_date_filter : datetime ,
781+ registration_cutoff : Optional [datetime ] = None ,
776782) -> tuple [bool , Optional [str ]]:
777783 """
778784 Validate a merged PR against all eligibility criteria.
@@ -782,6 +788,7 @@ def should_skip_merged_pr(
782788 repository_full_name (str): Full repository name (owner/repo)
783789 repo_config (RepositoryConfig): Repository configuration
784790 lookback_date_filter (datetime): Date filter for lookback period
791+ registration_cutoff (Optional[datetime]): Skip merged PRs whose merged_at is earlier than this cutoff
785792
786793 Returns:
787794 tuple[bool, Optional[str]]: (should_skip, skip_reason) - True if PR should be skipped with reason
@@ -799,6 +806,12 @@ def should_skip_merged_pr(
799806 f'Skipping PR #{ pr_raw ["number" ]} in { repository_full_name } - merged before { PR_LOOKBACK_DAYS } -day lookback window' ,
800807 )
801808
809+ if registration_cutoff is not None and merged_dt < registration_cutoff :
810+ return (
811+ True ,
812+ f'Skipping PR #{ pr_raw ["number" ]} in { repository_full_name } - merged before miner registration on this validator' ,
813+ )
814+
802815 # Skip if PR author is a maintainer
803816 author_association = pr_raw .get ('authorAssociation' )
804817 if not os .environ .get ('DEV_MODE' ) and author_association in MAINTAINER_ASSOCIATIONS :
@@ -854,7 +867,10 @@ def should_skip_merged_pr(
854867
855868
856869def load_miners_prs (
857- miner_eval : MinerEvaluation , master_repositories : Dict [str , RepositoryConfig ], max_prs : int = 1000
870+ miner_eval : MinerEvaluation ,
871+ master_repositories : Dict [str , RepositoryConfig ],
872+ max_prs : int = 1000 ,
873+ registration_cutoff : Optional [datetime ] = None ,
858874) -> None :
859875 """
860876 Fetches user PRs via GraphQL API and categorize them by state.
@@ -864,6 +880,7 @@ def load_miners_prs(
864880 miner_eval: The MinerEvaluation object containing github details + more
865881 master_repositories: Repository metadata (name -> RepositoryConfig)
866882 max_prs: Maximum merged PRs to fetch
883+ registration_cutoff: Skip PRs (merged or closed) whose effective timestamp predates this cutoff
867884 """
868885 bt .logging .info ('*****Fetching PRs*****' )
869886 miner_eval .github_pr_fetch_failed = False
@@ -945,11 +962,17 @@ def load_miners_prs(
945962 continue
946963
947964 if pr_state in (PRState .OPEN .value , PRState .CLOSED .value ):
948- try_add_open_or_closed_pr (miner_eval , pr_raw , pr_state , lookback_date_filter )
965+ try_add_open_or_closed_pr (
966+ miner_eval , pr_raw , pr_state , lookback_date_filter , registration_cutoff = registration_cutoff
967+ )
949968 continue
950969
951970 should_skip , skip_reason = should_skip_merged_pr (
952- pr_raw , repository_full_name , repo_config , lookback_date_filter
971+ pr_raw ,
972+ repository_full_name ,
973+ repo_config ,
974+ lookback_date_filter ,
975+ registration_cutoff = registration_cutoff ,
953976 )
954977
955978 if should_skip :
0 commit comments