MCPcopy Index your code
hub / github.com/codeaashu/claude-code / checkCachedPassesEligibility

Function checkCachedPassesEligibility

src/services/api/referral.ts:83–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81 * Returns current cached state and cache status
82 */
83export function checkCachedPassesEligibility(): {
84 eligible: boolean
85 needsRefresh: boolean
86 hasCache: boolean
87} {
88 if (!shouldCheckForPasses()) {
89 return {
90 eligible: false,
91 needsRefresh: false,
92 hasCache: false,
93 }
94 }
95
96 const orgId = getOauthAccountInfo()?.organizationUuid
97 if (!orgId) {
98 return {
99 eligible: false,
100 needsRefresh: false,
101 hasCache: false,
102 }
103 }
104
105 const config = getGlobalConfig()
106 const cachedEntry = config.passesEligibilityCache?.[orgId]
107
108 if (!cachedEntry) {
109 // No cached entry, needs fetch
110 return {
111 eligible: false,
112 needsRefresh: true,
113 hasCache: false,
114 }
115 }
116
117 const { eligible, timestamp } = cachedEntry
118 const now = Date.now()
119 const needsRefresh = now - timestamp > CACHE_EXPIRATION_MS
120
121 return {
122 eligible,
123 needsRefresh,
124 hasCache: true,
125 }
126}
127
128const CURRENCY_SYMBOLS: Record<string, string> = {
129 USD: '$',

Callers 3

isHiddenFunction · 0.85
tipRegistry.tsFile · 0.85

Calls 3

shouldCheckForPassesFunction · 0.85
getGlobalConfigFunction · 0.85
getOauthAccountInfoFunction · 0.50

Tested by

no test coverage detected