diff --git a/hive/db/schema.py b/hive/db/schema.py index 11b0d95e6c64a69c5de512be7ce704947f833329..92631c0a558b18af5e77f40bad58f2920b9a940f 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 1ae35ced14401dbd15caf3f6d2efe3a842bd2836..913459495f11bcd3b7ae2ab350b0a7ecbf4c15cf 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 3ba4db6b98dd8b2742a2fb7c47099d3661f440c8..ae9969d144a457011da270e74f3af7cb3e4d0f29 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 fca016f02e4bcd9736be08e579cc3426bc4540e0..6a829832db9f07ea04436768e0e4a150a7d35d89 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 8a5c78b1c4e7c3046bea24c07058d644eb8fb608..c43071931d6c7533c117ef8659f152073bba129a 160000 --- a/tests/tests_api +++ b/tests/tests_api @@ -1 +1 @@ -Subproject commit 8a5c78b1c4e7c3046bea24c07058d644eb8fb608 +Subproject commit c43071931d6c7533c117ef8659f152073bba129a