the-algorithm/follow-recommendations-service/common/src/main/scala/com/twitter/follow_recommendations/common/utils/UserSignupUtil.scala
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
2023-03-31 17:36:31 -05:00

15 lines
545 B
Scala

package com.twitter.follow_recommendations.common.utils
import com.twitter.product_mixer.core.model.marshalling.request.HasClientContext
import com.twitter.snowflake.id.SnowflakeId
import com.twitter.util.Duration
import com.twitter.util.Time
object UserSignupUtil {
def signupTime(hasClientContext: HasClientContext): Option[Time] =
hasClientContext.clientContext.userId.flatMap(SnowflakeId.timeFromIdOpt)
def userSignupAge(hasClientContext: HasClientContext): Option[Duration] =
signupTime(hasClientContext).map(Time.now - _)
}