| <?php |
| /** |
| * Copyright (c) Eclipse Foundation and others. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| */ |
| require_once dirname ( __FILE__ ) . '/../../eclipse.org-common/system/app.class.php'; |
| require_once dirname ( __FILE__ ) . '/../../eclipse.org-common/system/nav.class.php'; |
| require_once dirname ( __FILE__ ) . '/../../eclipse.org-common/system/menu.class.php'; |
| $App = new App (); |
| $Nav = new Nav (); |
| $Menu = new Menu (); |
| include ($App->getProjectCommon ()); |
| |
| require_once dirname ( __FILE__ ) . '/../classes/Project.class.php'; |
| require_once dirname ( __FILE__ ) . '/../classes/debug.php'; |
| require_once dirname ( __FILE__ ) . '/../classes/database.inc'; |
| |
| $pageTitle = "Future Eclipse Project Releases"; |
| $pageKeywords = ""; |
| $pageAuthor = "Wayne Beaton"; |
| |
| /* |
| * Lightweight representation of a release to let us work with release |
| * data in an abstract manner. |
| */ |
| class Release { |
| var $project; |
| var $name; |
| var $date; |
| function __construct(Project $project, $name, $date) { |
| $this->project = $project; |
| $this->name = $name; |
| $this->date = $date; |
| } |
| function getId() { |
| return $this->project->getId (); |
| } |
| function getUrl() { |
| return $this->project->getUrl (); |
| } |
| function getName() { |
| return $this->project->getFormalName () . ' ' . $this->name; |
| } |
| function getDate() { |
| return $this->date; |
| } |
| } |
| |
| /** |
| * Answers an array containing information about future releases. |
| * The array that gets returned maps review dates to a collection of |
| * releases that will be concluded on the date. |
| * |
| * @return array|Release |
| */ |
| function getFutureReleases() { |
| $releases = array (); |
| |
| /* |
| * The ProjectReleases table in the dashboard database contains |
| * a cache of the release information. This cache is generated by |
| * the /capture/php/projects.php script in the project-services |
| * repository. |
| */ |
| $sql = " |
| select |
| project as id, name, date |
| from ProjectReleases |
| where date > date(now()) |
| order by date"; |
| |
| query ( 'dashboard', $sql, array (), function ($row) use (&$releases) { |
| if ($project = Project::getProject ( $row ['id'] )) { |
| $name = $row ['name']; |
| $date = strtotime ( $row ['date'] ); |
| $reviewDate = getProbableReviewDate ( $date ); |
| $releases [$reviewDate] [] = new Release ( $project, $name, $date ); |
| } |
| } ); |
| |
| return $releases; |
| } |
| |
| /** |
| * Write HTML describing the future releases. |
| */ |
| function dumpFutureReleases() { |
| foreach ( getFutureReleases () as $date => $releases ) { |
| echo "<h3>" . ($date == 0 ? "It's already too late" : ("For review on " . date ( 'Y-m-d', $date ))) . "</h3>"; |
| echo "<ul>"; |
| foreach ( $releases as $release ) { |
| echo "<li><a href=\"{$release->getUrl()}\">{$release->getName()}</a> "; |
| echo date ( 'Y-m-d', $release->getDate () ); |
| dumpOpenCQs ( $release ); |
| echo "</li>"; |
| } |
| echo "</ul>"; |
| } |
| } |
| |
| /** |
| * Write an HTML unordered list of all open CQs for the project |
| * that owns the release. |
| * |
| * @param Release $release |
| */ |
| function dumpOpenCQs(Release $release) { |
| echo "<ul>"; |
| |
| /* |
| * Query IPZilla directly to get the list of open CQs |
| * associated with the release. |
| */ |
| $sql = ' |
| select |
| b.bug_id as id, b.short_desc as title |
| from bugs as b |
| join components as c on b.component_id=c.id |
| where c.name=\'$id\' |
| and bug_status in (\'NEW\', \'REOPENED\')'; |
| |
| query ( 'ipzilla', $sql, array ('$id' => $release->getId ()), function ($row) { |
| $id = $row ['id']; |
| $title = $row ['title']; |
| echo "<li><a target=_blank href=\"https://dev.eclipse.org/ipzilla/show_bug.cgi?id=$id\">$id</a> $title</li>"; |
| } ); |
| echo "</ul>"; |
| } |
| |
| /** |
| * We run reviews twice each month, concluding on the first and |
| * third Wednesdays. |
| * A review must conclude before the release, so |
| * the returned date should be the release date or earlier. |
| * |
| * Given a UNIX date (int), this function sorts out the probable |
| * review date. |
| * |
| * TODO Refactor: move this function to a shared import. |
| * |
| * @param int $date |
| * UNIX date of a release. |
| * @return int probable UNIX date of the corresponding review. |
| */ |
| function getProbableReviewDate($date) { |
| |
| // Find the Wednesday that occurs on or before |
| // the provided date. |
| $diff = date ( 'w', $date ) - 3; // '3' means Wednesday |
| if ($diff < 0) |
| $diff += 7; |
| $date = strtotime ( "-$diff days", $date ); |
| |
| // Walk backwards week-by-week to find a Wednesday |
| // that is either the first or third Wednesday of |
| // the month. There's probably some date property |
| // that can give us this with a calculation, but |
| // this won't iterate more than a couple of times, |
| // and so is a good enough solution. |
| while ( true ) { |
| if (isFirstOrThirdWeek ( $date )) { |
| return $date; |
| } |
| $date = strtotime ( "-1 week", $date ); |
| } |
| return 0; |
| } |
| |
| /** |
| * Answers whether the provided date occurs in the first |
| * or third week of the month. |
| * |
| * @param int $date UNIX date |
| * @return bool true if the date occurs in the first or third week, or false otherwise. |
| */ |
| function isFirstOrThirdWeek($date) { |
| $day = date ( 'j', $date ) - 1; // 0-based day of the month |
| if (floor ( $day / 7 ) == 0) |
| return true; // first week |
| if (floor ( $day / 7 ) == 2) |
| return true; // third week |
| return false; |
| } |
| |
| ob_start (); |
| ?> |
| <div id="maincontent"> |
| <div id="midcolumn"> |
| <h1><?=$pageTitle?></h1> |
| <p> |
| <strong>EXPERIMENTAL</strong>. This page shows a list of upcoming |
| releases and—where they exist—corresponding lists of open |
| intellectual property review requests (CQs). Note that the CQs are |
| associated with the projects, not with any particular release. This |
| is for informational purposes only. |
| </p> |
| |
| <?php dumpFutureReleases(); ?> |
| |
| </div> |
| </div> |
| |
| <?php |
| $html = ob_get_contents (); |
| ob_end_clean (); |
| $App->generatePage ( $theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html ); |
| ?> |