function stats_project_weekly($group_id, $span = 8) { if (!$span) { $span = 8; } // Get information about the date $span weeks ago $begin_date = localtime(time() - $span * 7 * 86400, 1); $week = gmstrftime("%U", time() - $span * 7 * 86400); $year = $begin_date["tm_year"] + 1900; $month = sprintf("%02d", $begin_date["tm_mon"] + 1); $day = $begin_date["tm_mday"]; $sql = "SELECT month,week,AVG(group_ranking) AS group_ranking, " . "AVG(group_metric) AS group_metric, " . "SUM(downloads) AS downloads, " . "SUM(site_views + subdomain_views) AS page_views, " . "SUM(msg_posted) AS msg_posted, " . "SUM(bugs_opened) AS bugs_opened, " . "SUM(bugs_closed) AS bugs_closed, " . "SUM(support_opened) AS support_opened, " . "SUM(support_closed) AS support_closed, " . "SUM(patches_opened) AS patches_opened, " . "SUM(patches_closed) AS patches_closed, " . "SUM(tasks_opened) AS tasks_opened, " . "SUM(tasks_closed) AS tasks_closed, " . "SUM(cvs_commits) AS cvs_commits, " . "SUM(cvs_adds) AS cvs_adds " . "FROM stats_project " . "WHERE ( (( month > " . $year . "00 AND week > " . $week . " ) OR ( month > " . $year . $month . ")) " . "AND group_id = " . $group_id . " ) " . "GROUP BY month,week ORDER BY month DESC, week DESC"; // Executions will continue until morale improves. $res = db_query($sql); // if there are any weeks, we have valid data. if (($valid_weeks = db_numrows($res)) > 0) { print '<P><B>Statistics for the past ' . ($valid_weeks - 1) . ' weeks, plus the week-in-progress.</B></P>'; print '<P><TABLE width="100%" cellpadding=0 cellspacing=0 border=0>' . '<TR valign="top">' . '<TD><B>Week</B></TD>' . '<TD><B>Rank</B></TD>' . '<TD align="right"><B>Page Views</B></TD>' . '<TD align="right"><B>D/l</B></TD>' . '<TD align="right"><B>Bugs</B></TD>' . '<TD align="right"><B>Support</B></TD>' . '<TD align="right"><B>Patches</B></TD>' . '<TD align="right"><B>Tasks</B></TD>' . '<TD align="right"><B>CVS</B></TD>' . '</TR>' . "\n"; $today = time(); while ($row = db_fetch_array($res)) { $i++; $w_begin = $w_end = 0; list($w_begin, $w_end) = week_to_dates($row["week"]); //if ( $w_end > $today ) { // $w_end = $today; //} print '<TR bgcolor="' . html_get_alt_row_color($i) . '">' . '<TD>' . $row["week"] . " (" . gmstrftime("%D", $w_begin) . " -> " . strftime("%D", $w_end) . ') </TD>' . '<TD>' . sprintf("%d", $row["group_ranking"]) . " ( " . sprintf("%0.2f", $row["group_metric"]) . ' ) </TD>' . '<TD align="right">' . number_format($row["page_views"]) . '</TD>' . '<TD align="right">' . number_format($row["downloads"]) . '</TD>' . '<TD align="right"> ' . $row["bugs_opened"] . " ( " . $row["bugs_closed"] . ' )</TD>' . '<TD align="right"> ' . $row["support_opened"] . " ( " . $row["support_closed"] . ' )</TD>' . '<TD align="right"> ' . $row["patches_opened"] . " ( " . $row["patches_closed"] . ' )</TD>' . '<TD align="right"> ' . $row["tasks_opened"] . " ( " . $row["tasks_closed"] . ' )</TD>' . '<TD align="right"> ' . $row["cvs_commits"] . '</TD>' . '</TR>' . "\n"; } print '</TABLE>'; } else { echo "Project did not exist on this date."; echo db_error(); } }
} if (!span) { $span = 30; } if ($span < 4) { $span = 4; } $today = localtime(time(), 1); // // How does Uriah say it? PHEAR the date manipulation. // if ($view == "monthly") { $begin_time = mktime(0, 0, 1, $today['tm_mon'] - $span + 2, 1, $year); } elseif ($view == "weekly") { $foo = mktime(0, 0, 1, $today['tm_mon'] + 1, $today['tm_mday'] - 7 * $span, $year); list($begin_time, $bar) = week_to_dates(strftime("%U", $foo) + 1, strftime("%Y", $foo)); } else { $begin_time = mktime(0, 0, 1, $today['tm_mon'] + 1, $today['tm_mday'] - $span, $year); } $year = date("Y", $begin_time); $month = sprintf("%02d", date("m", $begin_time)); $day = date("d", $begin_time); $sql = "SELECT month,day,downloads,(site_views + subdomain_views) as views "; $sql .= "FROM stats_project "; $sql .= "WHERE ( (( month = " . $year . $month . " AND day >= " . $day . " ) OR "; $sql .= "( month > " . $year . $month . " )) AND group_id = " . $group_id . " ) "; $sql .= "GROUP BY month,day ORDER BY month,day"; $res = db_query($sql); $i = 0; while ($row = db_fetch_array($res)) { $xdata[$i] = $i;
function stats_project_weekly($group_id, $span = 8) { global $Language; $pm = ProjectManager::instance(); $grp = $pm->getProject($group_id); if (!$span) { $span = 8; } // Get information about the date $span weeks ago $begin_date = localtime(time() - $span * 7 * 86400, 1); $week = gmstrftime("%U", time() - $span * 7 * 86400); $year = $begin_date["tm_year"] + 1900; $month = sprintf("%02d", $begin_date["tm_mon"] + 1); $sql = stats_get_sql_query($group_id); $sql .= "WHERE ( (( month > " . $year . "00 AND week > " . $week . " ) OR ( month > " . $year . $month . "))"; $sql .= "AND group_id = " . $group_id . " ) "; $sql .= "GROUP BY week ORDER BY month DESC, week DESC"; // Executions will continue until morale improves. $res = db_query($sql); // if there are any weeks, we have valid data. if (($valid_weeks = db_numrows($res)) > 1) { print '<P><B>' . $Language->getText('project_stats_index', 'stats_for_past_x_weeks', $valid_weeks - 1); print '<P><TABLE width="100%" cellpadding=2 cellspacing=1 border=0>' . '<TR class="boxtable">' . '<TD class="boxtitle">' . $Language->getText('project_stats_utils', 'week_gmt') . '</TD>' . '<TD class="boxtitle">' . $Language->getText('project_stats_index', 'rank') . '</TD>'; print stats_get_table_service_header($group_id); print '</TR>' . "\n"; $today = time(); $i = 0; while ($row = db_fetch_array($res)) { $w_begin = $w_end = 0; list($w_begin, $w_end) = week_to_dates($row["week"]); //if ( $w_end > $today ) { // $w_end = $today; //} print '<TR class="' . util_get_alt_row_color($i++) . '">' . '<TD align="center">' . $row["week"] . " (" . gmstrftime("%D", $w_begin) . " -> " . gmstrftime("%D", $w_end) . ') </TD>' . '<TD align="center">' . sprintf("%d", $row["AVG(group_ranking)"]) . " ( " . sprintf("%0.2f", $row["AVG(group_metric)"]) . ' ) </TD>'; print stats_get_table_service_rows($group_id, $row); print '</TR>' . "\n"; } print '</TABLE>'; } else { echo $Language->getText('project_stats_index', 'proj_not_exist_on_date'); } }