-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Significant Events Endpoint for Article as a Living Document experiment #2
base: master
Are you sure you want to change the base?
Conversation
Update master
…ng section detection)
…ther in one timeline event
This reverts commit f719ae1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great overall! Just found one minor issue
routes/page/significant-events.js
Outdated
var titleDict = domainDict[keyTitle]; | ||
if (titleDict) { | ||
titleDict[item.revid] = item; | ||
titleDict.maxedOut = calculateCacheForTitleIsMaxedOut(titleDict); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This titleDict
is a copy of the value inside domainDict
so updating it doesn't update the value inside of domainDict
. This could be fixed by moving domainDict[keyTitle] = titleDict;
outside of the if/else block so that the updated value is set in the domainDict
in either case. I'm not sure if there's a way to get reference semantics here so you could update directly
routes/page/significant-events.js
Outdated
titleDict[item.revid] = item; | ||
titleDict.maxedOut = calculateCacheForTitleIsMaxedOut(titleDict); | ||
domainDict[keyTitle] = titleDict; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above but for the domainDict
, should be fixed by moving significantChangesCache[req.params.domain] = domainDict;
below out of the if/else block
|
||
return Object.assign({ | ||
uncachedRevisions: uncachedRevisions, | ||
cachedOutput: cachedOutput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed cachedOutput
is always empty, even on subsequent requests for the same title. Seems to be fixed by making the changes suggested below
routes/page/significant-events.js
Outdated
domainDict = {}; | ||
domainDict[keyTitle] = titleDict; | ||
significantChangesCache[req.params.domain] = domainDict; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the comments above, and that ||
in JS works kind of like ??
in Swift, this could be updated to:
function setSignificantChangesCache(req, title, item) {
const keyTitle = keyTitleForCache(req, title);
var domainDict = significantChangesCache[req.params.domain] || {};
var titleDict = domainDict[keyTitle] || {};
titleDict[item.revid] = item;
titleDict.maxedOut = calculateCacheForTitleIsMaxedOut(titleDict);
domainDict[keyTitle] = titleDict;
significantChangesCache[req.params.domain] = domainDict;
}
routes/page/significant-events.js
Outdated
} | ||
|
||
// clean out from talk page cache | ||
// todo: why on earth do we get a talkPageTitle is not a function error here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you had:
var talkPageTitle = talkPageTitle(req);
the function is already shaded by the variable name. Could be fixed by renaming the function to getTalkPageTitle
or using a different variable name
…nupCache Change-Id: Ia2b76a7bfc63f34dccfb678a27ae42287c6d0c96
Change-Id: I9c5f795e76d4564022cdd79a53162e5672d16bd8
…solutely necessary
https://phabricator.wikimedia.org/T241253