MCPcopy Create free account
hub / github.com/codecombat/codecombat / reconcileActivity

Function reconcileActivity

app/lib/user-utils.js:124–132  ·  view source on GitHub ↗
(localActivity, remoteActivity)

Source from the content-addressed store, hash-verified

122}
123
124function reconcileActivity (localActivity, remoteActivity) {
125 const remote = activityFromRemote(remoteActivity)
126 if (!localActivity) { return remote }
127 if (!remote) { return localActivity }
128 if ((remote.count ?? 0) > (localActivity.count ?? 0)) { return remote }
129 if ((remote.count ?? 0) < (localActivity.count ?? 0)) { return localActivity }
130 if ((remote.last ?? 0) > (localActivity.last ?? 0)) { return remote }
131 return localActivity
132}
133
134function writeActivityToCache (userId, activityName, activity) {
135 const key = getActivityStatusCacheKey(userId)

Callers

nothing calls this directly

Calls 1

activityFromRemoteFunction · 0.85

Tested by

no test coverage detected