in sourcecode/scoring/contributor_state.py [0:0]
def single_trigger_earn_out(contributorScoresWithEnrollment: pd.DataFrame) -> pd.DataFrame:
"""
A function that earns out users with a negative writing impact upon any CRNH note
Args:
contributorScoresWithEnrollment (pd.DataFrame): contributor scores with state and current enrollment
Returns:
pd.DataFrame: updated contributor scores reflecting single trigger earned out users
"""
earnedOutUsers = (
(
contributorScoresWithEnrollment[c.notesCurrentlyRatedNotHelpful].fillna(0, inplace=False)
> contributorScoresWithEnrollment[c.notesCurrentlyRatedHelpful].fillna(0, inplace=False)
)
& (contributorScoresWithEnrollment[c.hasCrnhSinceEarnOut] == True)
& (
contributorScoresWithEnrollment[c.enrollmentState]
!= c.enrollmentStateToThrift[c.earnedOutNoAcknowledge]
)
& (
contributorScoresWithEnrollment[c.enrollmentState]
!= c.enrollmentStateToThrift[c.earnedOutAcknowledged]
)
& (contributorScoresWithEnrollment[c.enrollmentState] != c.enrollmentStateToThrift[c.newUser])
& (contributorScoresWithEnrollment[c.enrollmentState] != c.enrollmentStateToThrift[c.removed])
)
contributorScoresWithEnrollment.loc[earnedOutUsers, c.numberOfTimesEarnedOutKey] = (
contributorScoresWithEnrollment.loc[earnedOutUsers, c.numberOfTimesEarnedOutKey] + 1
)
# use earned out no ack internally to identify newly earned out users
contributorScoresWithEnrollment.loc[
earnedOutUsers, c.enrollmentState
] = c.enrollmentStateToThrift[c.earnedOutNoAcknowledge]
contributorScoresWithEnrollment.loc[earnedOutUsers, c.timestampOfLastStateChange] = c.epochMillis
return contributorScoresWithEnrollment.drop(columns=[c.hasCrnhSinceEarnOut])