| <?php |
| /******************************************************************************* |
| * Copyright (c) 2016 Eclipse Foundation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Wayne Beaton - initial API and implementation |
| *******************************************************************************/ |
| |
| /** |
| * Get the ids of the projects that are involved in the simultaneous release. |
| */ |
| function getProjectIds($release = 'neon') { |
| $url = "http://projects.eclipse.org/json/release/$release"; |
| $ch = curl_init(); |
| curl_setopt($ch,CURLOPT_URL,$url); |
| curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); |
| $json = curl_exec($ch); |
| curl_close($ch); |
| |
| $simrels = json_decode($json, true); |
| |
| $ids = array(); |
| |
| foreach($simrels as $name=>$simrel){ |
| $sr0 = $simrel['date']; |
| foreach($simrel['projects'] as $project) { |
| $ids[]=$project['id']; |
| foreach($project['releases'] as $release) { |
| foreach($release['subprojects'] as $id) { |
| $ids[] = $id; |
| } |
| } |
| } |
| } |
| $ids = array_unique($ids, SORT_REGULAR); |
| return "'" . join($ids, "','") . "'"; |
| } |
| |
| /** |
| * Answers the committer ids for all members of the architecture council in |
| * a string suitable for inclusion in an SQL list. |
| * |
| * @return string |
| */ |
| function getCouncilMemberIds() { |
| global $App; |
| $sql = " |
| select distinct PersonId as id |
| from ( |
| (select PersonId from PeopleProjects where relation in ('RA', 'RP') and not InactiveDate) |
| union (select PersonId from OrganizationContacts where relation in ('AC', 'PC')) |
| union (select PersonId from PeopleRelations where relation in ('AZ', 'EA', 'PZ', 'EP')) |
| ) as members"; |
| |
| $result = $App->foundation_sql($sql); |
| |
| while ($row=mysql_fetch_assoc($result)) { |
| $id = $row['id']; |
| $ids[] = "'$id'"; |
| } |
| |
| return join(',', $ids); |
| } |
| |
| |
| /** |
| * Answers the names of all the previous winners in a string suitable |
| * for inclusion in an SQL list. If you've won before, you can't win again. |
| * |
| * @return string |
| */ |
| function getPreviousWinnerNames() { |
| return " |
| 'Andrey Loskutov', 'Mateusz Matela', 'John Glassmyer', |
| 'Snjezana Peco', 'Tomasz Zarna', 'Dirk Fauth', |
| 'Tony McCrary', 'Robert Roth', 'Fabio Zadrozny', 'Simon Scholz' |
| "; |
| } |
| |
| /** |
| * Answers an SQL query to pull out the candidate commits. |
| * |
| * FIXME Hard-codes the "since" date. |
| */ |
| function getCommitsSql() { |
| //$projects = getProjectIds(); |
| $council = getCouncilMemberIds(); |
| $previous = getPreviousWinnerNames(); |
| $projects = getProjectIds(); |
| |
| return " |
| select |
| distinct gca.name, gr.project, gca.email, ce.id, |
| gc.path, |
| gc.ref, |
| gc.date, |
| gc.comment, |
| sum(added) as added, |
| sum(removed) as removed, |
| sum(added) - sum(removed) as netloc |
| from ProjectRollup as pr |
| join GitRepo as gr on pr.subproject=gr.project |
| join GitCommit as gc on gr.path=gc.path |
| join GitCommitFile as gcf on gc.ref=gcf.ref |
| join GitCommitAuthor as gca on gc.ref=gca.ref |
| left join CommitterEmail as ce on gca.email=ce.email |
| left join (select id, min(activeDate) as activeDate, max(inactiveDate) as inactiveDate from CommitterProject group by id) as cp |
| on cp.id=ce.id |
| and gc.date between cp.activeDate and cp.inactiveDate |
| where cp.id is null |
| and gc.date > date('2015-06-24') |
| and gc.path not like '/gitroot/www.eclipse.org/%' |
| and gr.project in ($projects) |
| and gca.name not in ('e4Build') |
| and gca.name not in ('Eclipse Webmaster team', $previous) |
| and (ce.id is null or ce.id not in ($council)) |
| group by gc.ref |
| "; |
| } |
| |
| function getCandidates($sort = true) { |
| global $App; |
| |
| $ide = "'tools.cdt', 'tools.pdt', 'technology.egit', 'technology.jgit', 'technology.recommenders', |
| 'tools.andmore', 'technology.m2e','tools.buildship', |
| 'rt.equinox','rt.equinox.p2','rt.equinox.framework','rt.equinox.bundles', |
| 'tools.oomph','technology.subversive'"; |
| |
| $result = $App->dashboard_sql(" |
| select |
| name, project, email, id, |
| path, ref, date, comment, added, removed, netloc, |
| if (project like 'eclipse.%' |
| or project like 'webtools.%' |
| or project in ($ide), 'IDE', 'Other') as type |
| from GreatFixCandidates"); |
| |
| $commits = array(); |
| while ($row=mysql_fetch_assoc($result)) { |
| $commits[$row['name']][] = new Commit($row); |
| } |
| return new Candidates($commits, $sort); |
| } |
| |
| |
| |
| |
| function getPriorityBugs () { |
| global $_priorityBugs; |
| |
| if (! $_priorityBugs) { |
| // $gtkUrl = |
| // "https://bugs.eclipse.org/bugs/buglist.cgi?classification=Eclipse&component=SWT&list_id=13844519&product=Platform&query_format=advanced&short_desc=%5Bgtk3%5D&short_desc_type=allwordssubstr&ctype=csv&human=1&columnlist=bugId"; |
| // $gtkBugs = explode(PHP_EOL, file_get_contents($gtkUrl)); |
| |
| $_priorityBugs = array( |
| // GTK3 Bugs |
| // https://bugs.eclipse.org/bugs/show_bug.cgi?id=479686 |
| 15 => array( |
| 441568,467499,485906,477950,482447,431160,465280, |
| 484463,477628,470872,461354,459834,475025,436529,470991, |
| 470515,481851,457909,465660,464816,408266,480447,421127, |
| 437416,473896,427487,468208,477099,467308,463937,396493, |
| 481104,462009,463733,436529,431890,429385,436098,479037, |
| 486334,480243,469323,434561,485672,475025,436687,470308, |
| 472308,464228,461616,480292,399560,397107,399548,473369, |
| 477599,465195,470944,435799,429086,454940,453827,454936, |
| 457476,463041,485808,474104,424596,442223,423870,484729, |
| 470994,478962,393728,434908,456349,458629,485444,479242, |
| 393729,483304,437691,436841,479998,440116,422940,399522, |
| 396305,458633,396303,485442,462525,486068,465636,436910, |
| 487059,463137,431160,471160,478447,480911,478442,404448, |
| 392784,474628,441566,480889,485906,486302,480926,465310, |
| 407374,406808,458630,396324,436211,467977,465644,486316, |
| 467499,399545,392700,439884,471437,427776,469126,396320, |
| 436655,471492,471632,478165,485447,465178,484213,434895, |
| 460935,417601,477197,464705,484463,420771,486048,392786, |
| 392774,392785,392841,392839,484772,422316,456556,465309, |
| 434883,471125,484849,487467,465280,472488,393724,483998, |
| 461251,480032,472533,403102,441568,477950,340067,486368, |
| 483910,482915,404062,472518,483414,438505,403474,437566, |
| 487271,460937,399562,460936,471721,484497,474800,469027, |
| 470220,472539,472403,469521,470298,472098,469333,472377, |
| 471831,476143,399543,461073,463783,478915,425999,485579, |
| 393793,426694,393727,411452,483791,404163,483848,441148, |
| 393792,465863,479035,399564,474632,421836,435742,470031, |
| 470129,480335,479274,431162,459834,478838,428852,460141, |
| 461041,403887,486235,423220,480794,428170,482756,458844, |
| 457196,396316,441063,441068,398176,485681,466386,466314, |
| 398748,472416,468990,470991,399551,482146,465056,456345, |
| 469277,468037,476419,476441,483112,396313,483706,408363, |
| 460938,464230,460934,420180,482447,434898,393726,413950, |
| 471461,476562,396306,399547,432115,466396,460932,463561, |
| 393723,466515,465911,446075,435773,472352,468868,431421, |
| 427511,427480,459117,465054,466499,466360,431425,431423, |
| 431426,424891,480261,472517,483545,465107,458781,476823, |
| 467664,431330,484794 |
| ), |
| // Allow user to discover plugins to edit a specific type of |
| // file |
| // https://bugs.eclipse.org/bugs/show_bug.cgi?id=480176 |
| 14 => array(90292 |
| ), |
| // MAC SWT Port Bugs |
| // https://bugs.eclipse.org/bugs/show_bug.cgi?id=482409 |
| 13 => array(366471,383750,478975,467205,471717,395381,480852 |
| ), |
| // Improve the Dark Theme |
| // https://bugs.eclipse.org/bugs/show_bug.cgi?id=481227 |
| 2 => array(23837,430278,384906 |
| ) |
| ); |
| } |
| |
| return $_priorityBugs; |
| } |
| |
| function getBugWeight($bugId) { |
| foreach(getPriorityBugs() as $index=>$ids) { |
| if (in_array($bugId, $ids)) return $index; |
| } |
| return 1; |
| } |
| |
| class Candidates { |
| var $data = array(); |
| |
| function __construct($data, $sort=true) { |
| foreach($data as $name => $commits) { |
| $this->data[$name] = new Candidate($name, $commits); |
| } |
| if ($sort) usort($this->data, array('Candidates', 'sortByWeight')); |
| } |
| |
| function getCandidates() { |
| return $this->data; |
| } |
| |
| static function sortByWeight($a, $b) { |
| $ia = $a->isIde(); |
| $ib = $b->isIde(); |
| |
| if ($ia && !$ib) return -1; |
| if (!$ia && $ib) return 1; |
| |
| $wa = $a->getWeight(); |
| $wb = $b->getWeight(); |
| |
| if ($wa == $wb) return 0; |
| return $wa < $wb ? 1 : -1; |
| } |
| } |
| |
| class Candidate { |
| var $name; |
| var $commits; |
| |
| function __construct($name, $commits) { |
| $this->name = $name; |
| $this->commits = $commits; |
| } |
| |
| function getName() { |
| return $this->name; |
| } |
| |
| function getEmails() { |
| $emails = array(); |
| foreach($this->commits as $commit) { |
| $emails[$commit->getEmail()] = true; |
| } |
| return array_keys($emails); |
| } |
| |
| function getEmail() { |
| return $this->commits[1]->data['email']; |
| } |
| |
| function isMember() { |
| $patterns = array( |
| '/\@redhat\.com$/','/\@tasktop\.com/', '/\@cea\.fr$/', '/\@all4tec\.net$/', |
| '/\@bsi-software\.com$/', '/\@bsiag\.com$/', '/\@.+\.ibm.com$/', '/\@itemis\.de$/', |
| '/\@ericsson\.com$/', '/\@obeo\.fr$/', '/\@sodifrance\.fr$/', |
| '/\@windriver\.com$/', '/\@eclipsesource\.com$/', '/\@opentext\.com$/', |
| '/\@blackberry\.com$/', '/\@google\.com$/', '/\@codetrails\.com$/', '/\@xored\.com$/', |
| '/\@actuate\.com$/', '/\@zend\.com$/', '/\@kichwacoders\.com$/' |
| ); |
| |
| foreach($patterns as $pattern) { |
| if (preg_match($pattern, $this->getEmail())) return true; |
| } |
| return false; |
| } |
| |
| function isIde() { |
| foreach($this->commits as $commit) if ($commit->isIde()) return true; |
| return false; |
| } |
| |
| function getWeight() { |
| $weight = 0; |
| foreach($this->commits as $commit) $weight += $commit->getWeight(); |
| |
| foreach($this->getBugIds() as $bugId) { |
| $weight += getBugWeight($bugId); |
| } |
| |
| //if (!$this->isMember()) $weight += 200; |
| |
| return $weight; |
| } |
| |
| function getCommits() { |
| return $this->commits; |
| } |
| |
| function getSummary() { |
| $projects = array(); |
| foreach($this->commits as $commit) { |
| $project = $commit->getProject(); |
| $projects[$project]++; |
| } |
| foreach($projects as $id => $count) |
| $parts[] = "$id ($count)"; |
| return join(', ', $parts); |
| } |
| |
| function getBugIds() { |
| $bugs = array(); |
| foreach($this->commits as $commit) { |
| if ($id = $commit->getBugId()) $bugs[$id] = 1; |
| } |
| return array_keys($bugs); |
| } |
| } |
| |
| class Commit { |
| var $data; |
| |
| function __construct($data) { |
| $this->data = $data; |
| } |
| |
| function getAuthor() { |
| return $this->data['name']; |
| } |
| |
| function getEmail() { |
| return $this->data['email']; |
| } |
| |
| function getComment() { |
| return $this->data['comment']; |
| } |
| |
| function getBugId() { |
| if (preg_match('/^(?:Bug )?\[?(\d+)\]?/', $this->getComment(), $matches)) |
| return $matches[1]; |
| return null; |
| } |
| |
| function getRef() { |
| return $this->data['ref']; |
| } |
| |
| function getProject() { |
| return $this->data['project']; |
| } |
| |
| function getId() { |
| return substr($this->getRef(),0,6); |
| } |
| |
| function getLink() { |
| $path = $this->data['path']; |
| $ref = $this->getRef(); |
| if (preg_match('/^\/gitroot\/(.*)$/', $path, $matches)) { |
| $path = $matches[1]; |
| return "https://git.eclipse.org/c/$path/commit/?id=$ref"; |
| } |
| return $path; |
| } |
| |
| function getLinesAdded() { |
| return $this->data['added']; |
| } |
| |
| function getLinesRemoved() { |
| return $this->data['removed']; |
| } |
| |
| function getNetLOC() { |
| return $this->data['netloc']; |
| } |
| |
| function getType() { |
| return $this->data['type']; |
| } |
| |
| function isIde() { |
| return $this->getType() == 'IDE'; |
| } |
| |
| function getWeight() { |
| |
| // $bugId = (int)$this->getBugId(); |
| // foreach(getPriorityBugs() as $index=>$ids) { |
| // if (in_array($bugId, $ids)) return $index; |
| // } |
| |
| // if (preg_match('/\[gtk3\]/i', $this->getComment())) return 15; |
| |
| return 1; |
| } |
| |
| } |