{"action":"created","comment":{"url":"https://api.github.com/repos/joindin/joindin-api/pulls/comments/38140557","id":38140557,"diff_hunk":"@@ -0,0 +1,162 @@\n+<?php\n+\n+class TalkSpeakerMapper extends ApiMapper\n+{\n+    public function getDefaultFields() {\n+        $fields = array(\n+            \"username\" => \"speaker_name\",\n+            \"full_name\" => \"full_name\",\n+            \"twitter_username\" => \"twitter_username\"\n+        );\n+        return $fields;\n+    }\n+\n+    public function getVerboseFields() {\n+        $fields = array(\n+            \"username\" => \"speaker_name\",\n+            \"full_name\" => \"full_name\",\n+            \"twitter_username\" => \"twitter_username\"\n+        );\n+        return $fields;\n+    }\n+    /**\n+     * Generate the API-Array\n+     *\n+     * @param array   $results\n+     * @param boolean $verbose\n+     *\n+     * @return array\n+     */\n+    public function transformResults($results, $verbose)\n+    {\n+        $total = $results['total'];\n+        unset($results['total']);\n+        $list = parent::transformResults($results, $verbose);\n+\n+        $base = $this->_request->base;\n+        $version = $this->_request->version;\n+        if(is_array($list) && count($list)) {\n+            foreach($results as $key => $row) {\n+                // add speakers\n+                $list[$key]['uri'] = $base . '/' . $version . '/speakers/' . $row['speaker_id'] ;\n+                $list[$key]['verbose_uri'] = $base . '/' . $version . '/speakers/' . $row['speaker_id'] . '?verbose=yes';\n+                $list[$key]['talk_uri'] = $base . '/' . $version . '/talks/' . $row['talk_id'];\n+                if (isset($row['user_id'])) {\n+                    $list[$key]['user_uri'] = $base . '/' . $version . '/users/' . $row['user_id'];\n+                }\n+            }\n+        }\n+\n+        $retval = array();\n+        $retval['speakers'] = $list;\n+        $retval['meta'] = $this->getPaginationLinks($list, $total);\n+\n+        return $retval;\n+\n+    }\n+\n+    /**\n+     * Get a list of ALL speakers of a talk (confirmed AND unconfirmed)\n+     *\n+     * @param int  $talk_id\n+     * @param int  $resultsperpage\n+     * @param int  $start\n+     * @param bool $verbose\n+     *\n+     * @return array|false\n+     */\n+    public function getSpeakersByTalkId($talk_id, $resultsperpage, $start, $verbose = false)\n+    {\n+        $results = $this->getUsers(\n+            $resultsperpage,\n+            $start,\n+            'speaker.talk_id= :talk_id',\n+            null,\n+            array('talk_id' => $talk_id)\n+        );\n+\n+        if ($results) {\n+            $retval = $this->transformResults($results, $verbose);\n+            return $retval;\n+        }\n+        return false;\n+    }\n+\n+    /**\n+     * Get users for a given talk\n+     *\n+     * @param int    $resultsperpage\n+     * @param int    $start\n+     * @param string $where\n+     * @param string $order\n+     *\n+     * @return array|bool\n+     */\n+    protected function getUsers($resultsperpage, $start, $where = null, $order = null, $parameters = array())\n+    {\n+        $sql = 'select speaker.ID as speaker_id, speaker.speaker_name, speaker.talk_id, user.ID as user_id, user.email, '\n+               . 'user.full_name, user.twitter_username '\n+               . 'from talk_speaker as speaker '\n+               . 'left join user on (speaker.speaker_id = user.ID) '\n+               . 'where speaker.speaker_name <> \"\" ';\n+\n+        // where\n+        if ($where) {\n+            $sql .= ' and ' . $where;\n+        }\n+\n+        // group by because of adding the user_attend join\n+        $sql .= ' group by speaker.ID ';\n+\n+        // order by\n+        if ($order) {\n+            $sql .= ' order by ' . $order;\n+        }\n+\n+        error_log($sql);","path":"src/models/TalkSpeakerMapper.php","position":116,"original_position":116,"commit_id":"2d8b081265184c076754dec29d8375c0a28d75de","original_commit_id":"2d8b081265184c076754dec29d8375c0a28d75de","user":{"login":"chrishoult","id":738776,"avatar_url":"https://avatars.githubusercontent.com/u/738776?v=3","gravatar_id":"","url":"https://api.github.com/users/chrishoult","html_url":"https://github.com/chrishoult","followers_url":"https://api.github.com/users/chrishoult/followers","following_url":"https://api.github.com/users/chrishoult/following{/other_user}","gists_url":"https://api.github.com/users/chrishoult/gists{/gist_id}","starred_url":"https://api.github.com/users/chrishoult/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrishoult/subscriptions","organizations_url":"https://api.github.com/users/chrishoult/orgs","repos_url":"https://api.github.com/users/chrishoult/repos","events_url":"https://api.github.com/users/chrishoult/events{/privacy}","received_events_url":"https://api.github.com/users/chrishoult/received_events","type":"User","site_admin":false},"body":"Is this left in intentionally? If so, you're missing more SQL below :)","created_at":"2015-08-27T20:12:44Z","updated_at":"2015-08-27T20:12:44Z","html_url":"https://github.com/joindin/joindin-api/pull/199#discussion_r38140557","pull_request_url":"https://api.github.com/repos/joindin/joindin-api/pulls/199","_links":{"self":{"href":"https://api.github.com/repos/joindin/joindin-api/pulls/comments/38140557"},"html":{"href":"https://github.com/joindin/joindin-api/pull/199#discussion_r38140557"},"pull_request":{"href":"https://api.github.com/repos/joindin/joindin-api/pulls/199"}}},"pull_request":{"url":"https://api.github.com/repos/joindin/joindin-api/pulls/199","id":43119231,"html_url":"https://github.com/joindin/joindin-api/pull/199","diff_url":"https://github.com/joindin/joindin-api/pull/199.diff","patch_url":"https://github.com/joindin/joindin-api/pull/199.patch","issue_url":"https://api.github.com/repos/joindin/joindin-api/issues/199","number":199,"state":"open","locked":false,"title":"Edit talks v2: fetch speakers","user":{"login":"heiglandreas","id":91998,"avatar_url":"https://avatars.githubusercontent.com/u/91998?v=3","gravatar_id":"","url":"https://api.github.com/users/heiglandreas","html_url":"https://github.com/heiglandreas","followers_url":"https://api.github.com/users/heiglandreas/followers","following_url":"https://api.github.com/users/heiglandreas/following{/other_user}","gists_url":"https://api.github.com/users/heiglandreas/gists{/gist_id}","starred_url":"https://api.github.com/users/heiglandreas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heiglandreas/subscriptions","organizations_url":"https://api.github.com/users/heiglandreas/orgs","repos_url":"https://api.github.com/users/heiglandreas/repos","events_url":"https://api.github.com/users/heiglandreas/events{/privacy}","received_events_url":"https://api.github.com/users/heiglandreas/received_events","type":"User","site_admin":false},"body":"This PR allows to fetch already available speakers for a talk. It introduces 2 API-Endpoints:\r\n\r\n* /v2.1/talks/[talk-id]/speakers will give a list of speakers for the talk [talk-id] with references to the user-url if the talk has been claimed\r\n* /v2.1/speakers/[speaker-id] will give a list with one entry for the speaker [speaker-id].\r\n\r\nBoth results look like the following JSON where the list for the **/v2.1/talks/[talk-id]/speakers** can contain multiple entries and the list for the **/v2.1/speakers/[speaker-id]** will only contain 1 entry (the entry for the requested speaker-entry).\r\n\r\nDepending on whether the user has claimed the talk the ```full_name``` and ```twitter_username``` entries will contain a value or not and if the talk is claimed the entry ```user_uri``` is available or not.","created_at":"2015-08-23T10:44:33Z","updated_at":"2015-08-27T20:12:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e3c9bad78fa7e64d4ef0554182e6d11bd19e40f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/joindin/joindin-api/pulls/199/commits","review_comments_url":"https://api.github.com/repos/joindin/joindin-api/pulls/199/comments","review_comment_url":"https://api.github.com/repos/joindin/joindin-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/joindin/joindin-api/issues/199/comments","statuses_url":"https://api.github.com/repos/joindin/joindin-api/statuses/2d8b081265184c076754dec29d8375c0a28d75de","head":{"label":"heiglandreas:feature/editTalksv2_fetchSpeakers","ref":"feature/editTalksv2_fetchSpeakers","sha":"2d8b081265184c076754dec29d8375c0a28d75de","user":{"login":"heiglandreas","id":91998,"avatar_url":"https://avatars.githubusercontent.com/u/91998?v=3","gravatar_id":"","url":"https://api.github.com/users/heiglandreas","html_url":"https://github.com/heiglandreas","followers_url":"https://api.github.com/users/heiglandreas/followers","following_url":"https://api.github.com/users/heiglandreas/following{/other_user}","gists_url":"https://api.github.com/users/heiglandreas/gists{/gist_id}","starred_url":"https://api.github.com/users/heiglandreas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heiglandreas/subscriptions","organizations_url":"https://api.github.com/users/heiglandreas/orgs","repos_url":"https://api.github.com/users/heiglandreas/repos","events_url":"https://api.github.com/users/heiglandreas/events{/privacy}","received_events_url":"https://api.github.com/users/heiglandreas/received_events","type":"User","site_admin":false},"repo":{"id":19541168,"name":"joindin-api","full_name":"heiglandreas/joindin-api","owner":{"login":"heiglandreas","id":91998,"avatar_url":"https://avatars.githubusercontent.com/u/91998?v=3","gravatar_id":"","url":"https://api.github.com/users/heiglandreas","html_url":"https://github.com/heiglandreas","followers_url":"https://api.github.com/users/heiglandreas/followers","following_url":"https://api.github.com/users/heiglandreas/following{/other_user}","gists_url":"https://api.github.com/users/heiglandreas/gists{/gist_id}","starred_url":"https://api.github.com/users/heiglandreas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heiglandreas/subscriptions","organizations_url":"https://api.github.com/users/heiglandreas/orgs","repos_url":"https://api.github.com/users/heiglandreas/repos","events_url":"https://api.github.com/users/heiglandreas/events{/privacy}","received_events_url":"https://api.github.com/users/heiglandreas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/heiglandreas/joindin-api","description":"API for the joind.in website, apps, and other animals","fork":true,"url":"https://api.github.com/repos/heiglandreas/joindin-api","forks_url":"https://api.github.com/repos/heiglandreas/joindin-api/forks","keys_url":"https://api.github.com/repos/heiglandreas/joindin-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heiglandreas/joindin-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heiglandreas/joindin-api/teams","hooks_url":"https://api.github.com/repos/heiglandreas/joindin-api/hooks","issue_events_url":"https://api.github.com/repos/heiglandreas/joindin-api/issues/events{/number}","events_url":"https://api.github.com/repos/heiglandreas/joindin-api/events","assignees_url":"https://api.github.com/repos/heiglandreas/joindin-api/assignees{/user}","branches_url":"https://api.github.com/repos/heiglandreas/joindin-api/branches{/branch}","tags_url":"https://api.github.com/repos/heiglandreas/joindin-api/tags","blobs_url":"https://api.github.com/repos/heiglandreas/joindin-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heiglandreas/joindin-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heiglandreas/joindin-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/heiglandreas/joindin-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heiglandreas/joindin-api/statuses/{sha}","languages_url":"https://api.github.com/repos/heiglandreas/joindin-api/languages","stargazers_url":"https://api.github.com/repos/heiglandreas/joindin-api/stargazers","contributors_url":"https://api.github.com/repos/heiglandreas/joindin-api/contributors","subscribers_url":"https://api.github.com/repos/heiglandreas/joindin-api/subscribers","subscription_url":"https://api.github.com/repos/heiglandreas/joindin-api/subscription","commits_url":"https://api.github.com/repos/heiglandreas/joindin-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/heiglandreas/joindin-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/heiglandreas/joindin-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/heiglandreas/joindin-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/heiglandreas/joindin-api/contents/{+path}","compare_url":"https://api.github.com/repos/heiglandreas/joindin-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heiglandreas/joindin-api/merges","archive_url":"https://api.github.com/repos/heiglandreas/joindin-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heiglandreas/joindin-api/downloads","issues_url":"https://api.github.com/repos/heiglandreas/joindin-api/issues{/number}","pulls_url":"https://api.github.com/repos/heiglandreas/joindin-api/pulls{/number}","milestones_url":"https://api.github.com/repos/heiglandreas/joindin-api/milestones{/number}","notifications_url":"https://api.github.com/repos/heiglandreas/joindin-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heiglandreas/joindin-api/labels{/name}","releases_url":"https://api.github.com/repos/heiglandreas/joindin-api/releases{/id}","created_at":"2014-05-07T16:07:40Z","updated_at":"2014-06-24T16:40:51Z","pushed_at":"2015-08-25T13:56:33Z","git_url":"git://github.com/heiglandreas/joindin-api.git","ssh_url":"git@github.com:heiglandreas/joindin-api.git","clone_url":"https://github.com/heiglandreas/joindin-api.git","svn_url":"https://github.com/heiglandreas/joindin-api","homepage":null,"size":3780,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"joindin:master","ref":"master","sha":"383fae61ec6a1bb3409824076b022b2efbf9874e","user":{"login":"joindin","id":317803,"avatar_url":"https://avatars.githubusercontent.com/u/317803?v=3","gravatar_id":"","url":"https://api.github.com/users/joindin","html_url":"https://github.com/joindin","followers_url":"https://api.github.com/users/joindin/followers","following_url":"https://api.github.com/users/joindin/following{/other_user}","gists_url":"https://api.github.com/users/joindin/gists{/gist_id}","starred_url":"https://api.github.com/users/joindin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joindin/subscriptions","organizations_url":"https://api.github.com/users/joindin/orgs","repos_url":"https://api.github.com/users/joindin/repos","events_url":"https://api.github.com/users/joindin/events{/privacy}","received_events_url":"https://api.github.com/users/joindin/received_events","type":"Organization","site_admin":false},"repo":{"id":9841298,"name":"joindin-api","full_name":"joindin/joindin-api","owner":{"login":"joindin","id":317803,"avatar_url":"https://avatars.githubusercontent.com/u/317803?v=3","gravatar_id":"","url":"https://api.github.com/users/joindin","html_url":"https://github.com/joindin","followers_url":"https://api.github.com/users/joindin/followers","following_url":"https://api.github.com/users/joindin/following{/other_user}","gists_url":"https://api.github.com/users/joindin/gists{/gist_id}","starred_url":"https://api.github.com/users/joindin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joindin/subscriptions","organizations_url":"https://api.github.com/users/joindin/orgs","repos_url":"https://api.github.com/users/joindin/repos","events_url":"https://api.github.com/users/joindin/events{/privacy}","received_events_url":"https://api.github.com/users/joindin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/joindin/joindin-api","description":"API for the joind.in website, apps, and other animals","fork":false,"url":"https://api.github.com/repos/joindin/joindin-api","forks_url":"https://api.github.com/repos/joindin/joindin-api/forks","keys_url":"https://api.github.com/repos/joindin/joindin-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joindin/joindin-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joindin/joindin-api/teams","hooks_url":"https://api.github.com/repos/joindin/joindin-api/hooks","issue_events_url":"https://api.github.com/repos/joindin/joindin-api/issues/events{/number}","events_url":"https://api.github.com/repos/joindin/joindin-api/events","assignees_url":"https://api.github.com/repos/joindin/joindin-api/assignees{/user}","branches_url":"https://api.github.com/repos/joindin/joindin-api/branches{/branch}","tags_url":"https://api.github.com/repos/joindin/joindin-api/tags","blobs_url":"https://api.github.com/repos/joindin/joindin-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joindin/joindin-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joindin/joindin-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/joindin/joindin-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joindin/joindin-api/statuses/{sha}","languages_url":"https://api.github.com/repos/joindin/joindin-api/languages","stargazers_url":"https://api.github.com/repos/joindin/joindin-api/stargazers","contributors_url":"https://api.github.com/repos/joindin/joindin-api/contributors","subscribers_url":"https://api.github.com/repos/joindin/joindin-api/subscribers","subscription_url":"https://api.github.com/repos/joindin/joindin-api/subscription","commits_url":"https://api.github.com/repos/joindin/joindin-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/joindin/joindin-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/joindin/joindin-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/joindin/joindin-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/joindin/joindin-api/contents/{+path}","compare_url":"https://api.github.com/repos/joindin/joindin-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joindin/joindin-api/merges","archive_url":"https://api.github.com/repos/joindin/joindin-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joindin/joindin-api/downloads","issues_url":"https://api.github.com/repos/joindin/joindin-api/issues{/number}","pulls_url":"https://api.github.com/repos/joindin/joindin-api/pulls{/number}","milestones_url":"https://api.github.com/repos/joindin/joindin-api/milestones{/number}","notifications_url":"https://api.github.com/repos/joindin/joindin-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joindin/joindin-api/labels{/name}","releases_url":"https://api.github.com/repos/joindin/joindin-api/releases{/id}","created_at":"2013-05-03T17:44:24Z","updated_at":"2015-08-02T23:22:45Z","pushed_at":"2015-08-25T14:01:56Z","git_url":"git://github.com/joindin/joindin-api.git","ssh_url":"git@github.com:joindin/joindin-api.git","clone_url":"https://github.com/joindin/joindin-api.git","svn_url":"https://github.com/joindin/joindin-api","homepage":null,"size":5354,"stargazers_count":15,"watchers_count":15,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":101,"mirror_url":null,"open_issues_count":4,"forks":101,"open_issues":4,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/joindin/joindin-api/pulls/199"},"html":{"href":"https://github.com/joindin/joindin-api/pull/199"},"issue":{"href":"https://api.github.com/repos/joindin/joindin-api/issues/199"},"comments":{"href":"https://api.github.com/repos/joindin/joindin-api/issues/199/comments"},"review_comments":{"href":"https://api.github.com/repos/joindin/joindin-api/pulls/199/comments"},"review_comment":{"href":"https://api.github.com/repos/joindin/joindin-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/joindin/joindin-api/pulls/199/commits"},"statuses":{"href":"https://api.github.com/repos/joindin/joindin-api/statuses/2d8b081265184c076754dec29d8375c0a28d75de"}}}}