GitHub PullRequestReviewCommentEvent at 2014-08-29 15:16:31
Repository: oneanddone
Actor: bobsilverberg
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/oneanddone/pulls/comments/16903121","id":16903121,"diff_hunk":"@@ -16,6 +17,85 @@ class Meta:\n         fields = ('text',)\n \n \n+class TaskInvalidationCriterionForm(forms.ModelForm):\n+    def __init__(self, *args, **kwargs):\n+        initial = kwargs.get('initial', {})\n+        initial['relation'] = TaskInvalidationCriterion.EQUAL\n+        kwargs['initial'] = initial\n+        super(TaskInvalidationCriterionForm, self).__init__(*args, **kwargs)\n+\n+    class Meta:\n+        model = TaskInvalidationCriterion\n+        fields = ('field_name', 'relation', 'field_value')\n+        widgets = {\n+            'field_name': forms.TextInput(attrs={'size': 15}),\n+            'field_value': forms.TextInput(attrs={'size': 15})\n+            }\n+\n+\n+TaskInvalidCriteriaFormSet = forms.models.modelformset_factory(\n+                                TaskInvalidationCriterion,\n+                                form=TaskInvalidationCriterionForm)\n+\n+class TaskImportBatchForm(forms.ModelForm):\n+    def save(self, creator, *args, **kwargs):\n+        self.instance.creator = creator\n+        super(TaskImportBatchForm, self).save(*args, **kwargs)\n+        return self.instance\n+\n+    def clean(self):\n+        max_results = 100\n+        max_batch_size = 20\n+        cleaned_data = super(TaskImportBatchForm, self).clean()\n+        query = cleaned_data.get('query','')\n+        if query.count('?') != 1:\n+            raise forms.ValidationError(_('Please provide a full URL as your query.'))\n+        bugcount = request_bugcount(query.split('?')[1])\n+        if not bugcount:\n+            raise forms.ValidationError(_('Your query does not return any results.'))\n+        elif bugcount > max_results:\n+            raise forms.ValidationError(_(' '.join(['Your query returns more than', str(max_results), 'items.'])))\n+\n+        fresh_bugs = self._get_fresh_bugs(query, bugcount, max_batch_size)\n+\n+        if not fresh_bugs:\n+            raise forms.ValidationError(_('The results of this query have all been imported before. To import these results again as different tasks, please use a different query.'))\n+\n+        cleaned_data['_fresh_bugs'] = fresh_bugs\n+\n+        return cleaned_data\n+\n+    @staticmethod\n+    def _get_fresh_bugs(query, max_results, max_batch_size):\n+        ''' Returns at most first `limit` bugs (ordered by bug id) that have\n+            not already been imported via `query`.\n+        '''\n+        existing_bug_ids = set([bug.bugzilla_id for bug in BugzillaBug.objects.filter(tasks__batch__query__exact=query)])\n+\n+        def fetch(query, limit, offset):\n+            new_bugs = request_bugs(query.split('?')[1], limit=limit, offset=offset)\n+            fresh_bug_ids = set([bug['id'] for bug in new_bugs]) - existing_bug_ids\n+            if not fresh_bug_ids:\n+                return []\n+            else:\n+                return [bug for bug in new_bugs if bug['id'] in fresh_bug_ids]\n+\n+        fresh_bugs = []\n+        for offset in range(0, max_results, max_batch_size):\n+            fresh_bugs.extend(fetch(query, max_batch_size, offset))\n+            if len(fresh_bugs) >= max_batch_size:\n+                return fresh_bugs[:20]","path":"oneanddone/tasks/forms.py","position":81,"original_position":81,"commit_id":"5f658533f67a84003a99d6777c5f8c9e7666c092","original_commit_id":"5f658533f67a84003a99d6777c5f8c9e7666c092","user":{"login":"bobsilverberg","id":142755,"avatar_url":"https://avatars.githubusercontent.com/u/142755?v=2","gravatar_id":"95d98aa8f56318b4e22aab08425ee792","url":"https://api.github.com/users/bobsilverberg","html_url":"https://github.com/bobsilverberg","followers_url":"https://api.github.com/users/bobsilverberg/followers","following_url":"https://api.github.com/users/bobsilverberg/following{/other_user}","gists_url":"https://api.github.com/users/bobsilverberg/gists{/gist_id}","starred_url":"https://api.github.com/users/bobsilverberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobsilverberg/subscriptions","organizations_url":"https://api.github.com/users/bobsilverberg/orgs","repos_url":"https://api.github.com/users/bobsilverberg/repos","events_url":"https://api.github.com/users/bobsilverberg/events{/privacy}","received_events_url":"https://api.github.com/users/bobsilverberg/received_events","type":"User","site_admin":false},"body":"I don't think you want to hardcode this as `20`, do you? This should be the same as `max_batch_size`, correct?","created_at":"2014-08-29T15:16:31Z","updated_at":"2014-08-29T15:16:31Z","html_url":"https://github.com/mozilla/oneanddone/pull/170#discussion_r16903121","pull_request_url":"https://api.github.com/repos/mozilla/oneanddone/pulls/170","_links":{"self":{"href":"https://api.github.com/repos/mozilla/oneanddone/pulls/comments/16903121"},"html":{"href":"https://github.com/mozilla/oneanddone/pull/170#discussion_r16903121"},"pull_request":{"href":"https://api.github.com/repos/mozilla/oneanddone/pulls/170"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/oneanddone/pulls/170","id":20078321,"html_url":"https://github.com/mozilla/oneanddone/pull/170","diff_url":"https://github.com/mozilla/oneanddone/pull/170.diff","patch_url":"https://github.com/mozilla/oneanddone/pull/170.patch","issue_url":"https://api.github.com/repos/mozilla/oneanddone/issues/170","number":170,"state":"open","locked":false,"title":"Bug 1030972 - Import tasks from Bugzilla","user":{"login":"mjzffr","id":6024326,"avatar_url":"https://avatars.githubusercontent.com/u/6024326?v=2","gravatar_id":"90174ed63e707c8d6a03edd773f3c24e","url":"https://api.github.com/users/mjzffr","html_url":"https://github.com/mjzffr","followers_url":"https://api.github.com/users/mjzffr/followers","following_url":"https://api.github.com/users/mjzffr/following{/other_user}","gists_url":"https://api.github.com/users/mjzffr/gists{/gist_id}","starred_url":"https://api.github.com/users/mjzffr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjzffr/subscriptions","organizations_url":"https://api.github.com/users/mjzffr/orgs","repos_url":"https://api.github.com/users/mjzffr/repos","events_url":"https://api.github.com/users/mjzffr/events{/privacy}","received_events_url":"https://api.github.com/users/mjzffr/received_events","type":"User","site_admin":false},"body":"@bobsilverberg @Osmose r?","created_at":"2014-08-20T22:20:24Z","updated_at":"2014-08-29T15:16:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"46826db651bdb59ff0de0b20c9555e91402f9efb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/oneanddone/pulls/170/commits","review_comments_url":"https://api.github.com/repos/mozilla/oneanddone/pulls/170/comments","review_comment_url":"https://api.github.com/repos/mozilla/oneanddone/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mozilla/oneanddone/issues/170/comments","statuses_url":"https://api.github.com/repos/mozilla/oneanddone/statuses/5f658533f67a84003a99d6777c5f8c9e7666c092","head":{"label":"mjzffr:bugzillataskimport","ref":"bugzillataskimport","sha":"5f658533f67a84003a99d6777c5f8c9e7666c092","user":{"login":"mjzffr","id":6024326,"avatar_url":"https://avatars.githubusercontent.com/u/6024326?v=2","gravatar_id":"90174ed63e707c8d6a03edd773f3c24e","url":"https://api.github.com/users/mjzffr","html_url":"https://github.com/mjzffr","followers_url":"https://api.github.com/users/mjzffr/followers","following_url":"https://api.github.com/users/mjzffr/following{/other_user}","gists_url":"https://api.github.com/users/mjzffr/gists{/gist_id}","starred_url":"https://api.github.com/users/mjzffr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjzffr/subscriptions","organizations_url":"https://api.github.com/users/mjzffr/orgs","repos_url":"https://api.github.com/users/mjzffr/repos","events_url":"https://api.github.com/users/mjzffr/events{/privacy}","received_events_url":"https://api.github.com/users/mjzffr/received_events","type":"User","site_admin":false},"repo":{"id":18219635,"name":"oneanddone","full_name":"mjzffr/oneanddone","owner":{"login":"mjzffr","id":6024326,"avatar_url":"https://avatars.githubusercontent.com/u/6024326?v=2","gravatar_id":"90174ed63e707c8d6a03edd773f3c24e","url":"https://api.github.com/users/mjzffr","html_url":"https://github.com/mjzffr","followers_url":"https://api.github.com/users/mjzffr/followers","following_url":"https://api.github.com/users/mjzffr/following{/other_user}","gists_url":"https://api.github.com/users/mjzffr/gists{/gist_id}","starred_url":"https://api.github.com/users/mjzffr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjzffr/subscriptions","organizations_url":"https://api.github.com/users/mjzffr/orgs","repos_url":"https://api.github.com/users/mjzffr/repos","events_url":"https://api.github.com/users/mjzffr/events{/privacy}","received_events_url":"https://api.github.com/users/mjzffr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mjzffr/oneanddone","description":"The \"One and Done\" initiative, previously known as \"QA Taskboard\", is a workflow where Mozilla community contributors can pick tasks and work on them - one at a time, one day at a time - and feel good about doing them.","fork":true,"url":"https://api.github.com/repos/mjzffr/oneanddone","forks_url":"https://api.github.com/repos/mjzffr/oneanddone/forks","keys_url":"https://api.github.com/repos/mjzffr/oneanddone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mjzffr/oneanddone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mjzffr/oneanddone/teams","hooks_url":"https://api.github.com/repos/mjzffr/oneanddone/hooks","issue_events_url":"https://api.github.com/repos/mjzffr/oneanddone/issues/events{/number}","events_url":"https://api.github.com/repos/mjzffr/oneanddone/events","assignees_url":"https://api.github.com/repos/mjzffr/oneanddone/assignees{/user}","branches_url":"https://api.github.com/repos/mjzffr/oneanddone/branches{/branch}","tags_url":"https://api.github.com/repos/mjzffr/oneanddone/tags","blobs_url":"https://api.github.com/repos/mjzffr/oneanddone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mjzffr/oneanddone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mjzffr/oneanddone/git/refs{/sha}","trees_url":"https://api.github.com/repos/mjzffr/oneanddone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mjzffr/oneanddone/statuses/{sha}","languages_url":"https://api.github.com/repos/mjzffr/oneanddone/languages","stargazers_url":"https://api.github.com/repos/mjzffr/oneanddone/stargazers","contributors_url":"https://api.github.com/repos/mjzffr/oneanddone/contributors","subscribers_url":"https://api.github.com/repos/mjzffr/oneanddone/subscribers","subscription_url":"https://api.github.com/repos/mjzffr/oneanddone/subscription","commits_url":"https://api.github.com/repos/mjzffr/oneanddone/commits{/sha}","git_commits_url":"https://api.github.com/repos/mjzffr/oneanddone/git/commits{/sha}","comments_url":"https://api.github.com/repos/mjzffr/oneanddone/comments{/number}","issue_comment_url":"https://api.github.com/repos/mjzffr/oneanddone/issues/comments/{number}","contents_url":"https://api.github.com/repos/mjzffr/oneanddone/contents/{+path}","compare_url":"https://api.github.com/repos/mjzffr/oneanddone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mjzffr/oneanddone/merges","archive_url":"https://api.github.com/repos/mjzffr/oneanddone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mjzffr/oneanddone/downloads","issues_url":"https://api.github.com/repos/mjzffr/oneanddone/issues{/number}","pulls_url":"https://api.github.com/repos/mjzffr/oneanddone/pulls{/number}","milestones_url":"https://api.github.com/repos/mjzffr/oneanddone/milestones{/number}","notifications_url":"https://api.github.com/repos/mjzffr/oneanddone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mjzffr/oneanddone/labels{/name}","releases_url":"https://api.github.com/repos/mjzffr/oneanddone/releases{/id}","created_at":"2014-03-28T16:57:58Z","updated_at":"2014-06-30T15:50:26Z","pushed_at":"2014-08-20T22:17:45Z","git_url":"git://github.com/mjzffr/oneanddone.git","ssh_url":"git@github.com:mjzffr/oneanddone.git","clone_url":"https://github.com/mjzffr/oneanddone.git","svn_url":"https://github.com/mjzffr/oneanddone","homepage":null,"size":6540,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"2627b2042f2d803167e77baa018dbe5e38d8cfdf","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=2","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":6637799,"name":"oneanddone","full_name":"mozilla/oneanddone","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=2","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/oneanddone","description":"The \"One and Done\" initiative, previously known as \"QA Taskboard\", is a workflow where Mozilla community contributors can pick tasks and work on them - one at a time, one day at a time - and feel good about doing them.","fork":false,"url":"https://api.github.com/repos/mozilla/oneanddone","forks_url":"https://api.github.com/repos/mozilla/oneanddone/forks","keys_url":"https://api.github.com/repos/mozilla/oneanddone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/oneanddone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/oneanddone/teams","hooks_url":"https://api.github.com/repos/mozilla/oneanddone/hooks","issue_events_url":"https://api.github.com/repos/mozilla/oneanddone/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/oneanddone/events","assignees_url":"https://api.github.com/repos/mozilla/oneanddone/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/oneanddone/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/oneanddone/tags","blobs_url":"https://api.github.com/repos/mozilla/oneanddone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/oneanddone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/oneanddone/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/oneanddone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/oneanddone/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/oneanddone/languages","stargazers_url":"https://api.github.com/repos/mozilla/oneanddone/stargazers","contributors_url":"https://api.github.com/repos/mozilla/oneanddone/contributors","subscribers_url":"https://api.github.com/repos/mozilla/oneanddone/subscribers","subscription_url":"https://api.github.com/repos/mozilla/oneanddone/subscription","commits_url":"https://api.github.com/repos/mozilla/oneanddone/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/oneanddone/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/oneanddone/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/oneanddone/issues/comments/{number}","contents_url":"https://api.github.com/repos/mozilla/oneanddone/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/oneanddone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/oneanddone/merges","archive_url":"https://api.github.com/repos/mozilla/oneanddone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/oneanddone/downloads","issues_url":"https://api.github.com/repos/mozilla/oneanddone/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/oneanddone/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/oneanddone/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/oneanddone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/oneanddone/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/oneanddone/releases{/id}","created_at":"2012-11-11T11:33:56Z","updated_at":"2014-08-15T20:44:21Z","pushed_at":"2014-08-25T19:19:42Z","git_url":"git://github.com/mozilla/oneanddone.git","ssh_url":"git@github.com:mozilla/oneanddone.git","clone_url":"https://github.com/mozilla/oneanddone.git","svn_url":"https://github.com/mozilla/oneanddone","homepage":null,"size":8054,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":22,"mirror_url":null,"open_issues_count":5,"forks":22,"open_issues":5,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/oneanddone/pulls/170"},"html":{"href":"https://github.com/mozilla/oneanddone/pull/170"},"issue":{"href":"https://api.github.com/repos/mozilla/oneanddone/issues/170"},"comments":{"href":"https://api.github.com/repos/mozilla/oneanddone/issues/170/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/oneanddone/pulls/170/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/oneanddone/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mozilla/oneanddone/pulls/170/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/oneanddone/statuses/5f658533f67a84003a99d6777c5f8c9e7666c092"}}}}