From 38bbd350145b21aae54ffda3eba4fd73a577f41c Mon Sep 17 00:00:00 2001 From: Alison Date: Fri, 11 Aug 2017 20:36:18 -0500 Subject: [PATCH 1/2] Add last_active_at column to users page #155 --- client/app/pages/users/list.html | 4 ++++ redash/models.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/client/app/pages/users/list.html b/client/app/pages/users/list.html index 8f200f8a4e..3c88def94c 100644 --- a/client/app/pages/users/list.html +++ b/client/app/pages/users/list.html @@ -10,6 +10,7 @@ Name Joined + Last Active At @@ -20,6 +21,9 @@ + + {{ row.last_active_at[0][0] }} + diff --git a/redash/models.py b/redash/models.py index 311fbdb5c4..5899e1489b 100644 --- a/redash/models.py +++ b/redash/models.py @@ -387,6 +387,8 @@ def to_dict(self, with_api_key=False): if with_api_key: d['api_key'] = self.api_key + d['last_active_at'] = Event.query.filter(Event.user_id == self.id).with_entities(Event.created_at).order_by(Event.created_at.desc()).limit(1) + return d def is_api_user(self): From 99e00bc25bbfb69c20104c2527bbcc22fe838f1c Mon Sep 17 00:00:00 2001 From: Alison Date: Tue, 15 Aug 2017 11:53:45 -0500 Subject: [PATCH 2/2] updates to get tests passing --- client/app/pages/users/list.html | 2 +- redash/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/app/pages/users/list.html b/client/app/pages/users/list.html index 3c88def94c..0c1ab53eaf 100644 --- a/client/app/pages/users/list.html +++ b/client/app/pages/users/list.html @@ -22,7 +22,7 @@ - {{ row.last_active_at[0][0] }} + {{ row.last_active_at[0] }} diff --git a/redash/models.py b/redash/models.py index 5899e1489b..607d696dff 100644 --- a/redash/models.py +++ b/redash/models.py @@ -387,7 +387,7 @@ def to_dict(self, with_api_key=False): if with_api_key: d['api_key'] = self.api_key - d['last_active_at'] = Event.query.filter(Event.user_id == self.id).with_entities(Event.created_at).order_by(Event.created_at.desc()).limit(1) + d['last_active_at'] = Event.query.filter(Event.user_id == self.id).with_entities(Event.created_at).order_by(Event.created_at.desc()).first() return d