本文整理汇总了PHP中Status::isCalculationInProgress方法的典型用法代码示例。如果您正苦于以下问题:PHP Status::isCalculationInProgress方法的具体用法?PHP Status::isCalculationInProgress怎么用?PHP Status::isCalculationInProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::isCalculationInProgress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$calculationInProgress = Status::isCalculationInProgress();
$elements = array();
$user = Session::get('user');
// Check for currently ongoing calculation
if ($calculationInProgress) {
$alert = Bootstrap::alert('<img src="' . Url::link('img/alert.png') . '" /> Data calculation is in progress! Reports might be slower then usual! Status: ' . Status::getCalculationStatus())->color('warning')->dismissable();
$elements[] = $alert;
}
$title = Bootstrap::h(1, 'Welcome ' . ($this->getUser('first_name') === null ? $this->getUser('username') : $this->getUser('first_name')))->secondaryText('Your timezone is <a href="' . Url::href('profile') . '">' . $user['timezone'] . '</a>, ' . Timezone::date($user['timezone'], 'M dS, H:i:s'));
$elements[] = Bootstrap::row()->add(12, $title);
// last reports row
$row = Bootstrap::row();
$minutes = 15;
$panel = Bootstrap::panel("Reports per minute in last {$minutes} minutes", new Chart\RequestsPerSecond($minutes))->color('blue');
$row->add(4, $panel);
$panel = Bootstrap::panel("Problematic apps in last {$minutes} minutes", new Chart\ProblematicApps($minutes))->color('blue');
$row->add(4, $panel);
$panel = Bootstrap::panel("Problematic brands in last {$minutes} minutes", new Chart\ProblematicBrands($minutes))->color('blue');
$row->add(4, $panel);
$elements[] = $row;
// quick reports
$row = Bootstrap::row();
// quick links
$listGroup = Bootstrap::listGroup();
foreach (Menu::getReportLinks() as $url => $text) {
$listGroup->addLink($url, $text);
}
$row->add(4, Bootstrap::panel('Quick links', $listGroup));
// countries
$panel = Bootstrap::panel("Reports from countries in last {$minutes} minutes", new Chart\ProblematicCountries($minutes))->color('blue');
$row->add(4, $panel);
// OS versions
$panel = Bootstrap::panel("OS and version in last {$minutes} minutes", new Chart\ProblematicOsVersions($minutes))->color('blue');
$row->add(4, $panel);
$elements[] = $row;
$dashboardDaysCacheKey = "DashboardDays-last-10-days-offset-0min";
if (!$calculationInProgress || Cache::has($dashboardDaysCacheKey)) {
// dahsboard last 10 days
$row = Bootstrap::row();
$row->add(12, Bootstrap::panel('Number of crash reports in last 10 days', new Chart\DashboardDays(10))->color('blue'));
$elements[] = $row;
}
return View::create('base')->with('title', 'Dashboard')->with('content', $elements);
}
示例2: terminateAjax
/**
* Manually stop the calculation (which is not recommended)
* @return \Bootstrap\Response\ButtonRemote
*/
public function terminateAjax()
{
if (Status::isCalculationInProgress()) {
Status::terminateCalculation();
Log::info("{$this->getUser('username')} requested calculation termination");
return BootstrapUI::buttonRemoteResponse()->text('Requested termination')->disableButton();
} else {
return BootstrapUI::buttonRemoteResponse()->text('Not running')->disableButton();
}
}
示例3: calculate
/**
* Calculate for reports
* @return boolean
*/
public function calculate()
{
if (Status::isCalculationInProgress()) {
Log::info('Trying to start calculation, but calculation is already in progress. Last was started on ' . Status::getLastCalculationProcessStart() . ' UTC');
return false;
}
ini_set('memory_limit', '512M');
set_time_limit(0);
Status::calculationStarted();
Status::setCalculationStatus('Initializing');
Log::info('Calculation started');
/**
* metas: 'file_path', 'build', 'environment', 'settings_global', 'settings_system', 'settings_secure',
* 'device_features', 'shared_preferences', 'initial_configuration', 'crash_configuration',
* 'dumpsys_meminfo', 'display', 'stack_trace', 'logcat', 'tktal_mem_size', '@evice_features', 'installation_id'
*/
$query = new Select();
$query->from('crash_submit')->field('id')->limit(0, 200000);
$maxQuery = CrashArchive::query()->field('MAX(created_at)', 'time');
$max = $maxQuery->fetchFirstObj();
unset($maxQuery);
$lastDatetime = new DateTime(gmdate('Y-m-d H:00:00'));
$lastDatetime->modify('-1 hour');
$query->where('created_at', '<', $lastDatetime->format('Y-m-d H:i:s'));
$ids = $query->fetchAllObj();
$sizeofIds = sizeof($ids);
Log::info('Loaded ids: ' . $sizeofIds);
$brandTotals = $countryTotals = $packageTotals = $packageVersionTotals = $phoneModelTotals = $productTotals = $providerTotals = $stackTraceTotals = $osVersionTotals = array();
foreach ($ids as $index => $r) {
// on every 25 records, we should ask ourself: is that it?
if ($index % 25 == 0) {
$shouldTerminate = Status::shouldCalcuationTerminate();
if ($shouldTerminate !== false) {
Log::info("Noticed request for calculation termination on {$shouldTerminate}. Aborted!");
Status::setCalculationStatus('Terminated after ' . ($index + 1) . ' records');
Status::terminateCalculation(false);
return false;
}
}
$id = $r->id;
// record by record
Log::info("Will now fetch id={$id}");
if ($index % 15 == 0) {
$percent = round($index / $sizeofIds * 100, 2);
Status::setCalculationStatus("Working; {$index}/{$sizeofIds} {$percent}%");
}
$submit = CrashSubmit::fetchOne($id);
if ($submit !== false && $submit->package_name !== null && trim($submit->package_name !== null) != '') {
$appStartTime = strtotime($submit->user_app_start_date);
$appCrashTime = strtotime($submit->user_crash_date);
$appLifetime = $appCrashTime - $appStartTime;
$metas = $submit->getMetas();
if ($submit->report_id !== null && trim($submit->report_id) !== '') {
$metas['report_id'] = $submit->report_id;
}
if ($submit->file_path !== null && trim($submit->file_path) !== '') {
$metas['file_path'] = $submit->file_path;
}
if ($submit->installation_id !== null && trim($submit->installation_id) !== '') {
$metas['installation_id'] = $submit->installation_id;
}
$stackTrace = $submit->stack_trace;
if ($stackTrace === null) {
$stackTraceSummary = null;
} else {
$metas['stack_trace'] = $stackTrace;
$stackTraceSummary = StackTrace::getSummary($stackTrace);
}
$packageId = $this->getPackageId($submit->package_name);
$packageVersionId = $this->getPackageVersionId($this->getPackageId($submit->package_name), $submit->app_version_name);
$brandId = $this->getBrandId($submit->brand);
$phoneModelId = $this->getModelId($this->getBrandId($submit->brand), $submit->phone_model);
$productId = $this->getProductId($this->getBrandId($submit->brand), $submit->product);
$osVersionId = $this->getOsVersion($submit->os, $submit->android_version);
$stackTraceId = $this->getStackTraceId($stackTraceSummary, $submit->created_at);
$countryId = $this->getCountryId($submit->country);
$providerId = $this->getProviderId($submit->provider);
$archive = CrashArchive::create(array('created_at' => $submit->created_at, 'package_id' => $packageId, 'package_version_id' => $packageVersionId, 'brand_id' => $brandId, 'model_id' => $phoneModelId, 'product_id' => $productId, 'os' => $submit->os, 'os_version_id' => $osVersionId, 'total_mem_size' => $submit->total_mem_size, 'available_mem_size' => $submit->available_mem_size, 'user_comment' => trim($submit->user_comment) == '' ? null : trim($submit->user_comment), 'user_email' => trim($submit->user_email) == 'N/A' ? null : trim($submit->user_email), 'user_app_start_date' => $submit->user_app_start_date, 'user_crash_date' => $submit->user_crash_date, 'user_app_lifetime' => $appLifetime, 'stack_trace_id' => $stackTraceId, 'country_id' => $countryId, 'provider_id' => $providerId));
$archive->insertMeta($metas);
// prepare increments for totals
if ($packageId !== null) {
if (!isset($packageTotals[$packageId])) {
$packageTotals[$packageId] = 0;
}
$packageTotals[$packageId]++;
}
if ($packageVersionTotals !== null) {
if (!isset($packageVersionTotals[$packageVersionId])) {
$packageVersionTotals[$packageVersionId] = 0;
}
$packageVersionTotals[$packageVersionId]++;
}
if ($brandId !== null) {
if (!isset($brandTotals[$brandId])) {
$brandTotals[$brandId] = 0;
}
//.........这里部分代码省略.........