From 18d9b2eec92f45a67b493860b50cf055f41e8583 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Wed, 27 Sep 2017 18:04:21 +0300 Subject: [PATCH] Fix #1950: record_event fails for api events --- redash/handlers/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/redash/handlers/base.py b/redash/handlers/base.py index c5917c92..7cc85ee0 100644 --- a/redash/handlers/base.py +++ b/redash/handlers/base.py @@ -44,7 +44,7 @@ class BaseResource(Resource): def record_event(org, user, options): - if isinstance(user, ApiUser): + if user.is_api_user(): options.update({ 'api_key': user.name, 'org_id': org.id @@ -52,6 +52,7 @@ def record_event(org, user, options): else: options.update({ 'user_id': user.id, + 'user_name': user.name, 'org_id': org.id }) @@ -88,7 +89,7 @@ def paginate(query_set, page, page_size, serializer): if page < 1: abort(400, message='Page must be positive integer.') - if (page-1)*page_size+1 > count > 0: + if (page - 1) * page_size + 1 > count > 0: abort(400, message='Page is out of range.') if page_size > 250 or page_size < 1: