Commit 07de64d0 authored by Leigh Stoller's avatar Leigh Stoller

Emulab portal numbers now include classic numbers.

parent 6969a5c8
...@@ -31,37 +31,75 @@ include("quickvm_sup.php"); ...@@ -31,37 +31,75 @@ include("quickvm_sup.php");
# #
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
#
# We use the server to determine which portal.
#
$portal = $PORTAL_GENESIS;
$servername = $APTHOST;
# Include classic numbers.
if ($portal == "emulab") {
$portalclause = "(p.portal='$portal' or p.portal is null)";
}
else {
$portalclause = "(p.portal='$portal')";
}
# #
# For the Cloudlab front page, to display some current stats. # For the Cloudlab front page, to display some current stats.
# #
$blob = array(); $blob = array("active_experiments" => 0,
"total_experiments" => 0,
"projects" => 0,
"distinct_users" => 0);
# #
# Number of active experiments. # Number of active experiments.
# #
$query_result = $query_result =
DBQueryFatal("select count(uuid) from apt_instances"); DBQueryFatal("select count(uuid) from apt_instances " .
"where servername='$servername'");
if ($query_result) { if ($query_result) {
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
$blob["active_experiments"] = $row[0]; $blob["active_experiments"] = $row[0];
} }
# Add classic to emulab portal numbers,
if ($portal == "emulab") {
$query_result =
DBQueryFatal("select count(*) from experiments ".
"where geniflags=0 && state='active'");
}
if ($query_result) {
$row = mysql_fetch_array($query_result);
$blob["active_experiments"] += $row[0];
}
# #
# Number of experiments ever # Number of experiments ever
# #
$query_result = $query_result =
DBQueryFatal("select count(uuid) from apt_instance_history where servername='www.cloudlab.us'"); DBQueryFatal("select count(*) from apt_instance_history ".
"where servername='$servername'");
if ($query_result) { if ($query_result) {
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
$blob["total_experiments"] = $row[0]; $blob["total_experiments"] = $row[0];
} }
# Add classic to emulab portal numbers,
if ($portal == "emulab") {
$query_result =
DBQueryFatal("select count(*) from experiment_stats ".
"where geniflags is null");
}
if ($query_result) {
$row = mysql_fetch_array($query_result);
$blob["total_experiments"] += $row[0];
}
# #
# Number Cloudlab projects. # Number Cloudlab projects.
# #
$query_result = $query_result =
DBQueryFatal("select count(pid) from projects ". DBQueryFatal("select count(pid) from projects as p ".
"where approved=1 and portal='cloudlab'"); "where p.approved=1 and $portalclause");
if ($query_result) { if ($query_result) {
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
$blob["projects"] = $row[0]; $blob["projects"] = $row[0];
...@@ -70,19 +108,36 @@ if ($query_result) { ...@@ -70,19 +108,36 @@ if ($query_result) {
# #
# Number of users who have ever created an experiment. # Number of users who have ever created an experiment.
# #
$query_result = if ($portal == "emulab") {
DBQueryFatal("(select distinct creator from apt_instance_history) ". $query_result =
"union ". DBQueryFatal("select count(distinct creator_idx) ".
"(select distinct creator from apt_instances)"); " from experiment_stats as s ".
"left join projects as p on p.pid_idx=s.pid_idx ".
"where geniflags is null or $portalclause");
}
else {
$query_result =
DBQueryFatal("select count(*) from ".
" ((select distinct a.creator from apt_instance_history as a ".
" left join projects as p on p.pid_idx=a.pid_idx ".
" where $portalclause) ".
" union ".
" (select distinct a.creator from apt_instances as a ".
" left join projects as p on p.pid_idx=a.pid_idx ".
" where $portalclause)) as c");
}
if ($query_result) { if ($query_result) {
$blob["distinct_users"] = mysql_num_rows($query_result); $row = mysql_fetch_array($query_result);
$blob["distinct_users"] = $row[0];
} }
# #
# Number of profiles (both public and private) # Number of profiles (both public and private)
# #
$query_result = $query_result =
DBQueryFatal("select count(uuid) from apt_profiles"); DBQueryFatal("select count(profileid) from apt_profiles as a ".
"left join projects as p on p.pid_idx=a.pid_idx ".
"where $portalclause");
if ($query_result) { if ($query_result) {
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
$blob["profiles"] = $row[0]; $blob["profiles"] = $row[0];
......
Markdown is supported
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