From e6f9710032c093a5fc74bc978e8cdde01df2aed9 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 2 Dec 2003 22:04:26 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2735 --- checkin_notes | 21 ++++++++++++++++++++ db/constraints.sql | 42 ++++++++++++++++++++++++++++++++++++++-- db/schema.sql | 6 ++++++ html/forum/post.php | 4 ++-- html/forum/subscribe.inc | 20 +++++-------------- html/user/host.inc | 17 ---------------- html/user/totals.php | 28 +++++++++++++++------------ html/user/util.inc | 4 ++-- 8 files changed, 92 insertions(+), 50 deletions(-) diff --git a/checkin_notes b/checkin_notes index 35ea4fee9d..29e70ef069 100755 --- a/checkin_notes +++ b/checkin_notes @@ -8004,3 +8004,24 @@ Karl 2003-12-02 - created export-tarball program for nightly-tarball nightly-tarball + +David 28 Nov 2003 + - changed indices on result table + changed res_hostid to include id desc + removed res_wuid + added app_received_time + - removed "last result for host" info from web pages; + this required an index with no other function + - added comments to constraints.sql explaining why each index is needed + - add "subscriptions" table to schema.sql + + db/ + constraints.sql + schema.sql + html_user/ + host.inc + totals.php + util.inc + forum/ + post.php + subscribe.inc diff --git a/db/constraints.sql b/db/constraints.sql index c4b1d8ad17..75c54c059e 100644 --- a/db/constraints.sql +++ b/db/constraints.sql @@ -22,33 +22,71 @@ alter table user add unique(authenticator), add index ind_tid (teamid), add index user_tot (total_credit desc), + -- db_dump.C add index user_avg (expavg_credit desc); + -- db_dump.C alter table team add unique(name), add index team_avg (expavg_credit desc), + -- db_dump.C add index team_tot (total_credit desc); + -- db_dump.C alter table workunit add unique(name), + -- not currently used but good invariant add index wu_val (appid, need_validate), + -- validator add index wu_timeout (transition_time), + -- transitioner add index wu_filedel (file_delete_state), + -- file_deleter add index wu_assim (appid, assimilate_state); + -- assimilator alter table result add unique(name), - add index res_wuid (workunitid), + -- the scheduler looks up results by name + + //add index res_wuid (workunitid), + // -- transitioner + // -- NOTE: res_wu_user may suffice; could try dropping this one + add index ind_res_st (server_state, random), + -- feeder (random is to avoid sending WU result close together) + + add index res_app_state(appid, server_state), + -- splitter, e.g. + add index res_filedel (file_delete_state), - add index res_hostid (hostid), + -- file_deleter + + add index res_userid_id(userid, id desc), + -- html_user/results.php + + add index res_userid_val(userid, validate_state), + -- to show pending credit + + add index res_hostid (hostid, id desc), + -- html_user/results.php + add index res_wu_user (workunitid, userid), + -- scheduler (avoid sending mult results of same WU to one user) + add index app_received_time (appid, received_time desc); + -- html_ops/result_summary.php alter table host add index host_user (userid), + -- html_user/host_user.php add index host_avg (expavg_credit desc), + -- db_dump.C add index host_tot (total_credit desc); + -- db_dump.C alter table profile add unique profile_userid(userid); + +alter table subscriptions + add unique sub_unique(userid, threadid); diff --git a/db/schema.sql b/db/schema.sql index 33d1e1058c..a6ecdd402b 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -317,3 +317,9 @@ create table post ( primary key (id) ); +-- subscription to a thread +-- +create table subscriptions ( + userid integer not null, + threadid integer not null +); diff --git a/html/forum/post.php b/html/forum/post.php index c0a72edc01..ee93b02a0e 100644 --- a/html/forum/post.php +++ b/html/forum/post.php @@ -91,10 +91,10 @@ if ($category->is_helpdesk) { echo "

If you are having software problems, mention the version number of the software, - your computer type, operating system, etc. + your computer type and operating system. "; -} else { +} echo " diff --git a/html/forum/subscribe.inc b/html/forum/subscribe.inc index e6c3aea5f6..c50d18452e 100644 --- a/html/forum/subscribe.inc +++ b/html/forum/subscribe.inc @@ -13,16 +13,6 @@ function subscribe($thread, $user=null) { $user = get_logged_in_user(true, '../'); } - $sql = "SELECT * FROM subscriptions WHERE (userid = " . $user->id . ") AND (threadid = " . $thread->id . ")"; - $result = mysql_query($sql); - - // If they're already subscribed, don't add them again; - if (mysql_num_rows($result) > 0) { - // TODO: Specific "error" page for this case. - show_result_page("subscribe", true, $thread); - exit(); - } - $sql = "INSERT INTO subscriptions SET userid = " . $user->id . ", threadid = " . $thread->id; show_result_page("subscribe", (mysql_query($sql) != null), $thread); } @@ -47,11 +37,11 @@ function show_result_page($action, $success, $thread) { echo "

You are now subscribed to ", stripslashes($thread->title), ". You will receive an email whenever another user posts to this thread.

"; } else if ($action == "unsubscribe" && $success) { page_head("Unsubscription Successful"); - echo "Unsubscription successful"; + echo "Unsubscription successful"; echo "

You have successfully unsubscribed from ", stripslashes($thread->title), ". You will no longer receive emails for posts to this thread.

"; } else if ($action == "subscribe" && !$success) { page_head("Subscription Failed"); - echo "Subscription failed"; + echo "Subscription failed"; if ($thread) { echo "

There was a problem subscribing you to ", stripslashes($thread->title), ". Please try again later.

"; } else { @@ -88,7 +78,7 @@ function notify_subscribers($threadID) { } function send_notice_email($userId, $threadID) { - $thread = getThread($threadID); + $thread = getThread($threadID); $result = mysql_query("SELECT * FROM user WHERE id = $userId"); $row = mysql_fetch_assoc($result); @@ -96,9 +86,9 @@ function send_notice_email($userId, $threadID) { $title = PROJECT . ": A user has posted to your subscribed thread."; $link = URL_BASE . "forum/thread.php?id=" . $threadID; $body = "Another " . PROJECT . " user has posted to the thread \"" . stripslashes($thread->title) . "\".\n" - ."To view the updated thread, direct your web browser to the following URL:\n\n$link"; + ."To view the updated thread, visit the following URL:\n\n$link"; mail($row['email_addr'], $title, $body); } -?> \ No newline at end of file +?> diff --git a/html/user/host.inc b/html/user/host.inc index 341a7ea09b..7291aecf81 100644 --- a/html/user/host.inc +++ b/html/user/host.inc @@ -76,15 +76,10 @@ function show_host($host, $private) { } else { row2("Average download rate", "Unknown"); } - $last_result = host_last_result($host); $nresults = host_nresults($host); $nresults_success = host_nresults_success($host); $nresults_valid = host_nresults_valid($host); $results = "$nresults_valid valid / $nresults_success successful / id>$nresults total"; - if ($last_result) { - $time_last_result = time_str($last_result->received_time); - $results .= "
Last received: $time_last_result"; - } row2("Results", $results); if ($private) { @@ -126,13 +121,6 @@ function host_table_start($title, $private) { "; } -function host_last_result($host) { - $result = mysql_query("select * from result where hostid = $host->id order by received_time desc limit 1"); - $last_result = mysql_fetch_object($result); - mysql_free_result($result); - return $last_result; -} - function host_nresults($host) { $result = mysql_query("select count(*) as nresults from result where hostid=$host->id"); $foobar = mysql_fetch_object($result); @@ -184,15 +172,10 @@ function show_host_row($host, $i, $private) { $host->os_name, $host->os_version ); - $last_result = host_last_result($host); $nresults = host_nresults($host); $nresults_success = host_nresults_success($host); $nresults_valid = host_nresults_valid($host); echo "$nresults_valid / $nresults_success / id>$nresults"; - if ($last_result) { - $date_last_result = date_str($last_result->received_time); - echo " [$date_last_result]"; - } echo "\n"; } diff --git a/html/user/totals.php b/html/user/totals.php index 60826a6360..f12b2eae5f 100644 --- a/html/user/totals.php +++ b/html/user/totals.php @@ -9,20 +9,24 @@ start_table(); row1("Project totals"); - $result = mysql_query("select count(*) as total from result where server_state=5"); - $comp = mysql_fetch_object($result); - mysql_free_result($result); - row2("Results completed", $comp->total); + // need to break out the following by app - $result = mysql_query("select count(*) as total from result where server_state=4"); - $comp = mysql_fetch_object($result); - mysql_free_result($result); - row2("Results in progress", $comp->total); + if (0) { + $result = mysql_query("select count(*) as total from result where server_state=5"); + $comp = mysql_fetch_object($result); + mysql_free_result($result); + row2("Results completed", $comp->total); - $result = mysql_query("select count(*) as total from result where server_state=2"); - $comp = mysql_fetch_object($result); - mysql_free_result($result); - row2("Results waiting to send", $comp->total); + $result = mysql_query("select count(*) as total from result where server_state=4"); + $comp = mysql_fetch_object($result); + mysql_free_result($result); + row2("Results in progress", $comp->total); + + $result = mysql_query("select count(*) as total from result where server_state=2"); + $comp = mysql_fetch_object($result); + mysql_free_result($result); + row2("Results waiting to send", $comp->total); + } $result = mysql_query("select count(*) as total from user"); $comp = mysql_fetch_object($result); diff --git a/html/user/util.inc b/html/user/util.inc index 369cb4f9fc..e3d2605bc8 100644 --- a/html/user/util.inc +++ b/html/user/util.inc @@ -60,8 +60,8 @@ function get_profile_from_userid($userid) { return null; } -// $pathMod is a prefix for the path of the login processing form. This -// allows scripts in other directories (i.e. forum/) to call this function. +// $pathMod is a prefix for the path of the login processing form. +// This allows scripts in other directories (i.e. forum/) to call this function. function get_logged_in_user($must_be_logged_in=true, $pathMod="") { $authenticator = init_session();