The Resurfaced Memory — JavaScript Bug Hunt
Inspired by Facebook's Year in Review resurfacing posts people had deleted or locked down.
- Language: JavaScript
- Layer: Frontend
- Difficulty: Easy
- Concepts: Filtering, Privacy
- Modelled on: Facebook · Year in Review
- Visible tests: deleted posts never appear; private posts never appear; most liked comes first
- Reward: 50 XP for a complete fix
Briefing
Inspired by Facebook's Year in Review resurfacing posts people had deleted or locked down. The highlight reel must only ever contain public, non-deleted posts — sorted by likes, best first.
The bug hides in one filter expression in yearReview.js.
Bug report
BUG-2014 · Priority: Critical (trust) · Reported by: comms
- Deleted posts are appearing in Year in Review reels.
- Private posts appear too.
- The "top" post shown is actually the LEAST liked one.
Spec: exclude deleted posts, exclude visibility "private", return the top N by likes, most-liked first.
Logs
[review] included post id=77 deleted=true
[review] first slide likes=2, last slide likes=9540The code as shipped
src/review/yearReview.js (editable)
// Builds the year-in-review highlight reel.
exports.buildReel = function (posts, topN) {
var eligible = posts.filter(function (p) {
return !p.deleted || p.visibility !== "private";
});
eligible.sort(function (a, b) {
return a.likes - b.likes;
});
return eligible.slice(0, topN);
};
Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.