{"action":"created","comment":{"url":"https://api.github.com/repos/praekelt/vumi/pulls/comments/27953757","id":27953757,"diff_hunk":"@@ -124,18 +154,24 @@ class InboundMessage(Model):\n     # Extra fields for compound indexes\n     batches_with_timestamps = ListOf(Unicode(), index=True)\n     batches_with_addresses = ListOf(Unicode(), index=True)\n+    batches_with_addresses_reverse = ListOf(Unicode(), index=True)\n \n     def save(self):\n         # We override this method to set our index fields before saving.\n-        batches_with_timestamps = []\n-        batches_with_addresses = []\n+        self.batches_with_timestamps = []\n+        self.batches_with_addresses = []\n+        self.batches_with_addresses_reverse = []\n         timestamp = self.msg['timestamp']\n+        if not isinstance(timestamp, basestring):\n+            timestamp = format_vumi_date(timestamp)\n+        reverse_ts = to_reverse_timestamp(timestamp)\n         for batch_id in self.batches.keys():\n-            batches_with_timestamps.append(u\"%s$%s\" % (batch_id, timestamp))\n-            batches_with_addresses.append(\n+            self.batches_with_timestamps.append(\n+                u\"%s$%s\" % (batch_id, timestamp))\n+            self.batches_with_addresses.append(\n                 u\"%s$%s$%s\" % (batch_id, timestamp, self.msg['from_addr']))\n-        self.batches_with_timestamps = batches_with_timestamps\n-        self.batches_with_addresses = batches_with_addresses\n+            self.batches_with_addresses_reverse.append(\n+                u\"%s$%s$%s\" % (batch_id, reverse_ts, self.msg['from_addr']))","path":"vumi/components/message_store.py","position":115,"original_position":115,"commit_id":"ddd7980d3325530686f98cbca8af55cbf2e34b99","original_commit_id":"ddd7980d3325530686f98cbca8af55cbf2e34b99","user":{"login":"justinvdm","id":1731223,"avatar_url":"https://avatars.githubusercontent.com/u/1731223?v=3","gravatar_id":"","url":"https://api.github.com/users/justinvdm","html_url":"https://github.com/justinvdm","followers_url":"https://api.github.com/users/justinvdm/followers","following_url":"https://api.github.com/users/justinvdm/following{/other_user}","gists_url":"https://api.github.com/users/justinvdm/gists{/gist_id}","starred_url":"https://api.github.com/users/justinvdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinvdm/subscriptions","organizations_url":"https://api.github.com/users/justinvdm/orgs","repos_url":"https://api.github.com/users/justinvdm/repos","events_url":"https://api.github.com/users/justinvdm/events{/privacy}","received_events_url":"https://api.github.com/users/justinvdm/received_events","type":"User","site_admin":false},"body":"Probably not worth doing much work on here since we are going to be using github.com/praekelt/vumi-message-store some time in the future, but I'm seeing quite a bit of repitition between `InboundMessage.save` and `OutboundMessage.save`. Would it maybe be worth removing that repitition in vumi-message-store, if these models were copied across as is?","created_at":"2015-04-08T09:10:03Z","updated_at":"2015-04-08T09:10:03Z","html_url":"https://github.com/praekelt/vumi/pull/937#discussion_r27953757","pull_request_url":"https://api.github.com/repos/praekelt/vumi/pulls/937","_links":{"self":{"href":"https://api.github.com/repos/praekelt/vumi/pulls/comments/27953757"},"html":{"href":"https://github.com/praekelt/vumi/pull/937#discussion_r27953757"},"pull_request":{"href":"https://api.github.com/repos/praekelt/vumi/pulls/937"}}},"pull_request":{"url":"https://api.github.com/repos/praekelt/vumi/pulls/937","id":32503063,"html_url":"https://github.com/praekelt/vumi/pull/937","diff_url":"https://github.com/praekelt/vumi/pull/937.diff","patch_url":"https://github.com/praekelt/vumi/pull/937.patch","issue_url":"https://api.github.com/repos/praekelt/vumi/issues/937","number":937,"state":"open","locked":false,"title":"Reverse timestamp batch indexes for message store","user":{"login":"jerith","id":43731,"avatar_url":"https://avatars.githubusercontent.com/u/43731?v=3","gravatar_id":"","url":"https://api.github.com/users/jerith","html_url":"https://github.com/jerith","followers_url":"https://api.github.com/users/jerith/followers","following_url":"https://api.github.com/users/jerith/following{/other_user}","gists_url":"https://api.github.com/users/jerith/gists{/gist_id}","starred_url":"https://api.github.com/users/jerith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerith/subscriptions","organizations_url":"https://api.github.com/users/jerith/orgs","repos_url":"https://api.github.com/users/jerith/repos","events_url":"https://api.github.com/users/jerith/events{/privacy}","received_events_url":"https://api.github.com/users/jerith/received_events","type":"User","site_admin":false},"body":"We often want message store index results in reverse time order, which currently means walking the entire index to get the results we need.\r\n\r\n(I was originally planning to add similar indexes to stored events as well, but that changes the message store API and is therefore best left for a new PR.)","created_at":"2015-04-02T11:25:16Z","updated_at":"2015-04-08T09:10:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9dd07d32df0a0ff4d658e35a0d5a6d04583db32","assignee":{"login":"jerith","id":43731,"avatar_url":"https://avatars.githubusercontent.com/u/43731?v=3","gravatar_id":"","url":"https://api.github.com/users/jerith","html_url":"https://github.com/jerith","followers_url":"https://api.github.com/users/jerith/followers","following_url":"https://api.github.com/users/jerith/following{/other_user}","gists_url":"https://api.github.com/users/jerith/gists{/gist_id}","starred_url":"https://api.github.com/users/jerith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerith/subscriptions","organizations_url":"https://api.github.com/users/jerith/orgs","repos_url":"https://api.github.com/users/jerith/repos","events_url":"https://api.github.com/users/jerith/events{/privacy}","received_events_url":"https://api.github.com/users/jerith/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/praekelt/vumi/pulls/937/commits","review_comments_url":"https://api.github.com/repos/praekelt/vumi/pulls/937/comments","review_comment_url":"https://api.github.com/repos/praekelt/vumi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/praekelt/vumi/issues/937/comments","statuses_url":"https://api.github.com/repos/praekelt/vumi/statuses/ddd7980d3325530686f98cbca8af55cbf2e34b99","head":{"label":"praekelt:feature/issue-937-reverse-time-batch-indexes","ref":"feature/issue-937-reverse-time-batch-indexes","sha":"ddd7980d3325530686f98cbca8af55cbf2e34b99","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":1081665,"name":"vumi","full_name":"praekelt/vumi","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/vumi","description":"Messaging engine for the delivery of SMS, Star Menu and chat messages to diverse audiences in emerging markets and beyond.","fork":false,"url":"https://api.github.com/repos/praekelt/vumi","forks_url":"https://api.github.com/repos/praekelt/vumi/forks","keys_url":"https://api.github.com/repos/praekelt/vumi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/vumi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/vumi/teams","hooks_url":"https://api.github.com/repos/praekelt/vumi/hooks","issue_events_url":"https://api.github.com/repos/praekelt/vumi/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/vumi/events","assignees_url":"https://api.github.com/repos/praekelt/vumi/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/vumi/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/vumi/tags","blobs_url":"https://api.github.com/repos/praekelt/vumi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/vumi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/vumi/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/vumi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/vumi/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/vumi/languages","stargazers_url":"https://api.github.com/repos/praekelt/vumi/stargazers","contributors_url":"https://api.github.com/repos/praekelt/vumi/contributors","subscribers_url":"https://api.github.com/repos/praekelt/vumi/subscribers","subscription_url":"https://api.github.com/repos/praekelt/vumi/subscription","commits_url":"https://api.github.com/repos/praekelt/vumi/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/vumi/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/vumi/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/vumi/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/vumi/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/vumi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/vumi/merges","archive_url":"https://api.github.com/repos/praekelt/vumi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/vumi/downloads","issues_url":"https://api.github.com/repos/praekelt/vumi/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/vumi/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/vumi/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/vumi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/vumi/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/vumi/releases{/id}","created_at":"2010-11-15T11:34:03Z","updated_at":"2015-04-08T08:57:46Z","pushed_at":"2015-04-08T09:03:49Z","git_url":"git://github.com/praekelt/vumi.git","ssh_url":"git@github.com:praekelt/vumi.git","clone_url":"https://github.com/praekelt/vumi.git","svn_url":"https://github.com/praekelt/vumi","homepage":"","size":22351,"stargazers_count":201,"watchers_count":201,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":72,"mirror_url":null,"open_issues_count":89,"forks":72,"open_issues":89,"watchers":201,"default_branch":"develop"}},"base":{"label":"praekelt:develop","ref":"develop","sha":"483ecebcf9301031ff1864b26b91872f1e82327d","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":1081665,"name":"vumi","full_name":"praekelt/vumi","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/vumi","description":"Messaging engine for the delivery of SMS, Star Menu and chat messages to diverse audiences in emerging markets and beyond.","fork":false,"url":"https://api.github.com/repos/praekelt/vumi","forks_url":"https://api.github.com/repos/praekelt/vumi/forks","keys_url":"https://api.github.com/repos/praekelt/vumi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/vumi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/vumi/teams","hooks_url":"https://api.github.com/repos/praekelt/vumi/hooks","issue_events_url":"https://api.github.com/repos/praekelt/vumi/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/vumi/events","assignees_url":"https://api.github.com/repos/praekelt/vumi/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/vumi/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/vumi/tags","blobs_url":"https://api.github.com/repos/praekelt/vumi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/vumi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/vumi/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/vumi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/vumi/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/vumi/languages","stargazers_url":"https://api.github.com/repos/praekelt/vumi/stargazers","contributors_url":"https://api.github.com/repos/praekelt/vumi/contributors","subscribers_url":"https://api.github.com/repos/praekelt/vumi/subscribers","subscription_url":"https://api.github.com/repos/praekelt/vumi/subscription","commits_url":"https://api.github.com/repos/praekelt/vumi/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/vumi/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/vumi/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/vumi/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/vumi/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/vumi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/vumi/merges","archive_url":"https://api.github.com/repos/praekelt/vumi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/vumi/downloads","issues_url":"https://api.github.com/repos/praekelt/vumi/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/vumi/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/vumi/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/vumi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/vumi/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/vumi/releases{/id}","created_at":"2010-11-15T11:34:03Z","updated_at":"2015-04-08T08:57:46Z","pushed_at":"2015-04-08T09:03:49Z","git_url":"git://github.com/praekelt/vumi.git","ssh_url":"git@github.com:praekelt/vumi.git","clone_url":"https://github.com/praekelt/vumi.git","svn_url":"https://github.com/praekelt/vumi","homepage":"","size":22351,"stargazers_count":201,"watchers_count":201,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":72,"mirror_url":null,"open_issues_count":89,"forks":72,"open_issues":89,"watchers":201,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/praekelt/vumi/pulls/937"},"html":{"href":"https://github.com/praekelt/vumi/pull/937"},"issue":{"href":"https://api.github.com/repos/praekelt/vumi/issues/937"},"comments":{"href":"https://api.github.com/repos/praekelt/vumi/issues/937/comments"},"review_comments":{"href":"https://api.github.com/repos/praekelt/vumi/pulls/937/comments"},"review_comment":{"href":"https://api.github.com/repos/praekelt/vumi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/praekelt/vumi/pulls/937/commits"},"statuses":{"href":"https://api.github.com/repos/praekelt/vumi/statuses/ddd7980d3325530686f98cbca8af55cbf2e34b99"}}}}