GitHub PullRequestReviewCommentEvent at 2014-04-09 19:39:55
Repository: darjeeling
Actor: chuckharmston
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla/darjeeling/pulls/comments/11454905","id":11454905,"diff_hunk":"@@ -0,0 +1,74 @@\n+define('featured', ['settings', 'storage', 'log'], function(settings, storage, log) {\n+\n+  var console = log('featured');\n+\n+  // Constants representing cache keys.\n+  var ALL_FEATURED_APPS = 'featured_apps_all';\n+  var FEATURED_APPS = 'featured_apps_cached';\n+  var LAST_UPDATED = 'featured_apps_last_updated';\n+\n+  return {\n+\n+    all: function() {\n+      // This will eventually fetch from the JSON database. For now...\n+      var cached = JSON.parse(storage.getItem(ALL_FEATURED_APPS));\n+      if (!cached) {\n+        cached = [\n+          { name: 'trenta', weight: 10 },\n+          { name: 'venti', weight: 8 },\n+          { name: 'grande', weight: 6 },\n+          { name: 'tall', weight: 4 },\n+          { name: 'nessuno', weight: 2 }\n+        ];\n+        storage.setItem(JSON.stringify(ALL_FEATURED_APPS || {}), cached);\n+      }\n+      return cached;\n+    },\n+\n+    get: function() {\n+      // Retrieve a subset of the featured apps from cache. If the cache has\n+      // expired, regenerate a random subset and return the featured apps.\n+      var today = new Date().toDateString();\n+      if (storage.getItem(LAST_UPDATED) === new Date().toDateString()) {\n+        console.log('Using featured apps from cache: ' + today);\n+        return JSON.parse(storage.getItem(FEATURED_APPS));\n+      }\n+      var regenerated = this.regenerate();\n+      storage.setItem(FEATURED_APPS, JSON.stringify(regenerated || {}))\n+      storage.setItem(LAST_UPDATED, today);\n+      return regenerated;\n+    },\n+\n+    regenerate: function() {\n+      // From the pool of featured apps, returned a randomized, weighted selection to be","path":"src/media/js/featured.js","position":43,"original_position":43,"commit_id":"370ad566d4daf06f8561e04e8ebacbe12642dff9","original_commit_id":"370ad566d4daf06f8561e04e8ebacbe12642dff9","user":{"login":"chuckharmston","id":23885,"avatar_url":"https://avatars.githubusercontent.com/u/23885?","gravatar_id":"092d9d22975c92c4004ad0b3d189a093","url":"https://api.github.com/users/chuckharmston","html_url":"https://github.com/chuckharmston","followers_url":"https://api.github.com/users/chuckharmston/followers","following_url":"https://api.github.com/users/chuckharmston/following{/other_user}","gists_url":"https://api.github.com/users/chuckharmston/gists{/gist_id}","starred_url":"https://api.github.com/users/chuckharmston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuckharmston/subscriptions","organizations_url":"https://api.github.com/users/chuckharmston/orgs","repos_url":"https://api.github.com/users/chuckharmston/repos","events_url":"https://api.github.com/users/chuckharmston/events{/privacy}","received_events_url":"https://api.github.com/users/chuckharmston/received_events","type":"User","site_admin":false},"body":"`return`","created_at":"2014-04-09T19:39:55Z","updated_at":"2014-04-09T19:39:55Z","html_url":"https://github.com/mozilla/darjeeling/pull/3#discussion_r11454905","pull_request_url":"https://api.github.com/repos/mozilla/darjeeling/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/mozilla/darjeeling/pulls/comments/11454905"},"html":{"href":"https://github.com/mozilla/darjeeling/pull/3#discussion_r11454905"},"pull_request":{"href":"https://api.github.com/repos/mozilla/darjeeling/pulls/3"}}}}