{"action":"created","comment":{"url":"https://api.github.com/repos/pulp/pulp/pulls/comments/46253741","id":46253741,"diff_hunk":"@@ -186,20 +194,39 @@ def has_all_units_downloaded(repository):\n     :return: True if completely downloaded\n     :rtype: bool\n     \"\"\"\n-    types = {}\n-    q_set = model.RepositoryContentUnit.objects(repo_id=repository.repo_id)\n-    for association in q_set.only('unit_id', 'unit_type_id'):\n-        unit_ids = types.setdefault(association.unit_type_id, [])\n-        unit_ids.append(association.unit_id)\n-    for type_id, unit_ids in types.items():\n-        _model = plugin_api.get_unit_model_by_id(type_id)\n-        for page in paginate(unit_ids):\n-            q_set = _model.objects(id__in=page, downloaded=False)\n-            if q_set.count():\n-                return False\n+    for qs in _get_mongoengine_repo_querysets(str(repository.repo_id)):","path":"server/pulp/server/controllers/repository.py","position":56,"original_position":56,"commit_id":"716cf988c4ec09e4d79f6a2ac0eed77f4c624fb0","original_commit_id":"716cf988c4ec09e4d79f6a2ac0eed77f4c624fb0","user":{"login":"seandst","id":441252,"avatar_url":"https://avatars.githubusercontent.com/u/441252?v=3","gravatar_id":"","url":"https://api.github.com/users/seandst","html_url":"https://github.com/seandst","followers_url":"https://api.github.com/users/seandst/followers","following_url":"https://api.github.com/users/seandst/following{/other_user}","gists_url":"https://api.github.com/users/seandst/gists{/gist_id}","starred_url":"https://api.github.com/users/seandst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seandst/subscriptions","organizations_url":"https://api.github.com/users/seandst/orgs","repos_url":"https://api.github.com/users/seandst/repos","events_url":"https://api.github.com/users/seandst/events{/privacy}","received_events_url":"https://api.github.com/users/seandst/received_events","type":"User","site_admin":false},"body":"I think the logic is flipped, so it would need to be `return not any(...)`, which I think highlights how using `any` here is not necessarily better, at least in terms of readability.\r\n\r\nI [think](https://github.com/MongoEngine/mongoengine/blob/master/mongoengine/queryset/base.py#L170) that MongoEngine QuerySets will do what you want when evaluated for truthiness here, so assuming that qs is an instance of a MongoEngine QuerySet (which I am), a somewhat more readable option might be `return not any(_get_mongoengine_repo_querysets(str(repository.repo_id))`","created_at":"2015-12-01T09:05:22Z","updated_at":"2015-12-01T09:05:22Z","html_url":"https://github.com/pulp/pulp/pull/2186#discussion_r46253741","pull_request_url":"https://api.github.com/repos/pulp/pulp/pulls/2186","_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp/pulls/comments/46253741"},"html":{"href":"https://github.com/pulp/pulp/pull/2186#discussion_r46253741"},"pull_request":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2186"}}},"pull_request":{"url":"https://api.github.com/repos/pulp/pulp/pulls/2186","id":51559923,"html_url":"https://github.com/pulp/pulp/pull/2186","diff_url":"https://github.com/pulp/pulp/pull/2186.diff","patch_url":"https://github.com/pulp/pulp/pull/2186.patch","issue_url":"https://api.github.com/repos/pulp/pulp/issues/2186","number":2186,"state":"open","locked":false,"title":"Add total/downloaded units to repository view.","user":{"login":"jeremycline","id":1977525,"avatar_url":"https://avatars.githubusercontent.com/u/1977525?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremycline","html_url":"https://github.com/jeremycline","followers_url":"https://api.github.com/users/jeremycline/followers","following_url":"https://api.github.com/users/jeremycline/following{/other_user}","gists_url":"https://api.github.com/users/jeremycline/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremycline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremycline/subscriptions","organizations_url":"https://api.github.com/users/jeremycline/orgs","repos_url":"https://api.github.com/users/jeremycline/repos","events_url":"https://api.github.com/users/jeremycline/events{/privacy}","received_events_url":"https://api.github.com/users/jeremycline/received_events","type":"User","site_admin":false},"body":"This adds the following fields to the repository object returned from\r\nthe API ``v2/repositories/<repo-id>/?details=true``:\r\n``total_content_units`` and ``total_units_downloaded``.\r\n\r\ncloses #1354","created_at":"2015-11-23T18:20:05Z","updated_at":"2015-12-01T09:05:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"92cc7d6322baa8eb61063fef03146f5e35aa823f","assignee":{"login":"jeremycline","id":1977525,"avatar_url":"https://avatars.githubusercontent.com/u/1977525?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremycline","html_url":"https://github.com/jeremycline","followers_url":"https://api.github.com/users/jeremycline/followers","following_url":"https://api.github.com/users/jeremycline/following{/other_user}","gists_url":"https://api.github.com/users/jeremycline/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremycline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremycline/subscriptions","organizations_url":"https://api.github.com/users/jeremycline/orgs","repos_url":"https://api.github.com/users/jeremycline/repos","events_url":"https://api.github.com/users/jeremycline/events{/privacy}","received_events_url":"https://api.github.com/users/jeremycline/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/pulp/pulp/pulls/2186/commits","review_comments_url":"https://api.github.com/repos/pulp/pulp/pulls/2186/comments","review_comment_url":"https://api.github.com/repos/pulp/pulp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pulp/pulp/issues/2186/comments","statuses_url":"https://api.github.com/repos/pulp/pulp/statuses/716cf988c4ec09e4d79f6a2ac0eed77f4c624fb0","head":{"label":"jeremycline:story-1354-downloaded-count","ref":"story-1354-downloaded-count","sha":"716cf988c4ec09e4d79f6a2ac0eed77f4c624fb0","user":{"login":"jeremycline","id":1977525,"avatar_url":"https://avatars.githubusercontent.com/u/1977525?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremycline","html_url":"https://github.com/jeremycline","followers_url":"https://api.github.com/users/jeremycline/followers","following_url":"https://api.github.com/users/jeremycline/following{/other_user}","gists_url":"https://api.github.com/users/jeremycline/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremycline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremycline/subscriptions","organizations_url":"https://api.github.com/users/jeremycline/orgs","repos_url":"https://api.github.com/users/jeremycline/repos","events_url":"https://api.github.com/users/jeremycline/events{/privacy}","received_events_url":"https://api.github.com/users/jeremycline/received_events","type":"User","site_admin":false},"repo":{"id":24958984,"name":"pulp","full_name":"jeremycline/pulp","owner":{"login":"jeremycline","id":1977525,"avatar_url":"https://avatars.githubusercontent.com/u/1977525?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremycline","html_url":"https://github.com/jeremycline","followers_url":"https://api.github.com/users/jeremycline/followers","following_url":"https://api.github.com/users/jeremycline/following{/other_user}","gists_url":"https://api.github.com/users/jeremycline/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremycline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremycline/subscriptions","organizations_url":"https://api.github.com/users/jeremycline/orgs","repos_url":"https://api.github.com/users/jeremycline/repos","events_url":"https://api.github.com/users/jeremycline/events{/privacy}","received_events_url":"https://api.github.com/users/jeremycline/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremycline/pulp","description":"Repository for Pulp platform code, including the server and base admin and consumer clients","fork":true,"url":"https://api.github.com/repos/jeremycline/pulp","forks_url":"https://api.github.com/repos/jeremycline/pulp/forks","keys_url":"https://api.github.com/repos/jeremycline/pulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremycline/pulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremycline/pulp/teams","hooks_url":"https://api.github.com/repos/jeremycline/pulp/hooks","issue_events_url":"https://api.github.com/repos/jeremycline/pulp/issues/events{/number}","events_url":"https://api.github.com/repos/jeremycline/pulp/events","assignees_url":"https://api.github.com/repos/jeremycline/pulp/assignees{/user}","branches_url":"https://api.github.com/repos/jeremycline/pulp/branches{/branch}","tags_url":"https://api.github.com/repos/jeremycline/pulp/tags","blobs_url":"https://api.github.com/repos/jeremycline/pulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremycline/pulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremycline/pulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremycline/pulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremycline/pulp/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremycline/pulp/languages","stargazers_url":"https://api.github.com/repos/jeremycline/pulp/stargazers","contributors_url":"https://api.github.com/repos/jeremycline/pulp/contributors","subscribers_url":"https://api.github.com/repos/jeremycline/pulp/subscribers","subscription_url":"https://api.github.com/repos/jeremycline/pulp/subscription","commits_url":"https://api.github.com/repos/jeremycline/pulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremycline/pulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremycline/pulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremycline/pulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremycline/pulp/contents/{+path}","compare_url":"https://api.github.com/repos/jeremycline/pulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremycline/pulp/merges","archive_url":"https://api.github.com/repos/jeremycline/pulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremycline/pulp/downloads","issues_url":"https://api.github.com/repos/jeremycline/pulp/issues{/number}","pulls_url":"https://api.github.com/repos/jeremycline/pulp/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremycline/pulp/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremycline/pulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremycline/pulp/labels{/name}","releases_url":"https://api.github.com/repos/jeremycline/pulp/releases{/id}","created_at":"2014-10-08T20:18:50Z","updated_at":"2015-01-15T14:25:50Z","pushed_at":"2015-11-30T21:56:08Z","git_url":"git://github.com/jeremycline/pulp.git","ssh_url":"git@github.com:jeremycline/pulp.git","clone_url":"https://github.com/jeremycline/pulp.git","svn_url":"https://github.com/jeremycline/pulp","homepage":"","size":87212,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"pulp:lazy-content","ref":"lazy-content","sha":"38e912de2bcb0b773c1eced1c1667f3f7884a80f","user":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"repo":{"id":5314652,"name":"pulp","full_name":"pulp/pulp","owner":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pulp/pulp","description":"Repository for Pulp platform code, including the server and base admin and consumer clients","fork":false,"url":"https://api.github.com/repos/pulp/pulp","forks_url":"https://api.github.com/repos/pulp/pulp/forks","keys_url":"https://api.github.com/repos/pulp/pulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pulp/pulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pulp/pulp/teams","hooks_url":"https://api.github.com/repos/pulp/pulp/hooks","issue_events_url":"https://api.github.com/repos/pulp/pulp/issues/events{/number}","events_url":"https://api.github.com/repos/pulp/pulp/events","assignees_url":"https://api.github.com/repos/pulp/pulp/assignees{/user}","branches_url":"https://api.github.com/repos/pulp/pulp/branches{/branch}","tags_url":"https://api.github.com/repos/pulp/pulp/tags","blobs_url":"https://api.github.com/repos/pulp/pulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pulp/pulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pulp/pulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/pulp/pulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pulp/pulp/statuses/{sha}","languages_url":"https://api.github.com/repos/pulp/pulp/languages","stargazers_url":"https://api.github.com/repos/pulp/pulp/stargazers","contributors_url":"https://api.github.com/repos/pulp/pulp/contributors","subscribers_url":"https://api.github.com/repos/pulp/pulp/subscribers","subscription_url":"https://api.github.com/repos/pulp/pulp/subscription","commits_url":"https://api.github.com/repos/pulp/pulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/pulp/pulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/pulp/pulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/pulp/pulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/pulp/pulp/contents/{+path}","compare_url":"https://api.github.com/repos/pulp/pulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pulp/pulp/merges","archive_url":"https://api.github.com/repos/pulp/pulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pulp/pulp/downloads","issues_url":"https://api.github.com/repos/pulp/pulp/issues{/number}","pulls_url":"https://api.github.com/repos/pulp/pulp/pulls{/number}","milestones_url":"https://api.github.com/repos/pulp/pulp/milestones{/number}","notifications_url":"https://api.github.com/repos/pulp/pulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pulp/pulp/labels{/name}","releases_url":"https://api.github.com/repos/pulp/pulp/releases{/id}","created_at":"2012-08-06T13:49:20Z","updated_at":"2015-11-27T16:33:23Z","pushed_at":"2015-12-01T02:18:15Z","git_url":"git://github.com/pulp/pulp.git","ssh_url":"git@github.com:pulp/pulp.git","clone_url":"https://github.com/pulp/pulp.git","svn_url":"https://github.com/pulp/pulp","homepage":"","size":88308,"stargazers_count":232,"watchers_count":232,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":92,"mirror_url":null,"open_issues_count":23,"forks":92,"open_issues":23,"watchers":232,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2186"},"html":{"href":"https://github.com/pulp/pulp/pull/2186"},"issue":{"href":"https://api.github.com/repos/pulp/pulp/issues/2186"},"comments":{"href":"https://api.github.com/repos/pulp/pulp/issues/2186/comments"},"review_comments":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2186/comments"},"review_comment":{"href":"https://api.github.com/repos/pulp/pulp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2186/commits"},"statuses":{"href":"https://api.github.com/repos/pulp/pulp/statuses/716cf988c4ec09e4d79f6a2ac0eed77f4c624fb0"}}}}