{"action":"created","comment":{"url":"https://api.github.com/repos/mattstauffer/suggestive/pulls/comments/47438446","id":47438446,"diff_hunk":"@@ -0,0 +1,73 @@\n+<?php\n+\n+namespace App\\Console\\Commands;\n+\n+use App\\User;\n+use Illuminate\\Console\\Command;\n+use Log;\n+\n+class PollTwitter extends Command\n+{\n+    /**\n+     * The name and signature of the console command.\n+     *\n+     * @var string\n+     */\n+    protected $signature = 'suggestive:poll-twitter';\n+\n+    /**\n+     * The console command description.\n+     *\n+     * @var string\n+     */\n+    protected $description = 'Polls Twitter for any tweets with the configured hashtag.';\n+\n+    /**\n+     * Create a new command instance.\n+     *\n+     * @return void\n+     */\n+    public function __construct()\n+    {\n+        parent::__construct();\n+    }\n+\n+    /**\n+     * Execute the console command.\n+     *\n+     * @return mixed\n+     */\n+    public function handle()\n+    {\n+        $users = User::where('role', 'owner')\n+                     ->whereNotNull('hashtag')\n+                     ->get([ 'id', 'name', 'hashtag', 'last_tweet_id', ]);\n+\n+        if ($users) {\n+            $twitter = app('TwitterClient');\n+\n+            Log::info('Found owners to poll Twitter for', [ 'count' => $users->count(), ]);\n+\n+            $users->each(function ($user) use ($twitter) {\n+                Log::info('Polling Twitter', [ 'owner' => $user->name, 'hashtag' => $user->hashtag, ]);\n+\n+                $response = $twitter->get('search/tweets', [ 'q' => $user->hashtag, 'since_id' => $user->last_tweet_id, ]);","path":"app/Console/Commands/PollTwitter.php","position":54,"original_position":54,"commit_id":"6aa948abd024c53c3f6c800058d10b3c6bc504f6","original_commit_id":"6aa948abd024c53c3f6c800058d10b3c6bc504f6","user":{"login":"mattstauffer","id":151829,"avatar_url":"https://avatars.githubusercontent.com/u/151829?v=3","gravatar_id":"","url":"https://api.github.com/users/mattstauffer","html_url":"https://github.com/mattstauffer","followers_url":"https://api.github.com/users/mattstauffer/followers","following_url":"https://api.github.com/users/mattstauffer/following{/other_user}","gists_url":"https://api.github.com/users/mattstauffer/gists{/gist_id}","starred_url":"https://api.github.com/users/mattstauffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattstauffer/subscriptions","organizations_url":"https://api.github.com/users/mattstauffer/orgs","repos_url":"https://api.github.com/users/mattstauffer/repos","events_url":"https://api.github.com/users/mattstauffer/events{/privacy}","received_events_url":"https://api.github.com/users/mattstauffer/received_events","type":"User","site_admin":false},"body":"Is there no `since_datetime` instead of `since_id`? would speed up the check.. if no matching tweets for two years, we have to check two years this way","created_at":"2015-12-12T23:53:08Z","updated_at":"2015-12-12T23:53:08Z","html_url":"https://github.com/mattstauffer/suggestive/pull/12#discussion_r47438446","pull_request_url":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/mattstauffer/suggestive/pulls/comments/47438446"},"html":{"href":"https://github.com/mattstauffer/suggestive/pull/12#discussion_r47438446"},"pull_request":{"href":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12","id":53475670,"html_url":"https://github.com/mattstauffer/suggestive/pull/12","diff_url":"https://github.com/mattstauffer/suggestive/pull/12.diff","patch_url":"https://github.com/mattstauffer/suggestive/pull/12.patch","issue_url":"https://api.github.com/repos/mattstauffer/suggestive/issues/12","number":12,"state":"open","locked":false,"title":"Poll Twitter for tweets made containing a given hashtag","user":{"login":"deringer","id":558441,"avatar_url":"https://avatars.githubusercontent.com/u/558441?v=3","gravatar_id":"","url":"https://api.github.com/users/deringer","html_url":"https://github.com/deringer","followers_url":"https://api.github.com/users/deringer/followers","following_url":"https://api.github.com/users/deringer/following{/other_user}","gists_url":"https://api.github.com/users/deringer/gists{/gist_id}","starred_url":"https://api.github.com/users/deringer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deringer/subscriptions","organizations_url":"https://api.github.com/users/deringer/orgs","repos_url":"https://api.github.com/users/deringer/repos","events_url":"https://api.github.com/users/deringer/events{/privacy}","received_events_url":"https://api.github.com/users/deringer/received_events","type":"User","site_admin":false},"body":"Addresses #5.\r\n\r\nFor any found tweets, add them as a new unflagged topic against the owner user record, so that they can be reviewed.\r\n\r\nI've done some preliminary work on this and opened a PR so I can get some feedback on the direction I've taken so far. The basic theory is that a user will specify a hashtag that Suggestive looks for periodicially (scheduling the `suggestive:poll-twitter` command), and creates unflagged `Topic` records for the owner to review.\r\n\r\nI assume as well that the `/topics` API endpoint should return only accepted topics (it currently returns everything).\r\n\r\nI haven't yet made any interface to set a hashtag, though that's only because there's no user profile at this stage.\r\n\r\nThis will also use the application Twitter credentials, which is 150 requests every ~15 minutes. This may be ok initially, but it is trivial to make it 150 requests per user - you just need to capture the Twitter token and secret when the user signs up. Of course, that's not much good with a GitHub authenticated user, so you might want to lock it down to just Twitter users.","created_at":"2015-12-12T12:50:47Z","updated_at":"2015-12-12T23:53:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a6d2302bd384b797392766625c749c8a5e04928","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12/commits","review_comments_url":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12/comments","review_comment_url":"https://api.github.com/repos/mattstauffer/suggestive/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mattstauffer/suggestive/issues/12/comments","statuses_url":"https://api.github.com/repos/mattstauffer/suggestive/statuses/6aa948abd024c53c3f6c800058d10b3c6bc504f6","head":{"label":"deringer:#5-poll-twitter-for-suggestions","ref":"#5-poll-twitter-for-suggestions","sha":"6aa948abd024c53c3f6c800058d10b3c6bc504f6","user":{"login":"deringer","id":558441,"avatar_url":"https://avatars.githubusercontent.com/u/558441?v=3","gravatar_id":"","url":"https://api.github.com/users/deringer","html_url":"https://github.com/deringer","followers_url":"https://api.github.com/users/deringer/followers","following_url":"https://api.github.com/users/deringer/following{/other_user}","gists_url":"https://api.github.com/users/deringer/gists{/gist_id}","starred_url":"https://api.github.com/users/deringer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deringer/subscriptions","organizations_url":"https://api.github.com/users/deringer/orgs","repos_url":"https://api.github.com/users/deringer/repos","events_url":"https://api.github.com/users/deringer/events{/privacy}","received_events_url":"https://api.github.com/users/deringer/received_events","type":"User","site_admin":false},"repo":{"id":47849136,"name":"suggestive","full_name":"deringer/suggestive","owner":{"login":"deringer","id":558441,"avatar_url":"https://avatars.githubusercontent.com/u/558441?v=3","gravatar_id":"","url":"https://api.github.com/users/deringer","html_url":"https://github.com/deringer","followers_url":"https://api.github.com/users/deringer/followers","following_url":"https://api.github.com/users/deringer/following{/other_user}","gists_url":"https://api.github.com/users/deringer/gists{/gist_id}","starred_url":"https://api.github.com/users/deringer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deringer/subscriptions","organizations_url":"https://api.github.com/users/deringer/orgs","repos_url":"https://api.github.com/users/deringer/repos","events_url":"https://api.github.com/users/deringer/events{/privacy}","received_events_url":"https://api.github.com/users/deringer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/deringer/suggestive","description":"Suggestive - take suggestions from the fans/followers of your podcast or blog","fork":true,"url":"https://api.github.com/repos/deringer/suggestive","forks_url":"https://api.github.com/repos/deringer/suggestive/forks","keys_url":"https://api.github.com/repos/deringer/suggestive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/deringer/suggestive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/deringer/suggestive/teams","hooks_url":"https://api.github.com/repos/deringer/suggestive/hooks","issue_events_url":"https://api.github.com/repos/deringer/suggestive/issues/events{/number}","events_url":"https://api.github.com/repos/deringer/suggestive/events","assignees_url":"https://api.github.com/repos/deringer/suggestive/assignees{/user}","branches_url":"https://api.github.com/repos/deringer/suggestive/branches{/branch}","tags_url":"https://api.github.com/repos/deringer/suggestive/tags","blobs_url":"https://api.github.com/repos/deringer/suggestive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/deringer/suggestive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/deringer/suggestive/git/refs{/sha}","trees_url":"https://api.github.com/repos/deringer/suggestive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/deringer/suggestive/statuses/{sha}","languages_url":"https://api.github.com/repos/deringer/suggestive/languages","stargazers_url":"https://api.github.com/repos/deringer/suggestive/stargazers","contributors_url":"https://api.github.com/repos/deringer/suggestive/contributors","subscribers_url":"https://api.github.com/repos/deringer/suggestive/subscribers","subscription_url":"https://api.github.com/repos/deringer/suggestive/subscription","commits_url":"https://api.github.com/repos/deringer/suggestive/commits{/sha}","git_commits_url":"https://api.github.com/repos/deringer/suggestive/git/commits{/sha}","comments_url":"https://api.github.com/repos/deringer/suggestive/comments{/number}","issue_comment_url":"https://api.github.com/repos/deringer/suggestive/issues/comments{/number}","contents_url":"https://api.github.com/repos/deringer/suggestive/contents/{+path}","compare_url":"https://api.github.com/repos/deringer/suggestive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/deringer/suggestive/merges","archive_url":"https://api.github.com/repos/deringer/suggestive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/deringer/suggestive/downloads","issues_url":"https://api.github.com/repos/deringer/suggestive/issues{/number}","pulls_url":"https://api.github.com/repos/deringer/suggestive/pulls{/number}","milestones_url":"https://api.github.com/repos/deringer/suggestive/milestones{/number}","notifications_url":"https://api.github.com/repos/deringer/suggestive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/deringer/suggestive/labels{/name}","releases_url":"https://api.github.com/repos/deringer/suggestive/releases{/id}","created_at":"2015-12-11T20:23:06Z","updated_at":"2015-12-11T20:23:07Z","pushed_at":"2015-12-12T23:02:58Z","git_url":"git://github.com/deringer/suggestive.git","ssh_url":"git@github.com:deringer/suggestive.git","clone_url":"https://github.com/deringer/suggestive.git","svn_url":"https://github.com/deringer/suggestive","homepage":"","size":745,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mattstauffer:master","ref":"master","sha":"01450f41d1dbbb6ad4829361bd090fbb8ebf3a98","user":{"login":"mattstauffer","id":151829,"avatar_url":"https://avatars.githubusercontent.com/u/151829?v=3","gravatar_id":"","url":"https://api.github.com/users/mattstauffer","html_url":"https://github.com/mattstauffer","followers_url":"https://api.github.com/users/mattstauffer/followers","following_url":"https://api.github.com/users/mattstauffer/following{/other_user}","gists_url":"https://api.github.com/users/mattstauffer/gists{/gist_id}","starred_url":"https://api.github.com/users/mattstauffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattstauffer/subscriptions","organizations_url":"https://api.github.com/users/mattstauffer/orgs","repos_url":"https://api.github.com/users/mattstauffer/repos","events_url":"https://api.github.com/users/mattstauffer/events{/privacy}","received_events_url":"https://api.github.com/users/mattstauffer/received_events","type":"User","site_admin":false},"repo":{"id":47484560,"name":"suggestive","full_name":"mattstauffer/suggestive","owner":{"login":"mattstauffer","id":151829,"avatar_url":"https://avatars.githubusercontent.com/u/151829?v=3","gravatar_id":"","url":"https://api.github.com/users/mattstauffer","html_url":"https://github.com/mattstauffer","followers_url":"https://api.github.com/users/mattstauffer/followers","following_url":"https://api.github.com/users/mattstauffer/following{/other_user}","gists_url":"https://api.github.com/users/mattstauffer/gists{/gist_id}","starred_url":"https://api.github.com/users/mattstauffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattstauffer/subscriptions","organizations_url":"https://api.github.com/users/mattstauffer/orgs","repos_url":"https://api.github.com/users/mattstauffer/repos","events_url":"https://api.github.com/users/mattstauffer/events{/privacy}","received_events_url":"https://api.github.com/users/mattstauffer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mattstauffer/suggestive","description":"Suggestive - take suggestions from the fans/followers of your podcast or blog","fork":false,"url":"https://api.github.com/repos/mattstauffer/suggestive","forks_url":"https://api.github.com/repos/mattstauffer/suggestive/forks","keys_url":"https://api.github.com/repos/mattstauffer/suggestive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mattstauffer/suggestive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mattstauffer/suggestive/teams","hooks_url":"https://api.github.com/repos/mattstauffer/suggestive/hooks","issue_events_url":"https://api.github.com/repos/mattstauffer/suggestive/issues/events{/number}","events_url":"https://api.github.com/repos/mattstauffer/suggestive/events","assignees_url":"https://api.github.com/repos/mattstauffer/suggestive/assignees{/user}","branches_url":"https://api.github.com/repos/mattstauffer/suggestive/branches{/branch}","tags_url":"https://api.github.com/repos/mattstauffer/suggestive/tags","blobs_url":"https://api.github.com/repos/mattstauffer/suggestive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mattstauffer/suggestive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mattstauffer/suggestive/git/refs{/sha}","trees_url":"https://api.github.com/repos/mattstauffer/suggestive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mattstauffer/suggestive/statuses/{sha}","languages_url":"https://api.github.com/repos/mattstauffer/suggestive/languages","stargazers_url":"https://api.github.com/repos/mattstauffer/suggestive/stargazers","contributors_url":"https://api.github.com/repos/mattstauffer/suggestive/contributors","subscribers_url":"https://api.github.com/repos/mattstauffer/suggestive/subscribers","subscription_url":"https://api.github.com/repos/mattstauffer/suggestive/subscription","commits_url":"https://api.github.com/repos/mattstauffer/suggestive/commits{/sha}","git_commits_url":"https://api.github.com/repos/mattstauffer/suggestive/git/commits{/sha}","comments_url":"https://api.github.com/repos/mattstauffer/suggestive/comments{/number}","issue_comment_url":"https://api.github.com/repos/mattstauffer/suggestive/issues/comments{/number}","contents_url":"https://api.github.com/repos/mattstauffer/suggestive/contents/{+path}","compare_url":"https://api.github.com/repos/mattstauffer/suggestive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mattstauffer/suggestive/merges","archive_url":"https://api.github.com/repos/mattstauffer/suggestive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mattstauffer/suggestive/downloads","issues_url":"https://api.github.com/repos/mattstauffer/suggestive/issues{/number}","pulls_url":"https://api.github.com/repos/mattstauffer/suggestive/pulls{/number}","milestones_url":"https://api.github.com/repos/mattstauffer/suggestive/milestones{/number}","notifications_url":"https://api.github.com/repos/mattstauffer/suggestive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mattstauffer/suggestive/labels{/name}","releases_url":"https://api.github.com/repos/mattstauffer/suggestive/releases{/id}","created_at":"2015-12-06T05:12:04Z","updated_at":"2015-12-11T05:48:34Z","pushed_at":"2015-12-12T23:02:58Z","git_url":"git://github.com/mattstauffer/suggestive.git","ssh_url":"git@github.com:mattstauffer/suggestive.git","clone_url":"https://github.com/mattstauffer/suggestive.git","svn_url":"https://github.com/mattstauffer/suggestive","homepage":"","size":713,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":8,"forks":5,"open_issues":8,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12"},"html":{"href":"https://github.com/mattstauffer/suggestive/pull/12"},"issue":{"href":"https://api.github.com/repos/mattstauffer/suggestive/issues/12"},"comments":{"href":"https://api.github.com/repos/mattstauffer/suggestive/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/mattstauffer/suggestive/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mattstauffer/suggestive/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/mattstauffer/suggestive/statuses/6aa948abd024c53c3f6c800058d10b3c6bc504f6"}}}}