{"action":"created","comment":{"url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/comments/43644086","id":43644086,"diff_hunk":"@@ -424,6 +429,140 @@ def check_deal_analytics(merchant_id)\n       deal_analytics\n     end\n \n+    # returns conversion rate of num wishlisters to viewers in percentage\n+    def get_wishlist_to_views(deal_id)\n+      push_date = Deal.find(deal_id).push_date\n+      num_wishlist = WishService.num_wishlist_deal(deal_id, push_date).to_f\n+      user_id = WishService.get_user_id(deal_id, push_date)\n+      num_views = Viewcount.where(user_id: user_id, deal_id: deal_id).uniq.where(:entry => 'merchant_push_notification').count.to_f\n+      conversion = (num_views/num_wishlist)*100\n+      conversion.round(2)\n+    end\n+\n+    # returns conversion rate of num unique views to redeems in percentage\n+    def get_views_to_redeem(deal_id)\n+      view_counts = ViewcountService.get_uniq_view_count(deal_id).to_f\n+      user_ids = ViewcountService.get_uniq_user_id(deal_id)\n+      redeem_count = RedemptionService.count_uniq_redemptions(deal_id, user_ids).to_f\n+      conversion = (redeem_count/view_counts)*100\n+      conversion.round(2)\n+    end\n+\n+    # returns percentage of user who redeemed more than once\n+    def get_multiple_redeems_percentage(deal_id)\n+      user_count = RedemptionService.count_uniq_redemptions(deal_id).to_f\n+      multiple_redeems = RedemptionService.num_users_multiple(deal_id).to_f\n+      percentage = (multiple_redeems/user_count)*100\n+      percentage.round(2)\n+    end\n+\n+    # returns average time between users who redeem more than once\n+    def average_time_btw_multiple_redeem(deal_id)\n+      multiple_redeems_user_ids = RedemptionService.get_user_ids(deal_id, true)\n+      if multiple_redeems_user_ids.blank?\n+        'No Redeems Yet'\n+      else\n+        (RedemptionService.get_average_days_between_redeems(deal_id, multiple_redeems_user_ids).to_s + ' days')\n+      end\n+    end\n+\n+    # returns a nested array\n+    # array[0] is cumulative increase in percentage per hour\n+    # array[1] is change in percentage per hour\n+    def get_wishlist_to_view(deal_id)\n+      array = Array.new\n+      cumulative = Array.new\n+      non_cumulative = Array.new\n+      push_date = Deal.find(deal_id).push_date.beginning_of_hour.to_datetime","path":"app/services/deal_analytic_service.rb","position":62,"original_position":62,"commit_id":"76c4d3075dd14b2c947536067b968feafd9acd7b","original_commit_id":"76c4d3075dd14b2c947536067b968feafd9acd7b","user":{"login":"Woonyong92","id":12532277,"avatar_url":"https://avatars.githubusercontent.com/u/12532277?v=3","gravatar_id":"","url":"https://api.github.com/users/Woonyong92","html_url":"https://github.com/Woonyong92","followers_url":"https://api.github.com/users/Woonyong92/followers","following_url":"https://api.github.com/users/Woonyong92/following{/other_user}","gists_url":"https://api.github.com/users/Woonyong92/gists{/gist_id}","starred_url":"https://api.github.com/users/Woonyong92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Woonyong92/subscriptions","organizations_url":"https://api.github.com/users/Woonyong92/orgs","repos_url":"https://api.github.com/users/Woonyong92/repos","events_url":"https://api.github.com/users/Woonyong92/events{/privacy}","received_events_url":"https://api.github.com/users/Woonyong92/received_events","type":"User","site_admin":false},"body":"@jkcheong92 noted will do updates","created_at":"2015-11-02T16:03:06Z","updated_at":"2015-11-02T16:03:06Z","html_url":"https://github.com/junwen29/amazingcoders-rails/pull/154#discussion_r43644086","pull_request_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154","_links":{"self":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/comments/43644086"},"html":{"href":"https://github.com/junwen29/amazingcoders-rails/pull/154#discussion_r43644086"},"pull_request":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154"}}},"pull_request":{"url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154","id":49370451,"html_url":"https://github.com/junwen29/amazingcoders-rails/pull/154","diff_url":"https://github.com/junwen29/amazingcoders-rails/pull/154.diff","patch_url":"https://github.com/junwen29/amazingcoders-rails/pull/154.patch","issue_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/154","number":154,"state":"open","locked":false,"title":"Das/new features","user":{"login":"Woonyong92","id":12532277,"avatar_url":"https://avatars.githubusercontent.com/u/12532277?v=3","gravatar_id":"","url":"https://api.github.com/users/Woonyong92","html_url":"https://github.com/Woonyong92","followers_url":"https://api.github.com/users/Woonyong92/followers","following_url":"https://api.github.com/users/Woonyong92/following{/other_user}","gists_url":"https://api.github.com/users/Woonyong92/gists{/gist_id}","starred_url":"https://api.github.com/users/Woonyong92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Woonyong92/subscriptions","organizations_url":"https://api.github.com/users/Woonyong92/orgs","repos_url":"https://api.github.com/users/Woonyong92/repos","events_url":"https://api.github.com/users/Woonyong92/events{/privacy}","received_events_url":"https://api.github.com/users/Woonyong92/received_events","type":"User","site_admin":false},"body":"@junwen29 @jkcheong92 \r\nAdded the analytic table and charts.\r\n\r\nAnyways do take note, i have commit some stuff then afterwards realise there was some bugs so made a few changes. Sorry abt it.\r\nI'll be seeding data for this so for now you need to manually add data to test.\r\nThe file below states my algo and the stuff you must seed\r\n\r\n[Analytics Algo.docx](https://github.com/junwen29/amazingcoders-rails/files/24852/Analytics.Algo.docx)\r\n","created_at":"2015-11-01T11:56:29Z","updated_at":"2015-11-02T16:03:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0ae6bb8c4a27f69653fb39da83b50818a2a1cc2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154/commits","review_comments_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154/comments","review_comment_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/154/comments","statuses_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/statuses/76c4d3075dd14b2c947536067b968feafd9acd7b","head":{"label":"junwen29:das/new_features","ref":"das/new_features","sha":"76c4d3075dd14b2c947536067b968feafd9acd7b","user":{"login":"junwen29","id":7575875,"avatar_url":"https://avatars.githubusercontent.com/u/7575875?v=3","gravatar_id":"","url":"https://api.github.com/users/junwen29","html_url":"https://github.com/junwen29","followers_url":"https://api.github.com/users/junwen29/followers","following_url":"https://api.github.com/users/junwen29/following{/other_user}","gists_url":"https://api.github.com/users/junwen29/gists{/gist_id}","starred_url":"https://api.github.com/users/junwen29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junwen29/subscriptions","organizations_url":"https://api.github.com/users/junwen29/orgs","repos_url":"https://api.github.com/users/junwen29/repos","events_url":"https://api.github.com/users/junwen29/events{/privacy}","received_events_url":"https://api.github.com/users/junwen29/received_events","type":"User","site_admin":false},"repo":{"id":41302830,"name":"amazingcoders-rails","full_name":"junwen29/amazingcoders-rails","owner":{"login":"junwen29","id":7575875,"avatar_url":"https://avatars.githubusercontent.com/u/7575875?v=3","gravatar_id":"","url":"https://api.github.com/users/junwen29","html_url":"https://github.com/junwen29","followers_url":"https://api.github.com/users/junwen29/followers","following_url":"https://api.github.com/users/junwen29/following{/other_user}","gists_url":"https://api.github.com/users/junwen29/gists{/gist_id}","starred_url":"https://api.github.com/users/junwen29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junwen29/subscriptions","organizations_url":"https://api.github.com/users/junwen29/orgs","repos_url":"https://api.github.com/users/junwen29/repos","events_url":"https://api.github.com/users/junwen29/events{/privacy}","received_events_url":"https://api.github.com/users/junwen29/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/junwen29/amazingcoders-rails","description":"","fork":false,"url":"https://api.github.com/repos/junwen29/amazingcoders-rails","forks_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/forks","keys_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/teams","hooks_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/hooks","issue_events_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/events{/number}","events_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/events","assignees_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/assignees{/user}","branches_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/branches{/branch}","tags_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/tags","blobs_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/languages","stargazers_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/stargazers","contributors_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/contributors","subscribers_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/subscribers","subscription_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/subscription","commits_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/contents/{+path}","compare_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/merges","archive_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/downloads","issues_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues{/number}","pulls_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/labels{/name}","releases_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/releases{/id}","created_at":"2015-08-24T12:52:39Z","updated_at":"2015-09-26T09:55:18Z","pushed_at":"2015-11-02T14:54:00Z","git_url":"git://github.com/junwen29/amazingcoders-rails.git","ssh_url":"git@github.com:junwen29/amazingcoders-rails.git","clone_url":"https://github.com/junwen29/amazingcoders-rails.git","svn_url":"https://github.com/junwen29/amazingcoders-rails","homepage":null,"size":15831,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"develop"}},"base":{"label":"junwen29:develop","ref":"develop","sha":"41af0084e3b051b15d39aca10e8e87493a7b73af","user":{"login":"junwen29","id":7575875,"avatar_url":"https://avatars.githubusercontent.com/u/7575875?v=3","gravatar_id":"","url":"https://api.github.com/users/junwen29","html_url":"https://github.com/junwen29","followers_url":"https://api.github.com/users/junwen29/followers","following_url":"https://api.github.com/users/junwen29/following{/other_user}","gists_url":"https://api.github.com/users/junwen29/gists{/gist_id}","starred_url":"https://api.github.com/users/junwen29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junwen29/subscriptions","organizations_url":"https://api.github.com/users/junwen29/orgs","repos_url":"https://api.github.com/users/junwen29/repos","events_url":"https://api.github.com/users/junwen29/events{/privacy}","received_events_url":"https://api.github.com/users/junwen29/received_events","type":"User","site_admin":false},"repo":{"id":41302830,"name":"amazingcoders-rails","full_name":"junwen29/amazingcoders-rails","owner":{"login":"junwen29","id":7575875,"avatar_url":"https://avatars.githubusercontent.com/u/7575875?v=3","gravatar_id":"","url":"https://api.github.com/users/junwen29","html_url":"https://github.com/junwen29","followers_url":"https://api.github.com/users/junwen29/followers","following_url":"https://api.github.com/users/junwen29/following{/other_user}","gists_url":"https://api.github.com/users/junwen29/gists{/gist_id}","starred_url":"https://api.github.com/users/junwen29/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junwen29/subscriptions","organizations_url":"https://api.github.com/users/junwen29/orgs","repos_url":"https://api.github.com/users/junwen29/repos","events_url":"https://api.github.com/users/junwen29/events{/privacy}","received_events_url":"https://api.github.com/users/junwen29/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/junwen29/amazingcoders-rails","description":"","fork":false,"url":"https://api.github.com/repos/junwen29/amazingcoders-rails","forks_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/forks","keys_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/teams","hooks_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/hooks","issue_events_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/events{/number}","events_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/events","assignees_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/assignees{/user}","branches_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/branches{/branch}","tags_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/tags","blobs_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/languages","stargazers_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/stargazers","contributors_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/contributors","subscribers_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/subscribers","subscription_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/subscription","commits_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/contents/{+path}","compare_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/merges","archive_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/downloads","issues_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues{/number}","pulls_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/labels{/name}","releases_url":"https://api.github.com/repos/junwen29/amazingcoders-rails/releases{/id}","created_at":"2015-08-24T12:52:39Z","updated_at":"2015-09-26T09:55:18Z","pushed_at":"2015-11-02T14:54:00Z","git_url":"git://github.com/junwen29/amazingcoders-rails.git","ssh_url":"git@github.com:junwen29/amazingcoders-rails.git","clone_url":"https://github.com/junwen29/amazingcoders-rails.git","svn_url":"https://github.com/junwen29/amazingcoders-rails","homepage":null,"size":15831,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154"},"html":{"href":"https://github.com/junwen29/amazingcoders-rails/pull/154"},"issue":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/154"},"comments":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/issues/154/comments"},"review_comments":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154/comments"},"review_comment":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/pulls/154/commits"},"statuses":{"href":"https://api.github.com/repos/junwen29/amazingcoders-rails/statuses/76c4d3075dd14b2c947536067b968feafd9acd7b"}}}}