Skip to content

Commit e0db545

Browse files
committed
fix: enhance affiliation stint key to include organization details and date fields
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent b469ca8 commit e0db545

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

services/apps/git_integration/src/crowdgit/services/affiliation/affiliation_service.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,13 +610,35 @@ def has_existing_stint(
610610

611611
@staticmethod
612612
def affiliation_stint_key(
613-
contributor: AffiliationContributor, domain: str
614-
) -> tuple[str, str, str] | None:
615-
domain = domain.lower()
613+
contributor: AffiliationContributor,
614+
organization: AffiliationOrganizationStint,
615+
) -> tuple[str, str, str, date | None, date | None, bool] | None:
616+
domain = organization.domain.lower()
617+
date_start = organization.date_start
618+
date_end = organization.date_end
619+
if isinstance(date_start, datetime):
620+
date_start = date_start.date()
621+
if isinstance(date_end, datetime):
622+
date_end = date_end.date()
623+
616624
if contributor.email:
617-
return ("email", contributor.email.lower(), domain)
625+
return (
626+
"email",
627+
contributor.email.lower(),
628+
domain,
629+
date_start,
630+
date_end,
631+
organization.is_unaffiliated,
632+
)
618633
if contributor.github:
619-
return ("github", contributor.github.lower(), domain)
634+
return (
635+
"github",
636+
contributor.github.lower(),
637+
domain,
638+
date_start,
639+
date_end,
640+
organization.is_unaffiliated,
641+
)
620642
return None
621643

622644
async def exclude_parent_repo_affiliations(
@@ -636,15 +658,15 @@ async def exclude_parent_repo_affiliations(
636658
key
637659
for entry in parent_snapshot
638660
for organization in entry.organizations
639-
if (key := self.affiliation_stint_key(entry.contributor, organization.domain))
661+
if (key := self.affiliation_stint_key(entry.contributor, organization))
640662
}
641663

642664
fork_entries: list[AffiliationContributorEntry] = []
643665
for entry in extracted_affiliations:
644666
organizations = [
645667
organization
646668
for organization in entry.organizations
647-
if (key := self.affiliation_stint_key(entry.contributor, organization.domain))
669+
if (key := self.affiliation_stint_key(entry.contributor, organization))
648670
is None
649671
or key not in parent_stint_keys
650672
]

0 commit comments

Comments
 (0)