{"action":"created","comment":{"url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/comments/31200254","id":31200254,"diff_hunk":"@@ -90,10 +114,79 @@ public function write(Comment $comment)\n         \n     }\n \n+    public static function get($id)            \n+    {\n+        $db = DB::conn();\n+\n+        $row = $db->row('SELECT * FROM thread WHERE id = ?', array($id));\n+\n+        if(!$row) {\n+            throw new RecordNotFoundException('no record found');\n+        }\n+\n+        return new self($row);                    \n+    }\n+\n     public static function countAll()\n     {\n         $db = DB::conn();\n         return $db->value(\"SELECT COUNT(*) FROM thread\");\n-    }                          \n+    }  \n+\n+\n+    public function getComments()\n+    {\n+        $comments = array();\n+        \n+        $db = DB::conn();\n+        $rows = $db->rows('SELECT * FROM comment WHERE thread_id = ? ORDER BY created ASC', array($this->id));\n+\n+        foreach ($rows as $row) {                        \n+            $comments[] = new Comment($row);\n+        }\n+        return $comments;\n+    }\n+\n+    public static function getTitle($id)\n+    {\n+        $db = DB::conn();\n+        $row = $db->row('SELECT title FROM thread WHERE id = ?', array($id));\n+        return $row;\n+    }\n+\n+    public static function getBodyContents($id)\n+    {\n+        $db = DB::conn();\n+        $row = $db->row('SELECT body FROM thread WHERE id = ?', array($id));\n+        return $row;\n+    }    \n+\n+    public static function getOwnerId($id)\n+    {\n+        $db = DB::conn();\n+        $row = $db->row('SELECT creator_id FROM thread WHERE id = ?', array($id));\n+        return $row['creator_id'];\n+    }\n+\n+\n+    public function isOwnedBy($username)\n+    {\n+        $db = DB::conn();\n+        $userId = User::getUserId($username);\n+        if($userId === $this->creator_id){\n+            return true;\n+        }\n+        else return false;\n+    }\n+\n+    public static function getTopFive()\n+    {\n+        $db = DB::conn();\n+        $rows = $db->rows(\n+            'SELECT thread_id, count(*) as commentCount FROM comment GROUP BY thread_id ORDER BY commentCount DESC LIMIT 5');\n+        return $rows;","path":"app/models/thread.php","position":null,"original_position":176,"commit_id":"1836bea4f0759304c8fd45e3adcdf07dfec3dfff","original_commit_id":"3fd7779f8b4909a5c0a68e5c572cf378a23636a0","user":{"login":"lawrence-agustin","id":11661188,"avatar_url":"https://avatars.githubusercontent.com/u/11661188?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-agustin","html_url":"https://github.com/lawrence-agustin","followers_url":"https://api.github.com/users/lawrence-agustin/followers","following_url":"https://api.github.com/users/lawrence-agustin/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-agustin/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-agustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-agustin/subscriptions","organizations_url":"https://api.github.com/users/lawrence-agustin/orgs","repos_url":"https://api.github.com/users/lawrence-agustin/repos","events_url":"https://api.github.com/users/lawrence-agustin/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-agustin/received_events","type":"User","site_admin":false},"body":"addressed po https://github.com/lawrence-agustin/Interconnect/commit/7d02609c89f33bb478c5b3662c4aa80a272d2d9c","created_at":"2015-05-28T03:05:38Z","updated_at":"2015-05-28T03:05:38Z","html_url":"https://github.com/lawrence-agustin/Interconnect/pull/2#discussion_r31200254","pull_request_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/comments/31200254"},"html":{"href":"https://github.com/lawrence-agustin/Interconnect/pull/2#discussion_r31200254"},"pull_request":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2","id":35914661,"html_url":"https://github.com/lawrence-agustin/Interconnect/pull/2","diff_url":"https://github.com/lawrence-agustin/Interconnect/pull/2.diff","patch_url":"https://github.com/lawrence-agustin/Interconnect/pull/2.patch","issue_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/2","number":2,"state":"open","locked":false,"title":"Dev 1.1","user":{"login":"lawrence-agustin","id":11661188,"avatar_url":"https://avatars.githubusercontent.com/u/11661188?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-agustin","html_url":"https://github.com/lawrence-agustin","followers_url":"https://api.github.com/users/lawrence-agustin/followers","following_url":"https://api.github.com/users/lawrence-agustin/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-agustin/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-agustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-agustin/subscriptions","organizations_url":"https://api.github.com/users/lawrence-agustin/orgs","repos_url":"https://api.github.com/users/lawrence-agustin/repos","events_url":"https://api.github.com/users/lawrence-agustin/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-agustin/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-21T09:22:40Z","updated_at":"2015-05-28T03:05:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ebf1b58632ca00822a5c36932ff1830b9c8cdbef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2/commits","review_comments_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2/comments","review_comment_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/2/comments","statuses_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/statuses/1836bea4f0759304c8fd45e3adcdf07dfec3dfff","head":{"label":"lawrence-agustin:dev_1.1","ref":"dev_1.1","sha":"1836bea4f0759304c8fd45e3adcdf07dfec3dfff","user":{"login":"lawrence-agustin","id":11661188,"avatar_url":"https://avatars.githubusercontent.com/u/11661188?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-agustin","html_url":"https://github.com/lawrence-agustin","followers_url":"https://api.github.com/users/lawrence-agustin/followers","following_url":"https://api.github.com/users/lawrence-agustin/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-agustin/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-agustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-agustin/subscriptions","organizations_url":"https://api.github.com/users/lawrence-agustin/orgs","repos_url":"https://api.github.com/users/lawrence-agustin/repos","events_url":"https://api.github.com/users/lawrence-agustin/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-agustin/received_events","type":"User","site_admin":false},"repo":{"id":34764998,"name":"Interconnect","full_name":"lawrence-agustin/Interconnect","owner":{"login":"lawrence-agustin","id":11661188,"avatar_url":"https://avatars.githubusercontent.com/u/11661188?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-agustin","html_url":"https://github.com/lawrence-agustin","followers_url":"https://api.github.com/users/lawrence-agustin/followers","following_url":"https://api.github.com/users/lawrence-agustin/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-agustin/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-agustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-agustin/subscriptions","organizations_url":"https://api.github.com/users/lawrence-agustin/orgs","repos_url":"https://api.github.com/users/lawrence-agustin/repos","events_url":"https://api.github.com/users/lawrence-agustin/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-agustin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lawrence-agustin/Interconnect","description":"","fork":false,"url":"https://api.github.com/repos/lawrence-agustin/Interconnect","forks_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/forks","keys_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/teams","hooks_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/hooks","issue_events_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/events{/number}","events_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/events","assignees_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/assignees{/user}","branches_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/branches{/branch}","tags_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/tags","blobs_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/refs{/sha}","trees_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/statuses/{sha}","languages_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/languages","stargazers_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/stargazers","contributors_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/contributors","subscribers_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/subscribers","subscription_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/subscription","commits_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/commits{/sha}","git_commits_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/commits{/sha}","comments_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/comments{/number}","issue_comment_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/comments{/number}","contents_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/contents/{+path}","compare_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/merges","archive_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/downloads","issues_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues{/number}","pulls_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls{/number}","milestones_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/milestones{/number}","notifications_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/labels{/name}","releases_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/releases{/id}","created_at":"2015-04-29T01:17:40Z","updated_at":"2015-05-18T01:01:40Z","pushed_at":"2015-05-28T03:04:03Z","git_url":"git://github.com/lawrence-agustin/Interconnect.git","ssh_url":"git@github.com:lawrence-agustin/Interconnect.git","clone_url":"https://github.com/lawrence-agustin/Interconnect.git","svn_url":"https://github.com/lawrence-agustin/Interconnect","homepage":null,"size":536,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"dev_1.0"}},"base":{"label":"lawrence-agustin:master","ref":"master","sha":"d5cd288686999e8bd037734f231b3a53f3bc7401","user":{"login":"lawrence-agustin","id":11661188,"avatar_url":"https://avatars.githubusercontent.com/u/11661188?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-agustin","html_url":"https://github.com/lawrence-agustin","followers_url":"https://api.github.com/users/lawrence-agustin/followers","following_url":"https://api.github.com/users/lawrence-agustin/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-agustin/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-agustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-agustin/subscriptions","organizations_url":"https://api.github.com/users/lawrence-agustin/orgs","repos_url":"https://api.github.com/users/lawrence-agustin/repos","events_url":"https://api.github.com/users/lawrence-agustin/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-agustin/received_events","type":"User","site_admin":false},"repo":{"id":34764998,"name":"Interconnect","full_name":"lawrence-agustin/Interconnect","owner":{"login":"lawrence-agustin","id":11661188,"avatar_url":"https://avatars.githubusercontent.com/u/11661188?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-agustin","html_url":"https://github.com/lawrence-agustin","followers_url":"https://api.github.com/users/lawrence-agustin/followers","following_url":"https://api.github.com/users/lawrence-agustin/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-agustin/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-agustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-agustin/subscriptions","organizations_url":"https://api.github.com/users/lawrence-agustin/orgs","repos_url":"https://api.github.com/users/lawrence-agustin/repos","events_url":"https://api.github.com/users/lawrence-agustin/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-agustin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lawrence-agustin/Interconnect","description":"","fork":false,"url":"https://api.github.com/repos/lawrence-agustin/Interconnect","forks_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/forks","keys_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/teams","hooks_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/hooks","issue_events_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/events{/number}","events_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/events","assignees_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/assignees{/user}","branches_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/branches{/branch}","tags_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/tags","blobs_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/refs{/sha}","trees_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/statuses/{sha}","languages_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/languages","stargazers_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/stargazers","contributors_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/contributors","subscribers_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/subscribers","subscription_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/subscription","commits_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/commits{/sha}","git_commits_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/git/commits{/sha}","comments_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/comments{/number}","issue_comment_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/comments{/number}","contents_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/contents/{+path}","compare_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/merges","archive_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/downloads","issues_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues{/number}","pulls_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls{/number}","milestones_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/milestones{/number}","notifications_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/labels{/name}","releases_url":"https://api.github.com/repos/lawrence-agustin/Interconnect/releases{/id}","created_at":"2015-04-29T01:17:40Z","updated_at":"2015-05-18T01:01:40Z","pushed_at":"2015-05-28T03:04:03Z","git_url":"git://github.com/lawrence-agustin/Interconnect.git","ssh_url":"git@github.com:lawrence-agustin/Interconnect.git","clone_url":"https://github.com/lawrence-agustin/Interconnect.git","svn_url":"https://github.com/lawrence-agustin/Interconnect","homepage":null,"size":536,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"dev_1.0"}},"_links":{"self":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2"},"html":{"href":"https://github.com/lawrence-agustin/Interconnect/pull/2"},"issue":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/2"},"comments":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/lawrence-agustin/Interconnect/statuses/1836bea4f0759304c8fd45e3adcdf07dfec3dfff"}}}}