public function run() { if (!defined('GROUP_CONTACT_REPORT_TOKEN')) { throw new Exception('Constant GROUP_CONTACT_REPORT_TOKEN not defined'); } $csvPath = "https://groups.openstack.org/reports/group-contact-report/csv?token=" . GROUP_CONTACT_REPORT_TOKEN . "&status=official"; $client = $this->getHTTPClient(); $response = $client->get($csvPath); if (200 !== $response->getStatusCode()) { throw new Exception("URL {$csvPath} returned status code: " . $response->getStatusCode()); } $csvDir = Controller::join_links(TEMP_FOLDER, 'auc-metrics'); $csvPath = $csvDir . '/group-contacts.csv'; @mkdir($csvDir); $body = $response->getBody(); // The first line of the CSV is written erroneously. Fix it. $fileData = explode(PHP_EOL, $body); $fileData[0] = "'User group','Full name','Email','Type'"; file_put_contents($csvPath, implode(PHP_EOL, $fileData)); $parser = $this->getParser($csvPath); $parser->mapColumns(['User group' => 'UserGroup', 'Full name' => 'FullName', 'Email' => 'Email', 'Type' => 'Type']); $this->results = ResultList::create(); foreach ($parser as $row) { $email = $row['Email']; $member = Member::get()->filterAny(['Email' => $email, 'SecondEmail' => $email, 'ThirdEmail' => $email])->first(); if ($member) { $this->results->push(Result::create($member)); } else { $this->logError("Member with email " . $row['Email'] . " not found"); } } unlink($csvPath); }
public function run() { $execPath = Controller::join_links(BASE_PATH, AUC_METRICS_DIR, 'lib/uc-recognition/tools/get_active_moderator.py'); $process = $this->getProcess($execPath); $process->start(); while ($process->isRunning()) { } // executes after the command finishes if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } $output = $process->getOutput(); $parts = preg_split("/((\r?\n)|(\r\n?))/", $output); $this->results = ResultList::create(); foreach ($parts as $line) { if (preg_match('/^Getting page: [0-9]+/', $line)) { continue; } preg_match('/(.*?)([0-9]+)\\s+$/', $line, $matches); if (!$matches) { continue; } $username = trim($matches[1]); $value = trim($matches[2]); $member = Member::get()->filterAny(['AskOpenStackUsername' => $username, 'Email' => $username, 'SecondEmail' => $username, 'ThirdEmail' => $username, 'IRCHandle' => $username, 'TwitterName' => $username])->first(); if ($member) { $this->results->push(Result::create($member, $value)); } else { $this->logError("Member {$username} not found."); } } }
/** * @return static */ public function run() { $this->results = ResultList::create(); $s = Summit::get_most_recent(); $chairs = $s->Categories()->relation('TrackChairs'); foreach ($chairs as $chair) { $this->results->push(Result::create($chair->Member(), implode(', ', $chair->Categories()->column('Title')))); } }
public function run() { $outputDir = Controller::join_links(TEMP_FOLDER, 'auc-metrics', 'meeting-data'); @mkdir($outputDir, 0755, true); $collectionDir = Controller::join_links($outputDir, 'eavesdrop.openstack.org/meetings'); @mkdir($collectionDir, 0755, true); $execPath = Controller::join_links(BASE_PATH, AUC_METRICS_DIR, 'lib/uc-recognition/tools/get_meeting_data.sh ' . $outputDir); $process = $this->getProcess($execPath); $process->start(); while ($process->isRunning()) { } // executes after the command finishes if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } $execPath = Controller::join_links(BASE_PATH, AUC_METRICS_DIR, 'lib/uc-recognition/tools/get_active_wg_members.py ' . $collectionDir); $process = $this->getProcess($execPath); $process->start(); while ($process->isRunning()) { } // executes after the command finishes if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } $output = $process->getOutput(); $parts = explode('OVERALL STATS', $output); $parts = preg_split("/((\r?\n)|(\r\n?))/", $parts[1]); $this->results = ResultList::create(); foreach ($parts as $line) { preg_match('/^([^=\\s]+)\\s+([0-9]+)\\s+([0-9]+)\\s*$/', $parts[1], $matches); if (!$matches) { continue; } $nickname = trim($matches[1]); $attendanceCount = trim($matches[2]); $linesSaid = trim($matches[3]); $member = Member::get()->filter('IRCHandle', $nickname)->first(); if ($member) { $this->results->push(Result::create($member, "{$attendanceCount} / {$linesSaid}")); } else { $this->logError("No member with nickname {$nickname}"); } } }
/** * @return void */ public function run() { $outputDir = Controller::join_links(TEMP_FOLDER, 'auc-metrics', 'active-committers'); @mkdir($outputDir, 0755, true); $sixMonthsAgo = date('YmdHis', strtotime('-6 months')); $user = Config::inst()->get('AUCActiveCommitterService', 'user'); $keyFile = Config::inst()->get('AUCActiveCommitterService', 'keyfile'); $execPath = Controller::join_links(BASE_PATH, AUC_METRICS_DIR, sprintf("lib/uc-recognition/tools/get_active_commiters.py %s -b %s -p %s -k %s", $user, $sixMonthsAgo, $outputDir, $keyFile)); $process = $this->getProcess($execPath); $process->start(); while ($process->isRunning()) { } // executes after the command finishes if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } $memberMap = []; $this->results = ResultList::create(); foreach (glob($outputDir . '/*.csv') as $filename) { $parser = $this->createCommitterParser($filename); foreach ($parser as $row) { $email = $row['Email']; $member = Member::get()->filterAny(['Email' => $email, 'SecondEmail' => $email, 'ThirdEmail' => $email])->first(); if ($member) { if (!isset($memberMap[$member->Email])) { $memberMap[$member->Email] = []; } $memberMap[$member->Email][] = basename($filename, '.csv'); } else { $this->logError("Member with email " . $row['Email'] . " not found"); } } unlink($filename); } foreach ($memberMap as $email => $repos) { $member = Member::get()->filter('Email', $email)->first(); if (!$member) { $this->logError("Member {$email} not found."); continue; } $this->results->push(Result::create($member, implode(', ', $repos))); } }
public function run() { $outputDir = Controller::join_links(TEMP_FOLDER, 'auc-metrics', 'meeting-data'); @mkdir($outputDir, 0755, true); $collectionDir = Controller::join_links($outputDir, 'eavesdrop.openstack.org/meetings'); @mkdir($collectionDir, 0755, true); $execPath = Controller::join_links(BASE_PATH, AUC_METRICS_DIR, 'lib/uc-recognition/tools/get_meeting_data.sh ' . $outputDir); $process = $this->getProcess($execPath); $process->start(); while ($process->isRunning()) { } if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } $execPath = Controller::join_links(BASE_PATH, AUC_METRICS_DIR, 'lib/uc-recognition/tools/get_active_wg_members.py --datadir=' . $collectionDir); $process = $this->getProcess($execPath); $process->start(); while ($process->isRunning()) { } if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } $output = $process->getOutput(); $fileData = explode(PHP_EOL, $output); $fileData[0] = "'Username','AttendanceCount','LinesSaid'"; $csvPath = Controller::join_links($outputDir, 'results.csv'); file_put_contents($csvPath, implode(PHP_EOL, $fileData)); $parser = $this->getParser($csvPath); $parser->mapColumns(['Username' => 'Username', 'AttendanceCount' => 'AttendanceCount', 'LinesSaid' => 'LinesSaid']); $this->results = ResultList::create(); foreach ($parser as $row) { $nickname = $row['Username']; $attendanceCount = $row['AttendanceCount']; $linesSaid = $row['LinesSaid']; $member = Member::get()->filter('IRCHandle', $nickname)->first(); if ($member) { $this->results->push(Result::create($member, "{$attendanceCount} / {$linesSaid}")); } else { $this->logError("No member with nickname {$nickname}"); } } }
/** * @return static */ public function run() { $this->results = ResultList::create(); $rss = new \SimplePie(); $rss->set_feed_url('http://superuser.openstack.org/feed'); $rss->init(); foreach ($rss->get_items() as $item) { $author = $item->get_author(); $members = Member::get()->where("\n \tCONCAT_WS(' ', Member.FirstName, Member.Surname) LIKE '%{$author->name}%'\n\t\t\t"); $count = (int) $members->count(); if ($count === 0) { $this->logError("Could not find member {$author}"); } else { if ($count > 1) { $this->logError("Author {$author} matched multiple Member records (" . implode(', ', $members->column('Email')) . ")"); } else { $this->results->push(Result::create($members->first(), $item->get_title())); } } } }