{"action":"created","comment":{"url":"https://api.github.com/repos/translate/pootle/pulls/comments/56145748","id":56145748,"diff_hunk":"@@ -145,22 +149,36 @@ def results(self):\n         return self.sort_qs(self.filter_qs(self.units_qs))\n \n     def search(self):\n-        uid_list = None\n-        begin = 0\n-        end = 2 * self.chunk_size\n-        if self.initial:\n-            results = self.results\n-            uid_list = list(results.values_list('id', flat=True))\n-            if len(self.uids) == 1:\n-                if self.uids[0] not in uid_list:\n-                    return [], results.none()\n-                index = uid_list.index(self.uids[0])\n-                begin = max(index - self.chunk_size, 0)\n-                end = min(index + self.chunk_size + 1, len(uid_list))\n-        elif self.uids:\n-            results = self.results.filter(id__in=self.uids)\n-        else:\n-            # used by export view\n-            uid_list = list(self.results.values_list('id', flat=True))\n-            results = self.results[:self.chunk_size]\n-        return uid_list, results[begin:end]\n+        total = self.results.count()\n+        start = self.offset\n+        if start > total:\n+            total, total, total, self.results.none()\n+\n+        find_unit = (\n+            not self.offset\n+            and self.language_code\n+            and self.project_code\n+            and self.filename\n+            and self.uids)\n+        find_next_slice = (\n+            self.previous_uids\n+            and self.offset) and True or False\n+\n+        if find_unit:\n+            # find the uid in the Store\n+            uid_list = list(self.results.values_list(\"pk\", flat=True))\n+            unit_index = uid_list.index(self.uids[0])\n+            start = int(unit_index / (2 * self.chunk_size)) * (2 * self.chunk_size)","path":"pootle/apps/pootle_store/unit/search.py","position":77,"original_position":77,"commit_id":"48fee78fa7a54de6463768be81f6a0728eca7575","original_commit_id":"48fee78fa7a54de6463768be81f6a0728eca7575","user":{"login":"unho","id":939880,"avatar_url":"https://avatars.githubusercontent.com/u/939880?v=3","gravatar_id":"","url":"https://api.github.com/users/unho","html_url":"https://github.com/unho","followers_url":"https://api.github.com/users/unho/followers","following_url":"https://api.github.com/users/unho/following{/other_user}","gists_url":"https://api.github.com/users/unho/gists{/gist_id}","starred_url":"https://api.github.com/users/unho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unho/subscriptions","organizations_url":"https://api.github.com/users/unho/orgs","repos_url":"https://api.github.com/users/unho/repos","events_url":"https://api.github.com/users/unho/events{/privacy}","received_events_url":"https://api.github.com/users/unho/received_events","type":"User","site_admin":false},"body":"I know we don't return slices anymore. But previous code did return a slice centered around the unit we wanted. Now we return the offset for a slice, being the offset a multiple of `(2 * self.chunk_size)`, thus the offset is for a virtual slice not centered around the unit anymore. For example we want start for unit 13 and chunk_size is 5, then `start = int(13 /20) / 10` so `start = 10` where previously it was `8` (5 units before and 5 units after the one we looked for).\r\n\r\nBut perhaps I am mistaken.","created_at":"2016-03-15T10:59:20Z","updated_at":"2016-03-15T10:59:20Z","html_url":"https://github.com/translate/pootle/pull/4560#discussion_r56145748","pull_request_url":"https://api.github.com/repos/translate/pootle/pulls/4560","_links":{"self":{"href":"https://api.github.com/repos/translate/pootle/pulls/comments/56145748"},"html":{"href":"https://github.com/translate/pootle/pull/4560#discussion_r56145748"},"pull_request":{"href":"https://api.github.com/repos/translate/pootle/pulls/4560"}}},"pull_request":{"url":"https://api.github.com/repos/translate/pootle/pulls/4560","id":62548403,"html_url":"https://github.com/translate/pootle/pull/4560","diff_url":"https://github.com/translate/pootle/pull/4560.diff","patch_url":"https://github.com/translate/pootle/pull/4560.patch","issue_url":"https://api.github.com/repos/translate/pootle/issues/4560","number":4560,"state":"open","locked":false,"title":"Remove uid lists","user":{"login":"phlax","id":454682,"avatar_url":"https://avatars.githubusercontent.com/u/454682?v=3","gravatar_id":"","url":"https://api.github.com/users/phlax","html_url":"https://github.com/phlax","followers_url":"https://api.github.com/users/phlax/followers","following_url":"https://api.github.com/users/phlax/following{/other_user}","gists_url":"https://api.github.com/users/phlax/gists{/gist_id}","starred_url":"https://api.github.com/users/phlax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phlax/subscriptions","organizations_url":"https://api.github.com/users/phlax/orgs","repos_url":"https://api.github.com/users/phlax/repos","events_url":"https://api.github.com/users/phlax/events{/privacy}","received_events_url":"https://api.github.com/users/phlax/received_events","type":"User","site_admin":false},"body":"This PR removes the uid_list of full search results in the translation editor.\r\n\r\nInstead the units are paginated forwards/backwards using offsets.\r\n\r\nYou can jump to a given index ~as before.\r\n\r\nWhen paginating forwards the editor sends the previous units to adjust the offsets for units that may have been removed eg from being edited.\r\n\r\nYou can jump to a unit in any results set if you know the offset. If the uid is not in the result set at that offset - you will be shown the units currently at that offset.\r\n\r\nFor the Store translation view you can also search by uid of a unit without knowing the offset beforehand, in which case the backend will calculate the offset for the client","created_at":"2016-03-11T14:16:43Z","updated_at":"2016-03-15T10:59:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3347673c795f25448a5f511b4948908b2f5b03d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/translate/pootle/pulls/4560/commits","review_comments_url":"https://api.github.com/repos/translate/pootle/pulls/4560/comments","review_comment_url":"https://api.github.com/repos/translate/pootle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/translate/pootle/issues/4560/comments","statuses_url":"https://api.github.com/repos/translate/pootle/statuses/48fee78fa7a54de6463768be81f6a0728eca7575","head":{"label":"phlax:remove_uid_lists","ref":"remove_uid_lists","sha":"48fee78fa7a54de6463768be81f6a0728eca7575","user":{"login":"phlax","id":454682,"avatar_url":"https://avatars.githubusercontent.com/u/454682?v=3","gravatar_id":"","url":"https://api.github.com/users/phlax","html_url":"https://github.com/phlax","followers_url":"https://api.github.com/users/phlax/followers","following_url":"https://api.github.com/users/phlax/following{/other_user}","gists_url":"https://api.github.com/users/phlax/gists{/gist_id}","starred_url":"https://api.github.com/users/phlax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phlax/subscriptions","organizations_url":"https://api.github.com/users/phlax/orgs","repos_url":"https://api.github.com/users/phlax/repos","events_url":"https://api.github.com/users/phlax/events{/privacy}","received_events_url":"https://api.github.com/users/phlax/received_events","type":"User","site_admin":false},"repo":{"id":39886550,"name":"pootle","full_name":"phlax/pootle","owner":{"login":"phlax","id":454682,"avatar_url":"https://avatars.githubusercontent.com/u/454682?v=3","gravatar_id":"","url":"https://api.github.com/users/phlax","html_url":"https://github.com/phlax","followers_url":"https://api.github.com/users/phlax/followers","following_url":"https://api.github.com/users/phlax/following{/other_user}","gists_url":"https://api.github.com/users/phlax/gists{/gist_id}","starred_url":"https://api.github.com/users/phlax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phlax/subscriptions","organizations_url":"https://api.github.com/users/phlax/orgs","repos_url":"https://api.github.com/users/phlax/repos","events_url":"https://api.github.com/users/phlax/events{/privacy}","received_events_url":"https://api.github.com/users/phlax/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/phlax/pootle","description":"Online translation tool","fork":true,"url":"https://api.github.com/repos/phlax/pootle","forks_url":"https://api.github.com/repos/phlax/pootle/forks","keys_url":"https://api.github.com/repos/phlax/pootle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phlax/pootle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phlax/pootle/teams","hooks_url":"https://api.github.com/repos/phlax/pootle/hooks","issue_events_url":"https://api.github.com/repos/phlax/pootle/issues/events{/number}","events_url":"https://api.github.com/repos/phlax/pootle/events","assignees_url":"https://api.github.com/repos/phlax/pootle/assignees{/user}","branches_url":"https://api.github.com/repos/phlax/pootle/branches{/branch}","tags_url":"https://api.github.com/repos/phlax/pootle/tags","blobs_url":"https://api.github.com/repos/phlax/pootle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phlax/pootle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phlax/pootle/git/refs{/sha}","trees_url":"https://api.github.com/repos/phlax/pootle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phlax/pootle/statuses/{sha}","languages_url":"https://api.github.com/repos/phlax/pootle/languages","stargazers_url":"https://api.github.com/repos/phlax/pootle/stargazers","contributors_url":"https://api.github.com/repos/phlax/pootle/contributors","subscribers_url":"https://api.github.com/repos/phlax/pootle/subscribers","subscription_url":"https://api.github.com/repos/phlax/pootle/subscription","commits_url":"https://api.github.com/repos/phlax/pootle/commits{/sha}","git_commits_url":"https://api.github.com/repos/phlax/pootle/git/commits{/sha}","comments_url":"https://api.github.com/repos/phlax/pootle/comments{/number}","issue_comment_url":"https://api.github.com/repos/phlax/pootle/issues/comments{/number}","contents_url":"https://api.github.com/repos/phlax/pootle/contents/{+path}","compare_url":"https://api.github.com/repos/phlax/pootle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phlax/pootle/merges","archive_url":"https://api.github.com/repos/phlax/pootle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phlax/pootle/downloads","issues_url":"https://api.github.com/repos/phlax/pootle/issues{/number}","pulls_url":"https://api.github.com/repos/phlax/pootle/pulls{/number}","milestones_url":"https://api.github.com/repos/phlax/pootle/milestones{/number}","notifications_url":"https://api.github.com/repos/phlax/pootle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phlax/pootle/labels{/name}","releases_url":"https://api.github.com/repos/phlax/pootle/releases{/id}","deployments_url":"https://api.github.com/repos/phlax/pootle/deployments","created_at":"2015-07-29T10:00:35Z","updated_at":"2016-01-14T21:46:37Z","pushed_at":"2016-03-15T06:48:06Z","git_url":"git://github.com/phlax/pootle.git","ssh_url":"git@github.com:phlax/pootle.git","clone_url":"https://github.com/phlax/pootle.git","svn_url":"https://github.com/phlax/pootle","homepage":"http://pootle.translatehouse.org","size":82303,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"translate:master","ref":"master","sha":"d09e7acc33752d1c8c0b35658021bfe0599fae74","user":{"login":"translate","id":1538178,"avatar_url":"https://avatars.githubusercontent.com/u/1538178?v=3","gravatar_id":"","url":"https://api.github.com/users/translate","html_url":"https://github.com/translate","followers_url":"https://api.github.com/users/translate/followers","following_url":"https://api.github.com/users/translate/following{/other_user}","gists_url":"https://api.github.com/users/translate/gists{/gist_id}","starred_url":"https://api.github.com/users/translate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/translate/subscriptions","organizations_url":"https://api.github.com/users/translate/orgs","repos_url":"https://api.github.com/users/translate/repos","events_url":"https://api.github.com/users/translate/events{/privacy}","received_events_url":"https://api.github.com/users/translate/received_events","type":"Organization","site_admin":false},"repo":{"id":3769702,"name":"pootle","full_name":"translate/pootle","owner":{"login":"translate","id":1538178,"avatar_url":"https://avatars.githubusercontent.com/u/1538178?v=3","gravatar_id":"","url":"https://api.github.com/users/translate","html_url":"https://github.com/translate","followers_url":"https://api.github.com/users/translate/followers","following_url":"https://api.github.com/users/translate/following{/other_user}","gists_url":"https://api.github.com/users/translate/gists{/gist_id}","starred_url":"https://api.github.com/users/translate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/translate/subscriptions","organizations_url":"https://api.github.com/users/translate/orgs","repos_url":"https://api.github.com/users/translate/repos","events_url":"https://api.github.com/users/translate/events{/privacy}","received_events_url":"https://api.github.com/users/translate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/translate/pootle","description":"Online translation tool","fork":false,"url":"https://api.github.com/repos/translate/pootle","forks_url":"https://api.github.com/repos/translate/pootle/forks","keys_url":"https://api.github.com/repos/translate/pootle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/translate/pootle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/translate/pootle/teams","hooks_url":"https://api.github.com/repos/translate/pootle/hooks","issue_events_url":"https://api.github.com/repos/translate/pootle/issues/events{/number}","events_url":"https://api.github.com/repos/translate/pootle/events","assignees_url":"https://api.github.com/repos/translate/pootle/assignees{/user}","branches_url":"https://api.github.com/repos/translate/pootle/branches{/branch}","tags_url":"https://api.github.com/repos/translate/pootle/tags","blobs_url":"https://api.github.com/repos/translate/pootle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/translate/pootle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/translate/pootle/git/refs{/sha}","trees_url":"https://api.github.com/repos/translate/pootle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/translate/pootle/statuses/{sha}","languages_url":"https://api.github.com/repos/translate/pootle/languages","stargazers_url":"https://api.github.com/repos/translate/pootle/stargazers","contributors_url":"https://api.github.com/repos/translate/pootle/contributors","subscribers_url":"https://api.github.com/repos/translate/pootle/subscribers","subscription_url":"https://api.github.com/repos/translate/pootle/subscription","commits_url":"https://api.github.com/repos/translate/pootle/commits{/sha}","git_commits_url":"https://api.github.com/repos/translate/pootle/git/commits{/sha}","comments_url":"https://api.github.com/repos/translate/pootle/comments{/number}","issue_comment_url":"https://api.github.com/repos/translate/pootle/issues/comments{/number}","contents_url":"https://api.github.com/repos/translate/pootle/contents/{+path}","compare_url":"https://api.github.com/repos/translate/pootle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/translate/pootle/merges","archive_url":"https://api.github.com/repos/translate/pootle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/translate/pootle/downloads","issues_url":"https://api.github.com/repos/translate/pootle/issues{/number}","pulls_url":"https://api.github.com/repos/translate/pootle/pulls{/number}","milestones_url":"https://api.github.com/repos/translate/pootle/milestones{/number}","notifications_url":"https://api.github.com/repos/translate/pootle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/translate/pootle/labels{/name}","releases_url":"https://api.github.com/repos/translate/pootle/releases{/id}","deployments_url":"https://api.github.com/repos/translate/pootle/deployments","created_at":"2012-03-19T23:06:03Z","updated_at":"2016-03-12T09:05:15Z","pushed_at":"2016-03-15T10:47:41Z","git_url":"git://github.com/translate/pootle.git","ssh_url":"git@github.com:translate/pootle.git","clone_url":"https://github.com/translate/pootle.git","svn_url":"https://github.com/translate/pootle","homepage":"http://pootle.translatehouse.org","size":83690,"stargazers_count":602,"watchers_count":602,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":174,"mirror_url":null,"open_issues_count":289,"forks":174,"open_issues":289,"watchers":602,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/translate/pootle/pulls/4560"},"html":{"href":"https://github.com/translate/pootle/pull/4560"},"issue":{"href":"https://api.github.com/repos/translate/pootle/issues/4560"},"comments":{"href":"https://api.github.com/repos/translate/pootle/issues/4560/comments"},"review_comments":{"href":"https://api.github.com/repos/translate/pootle/pulls/4560/comments"},"review_comment":{"href":"https://api.github.com/repos/translate/pootle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/translate/pootle/pulls/4560/commits"},"statuses":{"href":"https://api.github.com/repos/translate/pootle/statuses/48fee78fa7a54de6463768be81f6a0728eca7575"}}}}