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:
Steve Howell 2013-10-01 21:19:40 -04:00
parent 374a64acf8
commit 786c2cf759
2 changed files with 22 additions and 38 deletions

View File

@ -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):
""" """

View File

@ -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,7 +1794,6 @@ 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,
@ -1806,18 +1802,6 @@ class ActivityTable(object):
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:
if 'pointer' in query_name: if 'pointer' in query_name:
@ -1940,12 +1924,12 @@ 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 += [ ]
else:
data = [
('Website', ActivityTable(realm, 'website', web_queries)), ('Website', ActivityTable(realm, 'website', web_queries)),
('Mirror', ActivityTable(realm, 'zephyr_mirror', api_queries)), ('Mirror', ActivityTable(realm, 'zephyr_mirror', api_queries)),
('Desktop', ActivityTable(realm, 'desktop', web_queries)), ('Desktop', ActivityTable(realm, 'desktop', web_queries)),