Commit f6be6f33 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Get rid of the temporary table that was used to generate recently

active users and projects lists; it was taking 3 seconds to generate
that table from the testbed_stats table. Switch to using newly added
last_activity slots of user_stats and project_stats tables. Now takes
less then .1 seconds ...
parent f48666b8
...@@ -314,15 +314,11 @@ sub RecentUsers() ...@@ -314,15 +314,11 @@ sub RecentUsers()
my $limit = (60 * 60 * 24) * TBGetSiteVar("general/recently_active"); my $limit = (60 * 60 * 24) * TBGetSiteVar("general/recently_active");
print "Getting Recently Active Users\n" if $debug; print "Getting Recently Active Users\n" if $debug;
if (! DBQuery("create temporary table tstat1 ".
"select distinct exptidx,uid from testbed_stats as t ".
"where ((UNIX_TIMESTAMP(now()) - ".
"UNIX_TIMESTAMP(t.end_time)) <= $limit)")) {
DBFatal("Making Recently Active Temp Table!");
}
if (! ($query_result = if (! ($query_result =
DBQuery("select distinct u.usr_email from tstat1 as t ". DBQuery("select distinct u.usr_email from user_stats as s ".
"left join users as u on u.uid=t.uid ". "left join users as u on u.uid=s.uid ".
"where ((UNIX_TIMESTAMP(now()) - ".
" UNIX_TIMESTAMP(s.last_activity)) <= $limit) ".
"order by u.usr_email"))) { "order by u.usr_email"))) {
DBFatal("Getting Recently Active Users!"); DBFatal("Getting Recently Active Users!");
} }
...@@ -344,13 +340,13 @@ sub RecentProjects() ...@@ -344,13 +340,13 @@ sub RecentProjects()
print "Getting Recently Active Projects (members)\n" if $debug; print "Getting Recently Active Projects (members)\n" if $debug;
if (! ($query_result = if (! ($query_result =
DBQuery("select distinct u.usr_email from tstat1 as t ". DBQuery("select distinct u.usr_email from project_stats as s ".
"left join experiment_stats as s on ". "left join group_membership as g on ".
" s.exptidx=t.exptidx ". " g.pid=s.pid and g.gid=g.pid ".
"left join group_membership as p ". "left join users as u on u.uid=g.uid ".
" on s.pid=p.pid and p.pid=p.gid ". "where u.status='active' and ".
"left join users as u on u.uid=p.uid ". " ((UNIX_TIMESTAMP(now()) - ".
"where u.status='active' ". " UNIX_TIMESTAMP(s.last_activity)) <= $limit) ".
"order by u.usr_email"))) { "order by u.usr_email"))) {
DBFatal("Getting Recently Active Projects!"); DBFatal("Getting Recently Active Projects!");
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment