From 87f506205573040cb8c478ef9318aaa132f294de Mon Sep 17 00:00:00 2001 From: mtrela <mtrela@syncad.com> Date: Fri, 4 Sep 2020 14:17:21 +0200 Subject: [PATCH] Changes in `hive_accounts_info_view` view --- hive/db/schema.py | 52 ++++++++++++++--------------- hive/server/bridge_api/methods.py | 2 +- hive/server/bridge_api/objects.py | 2 +- hive/server/condenser_api/cursor.py | 2 +- tests/tests_api | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/hive/db/schema.py b/hive/db/schema.py index 11b0d95e6..92631c0a5 100644 --- a/hive/db/schema.py +++ b/hive/db/schema.py @@ -576,34 +576,34 @@ def setup(db): SELECT id, name, - COALESCE( - ( - select count(*) post_count - FROM hive_posts hp - WHERE ha.id=hp.author_id - GROUP BY hp.author_id - ), - 0 + ( + select count(*) post_count + FROM hive_posts hp + WHERE ha.id=hp.author_id ) post_count, - COALESCE( - ( - select max(hp.created_at) - FROM hive_posts hp - WHERE ha.id=hp.author_id - GROUP BY hp.author_id - ), - '1970-01-01 00:00:00.0' - ) post_active_at, - COALESCE( - ( - select max(hv.last_update) - from hive_votes hv - WHERE ha.id=hv.voter_id - GROUP BY hv.voter_id - ), - '1970-01-01 00:00:00.0' - ) AS vote_active_at, created_at, + ( + SELECT GREATEST + ( + created_at, + COALESCE( + ( + select max(hp.created_at) + FROM hive_posts hp + WHERE ha.id=hp.author_id + ), + '1970-01-01 00:00:00.0' + ), + COALESCE( + ( + select max(hv.last_update) + from hive_votes hv + WHERE ha.id=hv.voter_id + ), + '1970-01-01 00:00:00.0' + ) + ) + ) active_at, display_name, about, reputation, diff --git a/hive/server/bridge_api/methods.py b/hive/server/bridge_api/methods.py index 1ae35ced1..913459495 100644 --- a/hive/server/bridge_api/methods.py +++ b/hive/server/bridge_api/methods.py @@ -66,7 +66,7 @@ async def get_profile(context, account, observer=None): """Load account/profile data.""" db = context['db'] ret = await load_profiles(db, [valid_account(account)]) - assert ret, 'account \'{}\' does not exist'.format(account) + assert ret, 'Account \'{}\' does not exist'.format(account) observer_id = await get_account_id(db, observer) if observer else None if observer_id: diff --git a/hive/server/bridge_api/objects.py b/hive/server/bridge_api/objects.py index 3ba4db6b9..ae9969d14 100644 --- a/hive/server/bridge_api/objects.py +++ b/hive/server/bridge_api/objects.py @@ -201,7 +201,7 @@ def _condenser_profile_object(row): 'id': row['id'], 'name': row['name'], 'created': json_date(row['created_at']), - 'active': json_date(max( row['created_at'], row['post_active_at'], row['vote_active_at'] )), + 'active': json_date(row['active_at']), 'post_count': row['post_count'], 'reputation': row['reputation'], 'blacklists': blacklists, diff --git a/hive/server/condenser_api/cursor.py b/hive/server/condenser_api/cursor.py index fca016f02..6a829832d 100644 --- a/hive/server/condenser_api/cursor.py +++ b/hive/server/condenser_api/cursor.py @@ -463,7 +463,7 @@ async def get_accounts(db, accounts: list): account_data['rank'] = row.rank account_data['lastread_at'] = row.lastread_at.isoformat() - account_data['active_at'] = max( row.created_at, row.post_active_at, row.vote_active_at ).isoformat() + account_data['active_at'] = row.active_at.isoformat() account_data['cached_at'] = row.cached_at.isoformat() ret.append(account_data) diff --git a/tests/tests_api b/tests/tests_api index 8a5c78b1c..c43071931 160000 --- a/tests/tests_api +++ b/tests/tests_api @@ -1 +1 @@ -Subproject commit 8a5c78b1c4e7c3046bea24c07058d644eb8fb608 +Subproject commit c43071931d6c7533c117ef8659f152073bba129a -- GitLab