-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: move events serverside #2661
Changes from 10 commits
f31e346
94fb2d9
5b0ea8c
133283a
f46e668
c51edd3
4ac7ab8
2e748ce
89aa0d6
ea91d91
5f352ef
ff848f2
b2d57f8
bd34db6
86086a9
6c8146c
a66d304
f3c2e44
2d189d5
c09c41f
033841c
7ea2f37
dc83652
7614368
167ea03
8f9e63d
2c3149c
c8e9f42
e34b5b2
13b7bed
6b229a0
0a06222
f4a349e
ba80c43
ff55413
8134845
145dd98
9a587e8
2dbde49
9ed4815
b3bc29d
8f6597c
f899a1b
65eff8d
c87ec6a
4add5bb
105e798
16846d7
6f3d513
016e4ac
dad916e
8c176cb
e93385e
c4b9a25
2a09e2d
c202a9a
7a46113
6377dcd
ae43558
5497f0e
d9ae75b
ea4d2ab
9b16179
4b99223
c735de6
81287d1
85727c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import json | ||
import time | ||
|
||
from flask import request | ||
from flask_login import login_required | ||
|
@@ -7,6 +8,7 @@ | |
from redash.handlers.base import json_response | ||
from redash.permissions import require_super_admin | ||
from redash.tasks.queries import QueryTaskTracker | ||
from redash.tasks import record_event | ||
|
||
|
||
@routes.route('/api/admin/queries/outdated', methods=['GET']) | ||
|
@@ -23,6 +25,12 @@ def outdated_queries(): | |
else: | ||
outdated_queries = [] | ||
|
||
record_event({ | ||
'action': 'list', | ||
'object_id': 'admin/outdated_queries', | ||
'object_type': 'outdated_queries' | ||
}) | ||
|
||
return json_response( | ||
dict(queries=[q.to_dict(with_stats=True, with_last_modified_by=False) | ||
for q in outdated_queries], | ||
|
@@ -33,6 +41,11 @@ def outdated_queries(): | |
@require_super_admin | ||
@login_required | ||
def queries_tasks(): | ||
record_event({ | ||
'action': 'list', | ||
'object_type': 'celery_tasks', | ||
'object_id': 'admin/tasks', | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
global_limit = int(request.args.get('limit', 50)) | ||
waiting_limit = int(request.args.get('waiting_limit', global_limit)) | ||
progress_limit = int(request.args.get('progress_limit', global_limit)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,13 @@ class AlertResource(BaseResource): | |
def get(self, alert_id): | ||
alert = get_object_or_404(models.Alert.get_by_id_and_org, alert_id, self.current_org) | ||
require_access(alert.groups, self.current_user, view_only) | ||
|
||
self.record_event({ | ||
'action': 'view', | ||
'object_id': alert.id, | ||
'object_type': 'alert' | ||
}) | ||
|
||
return serialize_alert(alert) | ||
|
||
def post(self, alert_id): | ||
|
@@ -28,7 +35,6 @@ def post(self, alert_id): | |
|
||
self.record_event({ | ||
'action': 'edit', | ||
'timestamp': int(time.time()), | ||
'object_id': alert.id, | ||
'object_type': 'alert' | ||
}) | ||
|
@@ -65,7 +71,6 @@ def post(self): | |
|
||
self.record_event({ | ||
'action': 'create', | ||
'timestamp': int(time.time()), | ||
'object_id': alert.id, | ||
'object_type': 'alert' | ||
}) | ||
|
@@ -74,6 +79,11 @@ def post(self): | |
|
||
@require_permission('list_alerts') | ||
def get(self): | ||
self.record_event({ | ||
'action': 'list', | ||
'object_id': 'alerts', | ||
'object_type': 'alerts' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The object type is different to what is used above. Should this be the same? |
||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's convert all the list actions, where you used
|
||
return [serialize_alert(alert) for alert in models.Alert.all(group_ids=self.current_user.group_ids)] | ||
|
||
|
||
|
@@ -95,7 +105,6 @@ def post(self, alert_id): | |
|
||
self.record_event({ | ||
'action': 'subscribe', | ||
'timestamp': int(time.time()), | ||
'object_id': alert_id, | ||
'object_type': 'alert', | ||
'destination': req.get('destination_id') | ||
|
@@ -122,7 +131,6 @@ def delete(self, alert_id, subscriber_id): | |
|
||
self.record_event({ | ||
'action': 'unsubscribe', | ||
'timestamp': int(time.time()), | ||
'object_id': alert_id, | ||
'object_type': 'alert' | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action
->list
object_type
->outdated_queries
(
object_id
can be null and can be ommited)