Skip to content
Snippets Groups Projects
Commit 87f50620 authored by Mariusz Trela's avatar Mariusz Trela
Browse files

Changes in `hive_accounts_info_view` view

parent 5bd75a57
No related branches found
No related tags found
5 merge requests!456Release candidate v1 24,!230Setup monitoring with pghero,!138Small typos fixed,!135Enable postgres monitoring on CI server,!110Teh call `get_profile` works
...@@ -576,34 +576,34 @@ def setup(db): ...@@ -576,34 +576,34 @@ def setup(db):
SELECT SELECT
id, id,
name, name,
COALESCE( (
( select count(*) post_count
select count(*) post_count FROM hive_posts hp
FROM hive_posts hp WHERE ha.id=hp.author_id
WHERE ha.id=hp.author_id
GROUP BY hp.author_id
),
0
) post_count, ) 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, 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, display_name,
about, about,
reputation, reputation,
......
...@@ -66,7 +66,7 @@ async def get_profile(context, account, observer=None): ...@@ -66,7 +66,7 @@ async def get_profile(context, account, observer=None):
"""Load account/profile data.""" """Load account/profile data."""
db = context['db'] db = context['db']
ret = await load_profiles(db, [valid_account(account)]) 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 observer_id = await get_account_id(db, observer) if observer else None
if observer_id: if observer_id:
......
...@@ -201,7 +201,7 @@ def _condenser_profile_object(row): ...@@ -201,7 +201,7 @@ def _condenser_profile_object(row):
'id': row['id'], 'id': row['id'],
'name': row['name'], 'name': row['name'],
'created': json_date(row['created_at']), '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'], 'post_count': row['post_count'],
'reputation': row['reputation'], 'reputation': row['reputation'],
'blacklists': blacklists, 'blacklists': blacklists,
......
...@@ -463,7 +463,7 @@ async def get_accounts(db, accounts: list): ...@@ -463,7 +463,7 @@ async def get_accounts(db, accounts: list):
account_data['rank'] = row.rank account_data['rank'] = row.rank
account_data['lastread_at'] = row.lastread_at.isoformat() 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() account_data['cached_at'] = row.cached_at.isoformat()
ret.append(account_data) ret.append(account_data)
......
Subproject commit 8a5c78b1c4e7c3046bea24c07058d644eb8fb608 Subproject commit c43071931d6c7533c117ef8659f152073bba129a
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment