GitHub PullRequestReviewCommentEvent at 2014-05-07 21:41:14
Repository: otter
Actor: cyli
Payload: {"comment":{"url":"https://api.github.com/repos/rackerlabs/otter/pulls/comments/12404610","id":12404610,"diff_hunk":"@@ -6,9 +6,63 @@\n import json\n \n from otter.log import log\n+from otter.log.formatters import AUDIT_LOG_FIELDS\n from otter.rest.otterapp import OtterApp\n-from otter.rest.decorators import fails_with, succeeds_with, with_transaction_id\n+from otter.rest.decorators import fails_with, paginatable, succeeds_with, with_transaction_id\n from otter.rest.errors import exception_codes\n+from otter.util import logging_treq as treq\n+from otter.util.config import config_value\n+from otter.util.http import append_segments, check_success, get_collection_links\n+\n+\n+def make_auditlog_query(tenant_id, region, limit, marker=None):\n+    \"\"\"Make an elastic search query to fetch audit logs.\"\"\"\n+    return {\n+        \"size\": limit,\n+        \"query\": {\n+            \"filtered\": {\n+                \"filter\": {\n+                    \"bool\": {\n+                        \"must\": [\n+                            {\n+                                \"range\": {\n+                                    \"@timestamp\": {\n+                                        \"from\": \"now-30d\",\n+                                        \"to\": marker or \"now\"\n+                                    }\n+                                }\n+                            },\n+                            {\n+                                \"term\": {\"audit_log\": True}\n+                            },\n+                            {\n+                                \"term\": {\"tenant_id\": tenant_id.strip()}\n+                            },\n+                            {\n+                                \"term\": {\"tags\": region.lower().strip()}\n+                            }\n+                        ]\n+                    }\n+                }\n+            }\n+        },\n+        \"sort\": [{\"@timestamp\": {'order': 'desc'}}]\n+    }\n+\n+\n+def next_marker_by_timestamp(collection, limit, marker):\n+    \"\"\"\n+    Returns the next marker that is just last item in the collection's timestamp\n+\n+    :param collection: an iterable containing the collection to be paginated\n+    :param limit: the limit on the collection\n+    :marker: the current marker used to obtain this collection","path":"otter/rest/history.py","position":55,"original_position":55,"commit_id":"619bae8a38b54a0aafecc74d453e32a36cad293a","original_commit_id":"619bae8a38b54a0aafecc74d453e32a36cad293a","user":{"login":"cyli","id":223200,"avatar_url":"https://avatars.githubusercontent.com/u/223200?","gravatar_id":"307ebad5fc7824b9f223fbad5698d278","url":"https://api.github.com/users/cyli","html_url":"https://github.com/cyli","followers_url":"https://api.github.com/users/cyli/followers","following_url":"https://api.github.com/users/cyli/following{/other_user}","gists_url":"https://api.github.com/users/cyli/gists{/gist_id}","starred_url":"https://api.github.com/users/cyli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyli/subscriptions","organizations_url":"https://api.github.com/users/cyli/orgs","repos_url":"https://api.github.com/users/cyli/repos","events_url":"https://api.github.com/users/cyli/events{/privacy}","received_events_url":"https://api.github.com/users/cyli/received_events","type":"User","site_admin":false},"body":"It's a parameter mainly do to the pagination function, it passes all 3 because the marker could depend on the previous marker (`next_marker_by_offset` function) - since that's not used anywhere right now, perhaps we should just kill it?","created_at":"2014-05-07T21:41:14Z","updated_at":"2014-05-07T21:41:14Z","html_url":"https://github.com/rackerlabs/otter/pull/493#discussion_r12404610","pull_request_url":"https://api.github.com/repos/rackerlabs/otter/pulls/493","_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/otter/pulls/comments/12404610"},"html":{"href":"https://github.com/rackerlabs/otter/pull/493#discussion_r12404610"},"pull_request":{"href":"https://api.github.com/repos/rackerlabs/otter/pulls/493"}}}}