learningequality/ka-lite — pull request #215 by bcipolli (2013-07-09 12:54:33+00:00)
Title: Multipath NODE_CACHE

This pull request is dependent on #211, resolves #210 and #125, and makes #204 straightforward to implement. Please address #211 and allow that to be merged before reviewing here.

As described in #210, exercise and video nodes are mapped to many paths. Thus, when mapping from the topic tree to the NODE_CACHE, which is indexed by slug, more than one exercise and video nodes at different paths collided with the same slug.

Previously, we simply kept one path, and forgot about the others. However, this can cause strange behavior (for example, in being linked to a very different place in the topic hierarchy when following a "related videos" link) or outright bugs (failure to invalidate all cached items when a video is downloaded / deleted).

The current change is to keep a collection of paths on exercise and video nodes in the NODE_CACHE. All code dependent on NODE_CACHE exercise and video nodes having a "path" property had to change. In making this change, I made the following functional changes:
* Cache invalidation now happens for all related exercises, videos, and topics, over all video paths, given a single youtube_id
* Related videos link to the video at a sibling URL to the exercise linked from when possible.