File tree Expand file tree Collapse file tree
services/apps/git_integration/src/crowdgit/services/affiliation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -396,6 +396,30 @@ def _parse_optional_date(value: str | None) -> date | None:
396396 except ValueError :
397397 return None
398398
399+ @staticmethod
400+ def _sanitize_date_range (
401+ date_start : date | None , date_end : date | None
402+ ) -> tuple [date | None , date | None ]:
403+ if date_end is not None and (date_start is None or date_end < date_start ):
404+ return None , None
405+ return date_start , date_end
406+
407+ def normalize_affiliation_dates (
408+ self ,
409+ affiliations : list [AffiliationContributorEntry ] | None ,
410+ ) -> list [AffiliationContributorEntry ] | None :
411+ if not affiliations :
412+ return affiliations
413+
414+ for entry in affiliations :
415+ for organization in entry .organizations :
416+ organization .date_start , organization .date_end = self ._sanitize_date_range (
417+ organization .date_start ,
418+ organization .date_end ,
419+ )
420+
421+ return affiliations
422+
399423 @classmethod
400424 def group_parse_rows (
401425 cls , rows : list [AffiliationParseRow ]
@@ -1029,6 +1053,8 @@ async def process_affiliations(
10291053 )
10301054 ai_cost += parse_cost
10311055
1056+ affiliations = self .normalize_affiliation_dates (affiliations )
1057+
10321058 if repository .parent_repo :
10331059 affiliations = await self .exclude_parent_repo_affiliations (
10341060 repository .parent_repo , affiliations
You can’t perform that action at this time.
0 commit comments