{"action":"created","comment":{"url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/comments/59137561","id":59137561,"diff_hunk":"@@ -1,160 +1,230 @@\n (function (angular) {\n     'use strict';\n \n-    angular.module('znk.infra.contentAvail').service('ContentAvailSrv', [\n-        '$q', '$parse', 'InfraConfigSrv',\n-        function ($q, $parse, InfraConfigSrv) {\n-            var PURCHASED_ALL = 'all';\n-\n-            function getUserPurchaseData(){\n-                var StorageService = InfraConfigSrv.getStorageService();\n-                var purchaseDataPath = StorageService.variables.appUserSpacePath + '/purchase';\n-                var defValues = {\n-                    daily: 0,\n-                    exam: {},\n-                    tutorial: {},\n-                    subscription: {}\n-                };\n-                return StorageService.get(purchaseDataPath,defValues);\n-            }\n-\n-            function getFreeContentData(){\n-                var StorageService = InfraConfigSrv.getStorageService();\n-                var freeContentPath = 'freeContent';\n-                var defValues = {\n-                    daily: 0,\n-                    exam: {},\n-                    tutorial: {}\n-                };\n-                return StorageService.get(freeContentPath,defValues);\n-            }\n-\n-            function idToKeyInStorage(id){\n-                return 'id_' + id;\n-            }\n-\n-            function _hasSubscription(subscriptionObj){\n-                return subscriptionObj && subscriptionObj.expiryDate && subscriptionObj.expiryDate > Date.now();\n-            }\n-\n-            function _baseIsEntityAvail(){\n-                return $q.all([getUserPurchaseData(),getFreeContentData()]).then(function(res){\n-                    var purchaseData = res[0];\n-                    var hasSubscription = _hasSubscription(purchaseData.subscription);\n-                    if(hasSubscription){\n-                        return true;\n-                    }else{\n-                        return res;\n-                    }\n-                });\n-            }\n-\n-            function _isExamPurchased(purchaseData,examId){\n-                var examKeyProp = idToKeyInStorage(examId);\n-                return !!(purchaseData.exam === PURCHASED_ALL  || purchaseData.exam[examKeyProp]);\n-            }\n-\n-            function _isFreeContent(freeContentData,pathArr){\n-                var fullPath = pathArr.join('.');\n-                var isFreeGetter = $parse(fullPath);\n-                return !!isFreeGetter(freeContentData);\n-            }\n-\n-            this.hasSubscription = function(){\n-                return getUserPurchaseData().then(function(purchaseData){\n-                    return _hasSubscription(purchaseData.subscription);\n-                });\n+    angular.module('znk.infra.contentAvail').provider('ContentAvailSrv', [\n+        function () {\n+\n+            var _specials;\n+\n+            this.setSpecials = function(specialsObj) {\n+                _specials = specialsObj;\n             };\n \n-            this.isDailyAvail = function(dailyOrder){\n-                if(!angular.isNumber(dailyOrder) || isNaN(dailyOrder)){\n-                    return $q.reject('daily order should be a number');\n+            this.$get = ['$q', '$parse', '$injector', 'InfraConfigSrv', function($q, $parse, $injector, InfraConfigSrv) {\n+\n+                var PURCHASED_ALL = 'all';\n+\n+                function getUserPurchaseData(){\n+                    var StorageService = InfraConfigSrv.getStorageService();\n+                    var purchaseDataPath = StorageService.variables.appUserSpacePath + '/purchase';\n+                    var defValues = {\n+                        daily: 0,\n+                        exam: {},\n+                        tutorial: {},\n+                        subscription: {}\n+                    };\n+                    return StorageService.get(purchaseDataPath,defValues);\n                 }\n-                return _baseIsEntityAvail().then(function(res){\n-                    if(res === true){\n-                        return true;\n-                    }\n \n-                    var purchaseData = res[0];\n-                    var freeContent = res[1];\n+                function getFreeContentData(){\n+                    var StorageService = InfraConfigSrv.getStorageService();\n+                    var freeContentPath = 'freeContent';\n+                    var defValues = {\n+                        daily: 0,\n+                        exam: {},\n+                        tutorial: {},\n+                        specials: {}\n+                    };\n+                    return StorageService.get(freeContentPath,defValues);\n+                }\n \n-                    if(freeContent.daily >= dailyOrder){\n-                        return true;\n-                    }\n+                function getUserSpecialsData(){","path":"src/components/contentAvail/contentAvailSrv.js","position":116,"original_position":116,"commit_id":"7c6cbb211d3f6263f725f269beec5aec903575e5","original_commit_id":"7c6cbb211d3f6263f725f269beec5aec903575e5","user":{"login":"igormas","id":7754236,"avatar_url":"https://avatars.githubusercontent.com/u/7754236?v=3","gravatar_id":"","url":"https://api.github.com/users/igormas","html_url":"https://github.com/igormas","followers_url":"https://api.github.com/users/igormas/followers","following_url":"https://api.github.com/users/igormas/following{/other_user}","gists_url":"https://api.github.com/users/igormas/gists{/gist_id}","starred_url":"https://api.github.com/users/igormas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igormas/subscriptions","organizations_url":"https://api.github.com/users/igormas/orgs","repos_url":"https://api.github.com/users/igormas/repos","events_url":"https://api.github.com/users/igormas/events{/privacy}","received_events_url":"https://api.github.com/users/igormas/received_events","type":"User","site_admin":false},"body":"Why just not to set a function which return the specials map instead of iterating ?","created_at":"2016-04-10T17:23:39Z","updated_at":"2016-04-10T17:23:39Z","html_url":"https://github.com/Knowledge-OTP/infra/pull/116#discussion_r59137561","pull_request_url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/comments/59137561"},"html":{"href":"https://github.com/Knowledge-OTP/infra/pull/116#discussion_r59137561"},"pull_request":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116","id":65914659,"html_url":"https://github.com/Knowledge-OTP/infra/pull/116","diff_url":"https://github.com/Knowledge-OTP/infra/pull/116.diff","patch_url":"https://github.com/Knowledge-OTP/infra/pull/116.patch","issue_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues/116","number":116,"state":"open","locked":false,"title":"oded/content-specials","user":{"login":"odeds","id":4070881,"avatar_url":"https://avatars.githubusercontent.com/u/4070881?v=3","gravatar_id":"","url":"https://api.github.com/users/odeds","html_url":"https://github.com/odeds","followers_url":"https://api.github.com/users/odeds/followers","following_url":"https://api.github.com/users/odeds/following{/other_user}","gists_url":"https://api.github.com/users/odeds/gists{/gist_id}","starred_url":"https://api.github.com/users/odeds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeds/subscriptions","organizations_url":"https://api.github.com/users/odeds/orgs","repos_url":"https://api.github.com/users/odeds/repos","events_url":"https://api.github.com/users/odeds/events{/privacy}","received_events_url":"https://api.github.com/users/odeds/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-10T16:07:08Z","updated_at":"2016-04-10T17:23:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efc55df6d744d2e49a8d28f631e964611ca6a9ee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116/commits","review_comments_url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116/comments","review_comment_url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues/116/comments","statuses_url":"https://api.github.com/repos/Knowledge-OTP/infra/statuses/7c6cbb211d3f6263f725f269beec5aec903575e5","head":{"label":"Knowledge-OTP:oded/content-specials","ref":"oded/content-specials","sha":"7c6cbb211d3f6263f725f269beec5aec903575e5","user":{"login":"Knowledge-OTP","id":6382607,"avatar_url":"https://avatars.githubusercontent.com/u/6382607?v=3","gravatar_id":"","url":"https://api.github.com/users/Knowledge-OTP","html_url":"https://github.com/Knowledge-OTP","followers_url":"https://api.github.com/users/Knowledge-OTP/followers","following_url":"https://api.github.com/users/Knowledge-OTP/following{/other_user}","gists_url":"https://api.github.com/users/Knowledge-OTP/gists{/gist_id}","starred_url":"https://api.github.com/users/Knowledge-OTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Knowledge-OTP/subscriptions","organizations_url":"https://api.github.com/users/Knowledge-OTP/orgs","repos_url":"https://api.github.com/users/Knowledge-OTP/repos","events_url":"https://api.github.com/users/Knowledge-OTP/events{/privacy}","received_events_url":"https://api.github.com/users/Knowledge-OTP/received_events","type":"Organization","site_admin":false},"repo":{"id":44325496,"name":"infra","full_name":"Knowledge-OTP/infra","owner":{"login":"Knowledge-OTP","id":6382607,"avatar_url":"https://avatars.githubusercontent.com/u/6382607?v=3","gravatar_id":"","url":"https://api.github.com/users/Knowledge-OTP","html_url":"https://github.com/Knowledge-OTP","followers_url":"https://api.github.com/users/Knowledge-OTP/followers","following_url":"https://api.github.com/users/Knowledge-OTP/following{/other_user}","gists_url":"https://api.github.com/users/Knowledge-OTP/gists{/gist_id}","starred_url":"https://api.github.com/users/Knowledge-OTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Knowledge-OTP/subscriptions","organizations_url":"https://api.github.com/users/Knowledge-OTP/orgs","repos_url":"https://api.github.com/users/Knowledge-OTP/repos","events_url":"https://api.github.com/users/Knowledge-OTP/events{/privacy}","received_events_url":"https://api.github.com/users/Knowledge-OTP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Knowledge-OTP/infra","description":"","fork":false,"url":"https://api.github.com/repos/Knowledge-OTP/infra","forks_url":"https://api.github.com/repos/Knowledge-OTP/infra/forks","keys_url":"https://api.github.com/repos/Knowledge-OTP/infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Knowledge-OTP/infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Knowledge-OTP/infra/teams","hooks_url":"https://api.github.com/repos/Knowledge-OTP/infra/hooks","issue_events_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues/events{/number}","events_url":"https://api.github.com/repos/Knowledge-OTP/infra/events","assignees_url":"https://api.github.com/repos/Knowledge-OTP/infra/assignees{/user}","branches_url":"https://api.github.com/repos/Knowledge-OTP/infra/branches{/branch}","tags_url":"https://api.github.com/repos/Knowledge-OTP/infra/tags","blobs_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Knowledge-OTP/infra/statuses/{sha}","languages_url":"https://api.github.com/repos/Knowledge-OTP/infra/languages","stargazers_url":"https://api.github.com/repos/Knowledge-OTP/infra/stargazers","contributors_url":"https://api.github.com/repos/Knowledge-OTP/infra/contributors","subscribers_url":"https://api.github.com/repos/Knowledge-OTP/infra/subscribers","subscription_url":"https://api.github.com/repos/Knowledge-OTP/infra/subscription","commits_url":"https://api.github.com/repos/Knowledge-OTP/infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/Knowledge-OTP/infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/Knowledge-OTP/infra/contents/{+path}","compare_url":"https://api.github.com/repos/Knowledge-OTP/infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Knowledge-OTP/infra/merges","archive_url":"https://api.github.com/repos/Knowledge-OTP/infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Knowledge-OTP/infra/downloads","issues_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues{/number}","pulls_url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls{/number}","milestones_url":"https://api.github.com/repos/Knowledge-OTP/infra/milestones{/number}","notifications_url":"https://api.github.com/repos/Knowledge-OTP/infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Knowledge-OTP/infra/labels{/name}","releases_url":"https://api.github.com/repos/Knowledge-OTP/infra/releases{/id}","deployments_url":"https://api.github.com/repos/Knowledge-OTP/infra/deployments","created_at":"2015-10-15T15:05:15Z","updated_at":"2016-01-11T15:47:16Z","pushed_at":"2016-04-10T16:15:20Z","git_url":"git://github.com/Knowledge-OTP/infra.git","ssh_url":"git@github.com:Knowledge-OTP/infra.git","clone_url":"https://github.com/Knowledge-OTP/infra.git","svn_url":"https://github.com/Knowledge-OTP/infra","homepage":null,"size":32452,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"zinkerz/dev"}},"base":{"label":"Knowledge-OTP:zinkerz/dev","ref":"zinkerz/dev","sha":"d066a5d4235fb3722f4814910d700856da686196","user":{"login":"Knowledge-OTP","id":6382607,"avatar_url":"https://avatars.githubusercontent.com/u/6382607?v=3","gravatar_id":"","url":"https://api.github.com/users/Knowledge-OTP","html_url":"https://github.com/Knowledge-OTP","followers_url":"https://api.github.com/users/Knowledge-OTP/followers","following_url":"https://api.github.com/users/Knowledge-OTP/following{/other_user}","gists_url":"https://api.github.com/users/Knowledge-OTP/gists{/gist_id}","starred_url":"https://api.github.com/users/Knowledge-OTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Knowledge-OTP/subscriptions","organizations_url":"https://api.github.com/users/Knowledge-OTP/orgs","repos_url":"https://api.github.com/users/Knowledge-OTP/repos","events_url":"https://api.github.com/users/Knowledge-OTP/events{/privacy}","received_events_url":"https://api.github.com/users/Knowledge-OTP/received_events","type":"Organization","site_admin":false},"repo":{"id":44325496,"name":"infra","full_name":"Knowledge-OTP/infra","owner":{"login":"Knowledge-OTP","id":6382607,"avatar_url":"https://avatars.githubusercontent.com/u/6382607?v=3","gravatar_id":"","url":"https://api.github.com/users/Knowledge-OTP","html_url":"https://github.com/Knowledge-OTP","followers_url":"https://api.github.com/users/Knowledge-OTP/followers","following_url":"https://api.github.com/users/Knowledge-OTP/following{/other_user}","gists_url":"https://api.github.com/users/Knowledge-OTP/gists{/gist_id}","starred_url":"https://api.github.com/users/Knowledge-OTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Knowledge-OTP/subscriptions","organizations_url":"https://api.github.com/users/Knowledge-OTP/orgs","repos_url":"https://api.github.com/users/Knowledge-OTP/repos","events_url":"https://api.github.com/users/Knowledge-OTP/events{/privacy}","received_events_url":"https://api.github.com/users/Knowledge-OTP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Knowledge-OTP/infra","description":"","fork":false,"url":"https://api.github.com/repos/Knowledge-OTP/infra","forks_url":"https://api.github.com/repos/Knowledge-OTP/infra/forks","keys_url":"https://api.github.com/repos/Knowledge-OTP/infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Knowledge-OTP/infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Knowledge-OTP/infra/teams","hooks_url":"https://api.github.com/repos/Knowledge-OTP/infra/hooks","issue_events_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues/events{/number}","events_url":"https://api.github.com/repos/Knowledge-OTP/infra/events","assignees_url":"https://api.github.com/repos/Knowledge-OTP/infra/assignees{/user}","branches_url":"https://api.github.com/repos/Knowledge-OTP/infra/branches{/branch}","tags_url":"https://api.github.com/repos/Knowledge-OTP/infra/tags","blobs_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Knowledge-OTP/infra/statuses/{sha}","languages_url":"https://api.github.com/repos/Knowledge-OTP/infra/languages","stargazers_url":"https://api.github.com/repos/Knowledge-OTP/infra/stargazers","contributors_url":"https://api.github.com/repos/Knowledge-OTP/infra/contributors","subscribers_url":"https://api.github.com/repos/Knowledge-OTP/infra/subscribers","subscription_url":"https://api.github.com/repos/Knowledge-OTP/infra/subscription","commits_url":"https://api.github.com/repos/Knowledge-OTP/infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/Knowledge-OTP/infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/Knowledge-OTP/infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/Knowledge-OTP/infra/contents/{+path}","compare_url":"https://api.github.com/repos/Knowledge-OTP/infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Knowledge-OTP/infra/merges","archive_url":"https://api.github.com/repos/Knowledge-OTP/infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Knowledge-OTP/infra/downloads","issues_url":"https://api.github.com/repos/Knowledge-OTP/infra/issues{/number}","pulls_url":"https://api.github.com/repos/Knowledge-OTP/infra/pulls{/number}","milestones_url":"https://api.github.com/repos/Knowledge-OTP/infra/milestones{/number}","notifications_url":"https://api.github.com/repos/Knowledge-OTP/infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Knowledge-OTP/infra/labels{/name}","releases_url":"https://api.github.com/repos/Knowledge-OTP/infra/releases{/id}","deployments_url":"https://api.github.com/repos/Knowledge-OTP/infra/deployments","created_at":"2015-10-15T15:05:15Z","updated_at":"2016-01-11T15:47:16Z","pushed_at":"2016-04-10T16:15:20Z","git_url":"git://github.com/Knowledge-OTP/infra.git","ssh_url":"git@github.com:Knowledge-OTP/infra.git","clone_url":"https://github.com/Knowledge-OTP/infra.git","svn_url":"https://github.com/Knowledge-OTP/infra","homepage":null,"size":32452,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"zinkerz/dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116"},"html":{"href":"https://github.com/Knowledge-OTP/infra/pull/116"},"issue":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/issues/116"},"comments":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/Knowledge-OTP/infra/statuses/7c6cbb211d3f6263f725f269beec5aec903575e5"}}}}