mirror of https://github.com/zulip/zulip.git
Remove client-specific tabs from activity overview page.
Waseem is ok with removing the client-specific tabs on the main /activity page. This reduces the number of queries from 25 to 1. We might eventually restore some of that logic, but we will do it more efficiently. A lot of the data for non-website clients is kind of unreliable, anyway. The page looks kind of funny with only one tab, but that will be fixed in the next commit. (imported from commit 54f08f89d5242ad3e045d8ca0d97b86617c15380)
This commit is contained in:
parent
374a64acf8
commit
786c2cf759
|
@ -347,7 +347,7 @@ class ActivityTest(AuthedTestCase):
|
||||||
)
|
)
|
||||||
with queries_captured() as queries:
|
with queries_captured() as queries:
|
||||||
self.client.get('/activity')
|
self.client.get('/activity')
|
||||||
self.assertEqual(len(queries), 25)
|
self.assertEqual(len(queries), 1)
|
||||||
|
|
||||||
class PublicURLTest(TestCase):
|
class PublicURLTest(TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1779,12 +1779,9 @@ class ActivityTable(object):
|
||||||
|
|
||||||
records = UserActivity.objects.filter(
|
records = UserActivity.objects.filter(
|
||||||
query=url,
|
query=url,
|
||||||
client__name__startswith=client_name
|
client__name__startswith=client_name,
|
||||||
|
user_profile__realm__domain=realm
|
||||||
)
|
)
|
||||||
|
|
||||||
if realm:
|
|
||||||
records = records.filter(user_profile__realm__domain=realm)
|
|
||||||
|
|
||||||
records = records.select_related().only(*fields)
|
records = records.select_related().only(*fields)
|
||||||
|
|
||||||
count_field = query_name + '_count'
|
count_field = query_name + '_count'
|
||||||
|
@ -1797,26 +1794,13 @@ class ActivityTable(object):
|
||||||
count = record.count
|
count = record.count
|
||||||
last_visit = record.last_visit
|
last_visit = record.last_visit
|
||||||
|
|
||||||
if realm:
|
row = self.rows.setdefault(email,
|
||||||
row = self.rows.setdefault(email,
|
{'realm': domain,
|
||||||
{'realm': domain,
|
'full_name': full_name,
|
||||||
'full_name': full_name,
|
'email': email,
|
||||||
'email': email,
|
'type': 'user'})
|
||||||
'type': 'user'})
|
row[count_field] = count
|
||||||
row[count_field] = count
|
row[last_visit_field] = last_visit
|
||||||
row[last_visit_field] = last_visit
|
|
||||||
|
|
||||||
else:
|
|
||||||
row = self.rows.setdefault(domain,
|
|
||||||
{'realm': domain,
|
|
||||||
'type': 'realm'})
|
|
||||||
row.setdefault(count_field, 0)
|
|
||||||
row[count_field] += count
|
|
||||||
|
|
||||||
if last_visit_field in row:
|
|
||||||
row[last_visit_field] = max(last_visit, row[last_visit_field])
|
|
||||||
else:
|
|
||||||
row[last_visit_field] = last_visit
|
|
||||||
|
|
||||||
|
|
||||||
for query_name, urls in queries:
|
for query_name, urls in queries:
|
||||||
|
@ -1940,19 +1924,19 @@ def get_activity(request, realm=REQ(default=None)):
|
||||||
("send_message", ["/api/v1/send_message"]),
|
("send_message", ["/api/v1/send_message"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
data = []
|
|
||||||
|
|
||||||
if realm is None:
|
if realm is None:
|
||||||
data.append(('General', realm_summary_table()))
|
data = [
|
||||||
|
('Counts', realm_summary_table())
|
||||||
data += [
|
]
|
||||||
('Website', ActivityTable(realm, 'website', web_queries)),
|
else:
|
||||||
('Mirror', ActivityTable(realm, 'zephyr_mirror', api_queries)),
|
data = [
|
||||||
('Desktop', ActivityTable(realm, 'desktop', web_queries)),
|
('Website', ActivityTable(realm, 'website', web_queries)),
|
||||||
('API', ActivityTable(realm, 'API', api_queries)),
|
('Mirror', ActivityTable(realm, 'zephyr_mirror', api_queries)),
|
||||||
('Android', ActivityTable(realm, 'Android', api_queries)),
|
('Desktop', ActivityTable(realm, 'desktop', web_queries)),
|
||||||
('iPhone', ActivityTable(realm, 'iPhone', api_queries))
|
('API', ActivityTable(realm, 'API', api_queries)),
|
||||||
]
|
('Android', ActivityTable(realm, 'Android', api_queries)),
|
||||||
|
('iPhone', ActivityTable(realm, 'iPhone', api_queries))
|
||||||
|
]
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
'zerver/activity.html',
|
'zerver/activity.html',
|
||||||
|
|
Loading…
Reference in New Issue