mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
In charts, make "min" and "max" into pure functions and formally mark pure functions as pure
Summary: Depends on D20814. Currently, "min()" and "max()" are still "min(f, n)". This is no longer consistent with the construction of functions a function-generators that are composed at top level. Turn them into "min(n)" and "max(n)" (i.e., not higher-order functions). Then, mark all the functions which are pure mathematical functions and not higher-order as "pure". These functions have no function parameters and do not reference external data. For now, this distinction has no immediate implications, but it will simplify the next change (which tracks where data came from when it originated from an external source -- these pure functions never have any source information, since they only apply pure mathematical transformations to data). Test Plan: Loaded a burnup chart, nothing seemed obviously broken. Subscribers: yelirekim Differential Revision: https://secure.phabricator.com/D20815
This commit is contained in:
parent
f529abf900
commit
769e745a3f
10 changed files with 48 additions and 52 deletions
|
@ -4422,6 +4422,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectsWatchersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php',
|
'PhabricatorProjectsWatchersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php',
|
||||||
'PhabricatorPronounSetting' => 'applications/settings/setting/PhabricatorPronounSetting.php',
|
'PhabricatorPronounSetting' => 'applications/settings/setting/PhabricatorPronounSetting.php',
|
||||||
'PhabricatorProtocolLog' => 'infrastructure/log/PhabricatorProtocolLog.php',
|
'PhabricatorProtocolLog' => 'infrastructure/log/PhabricatorProtocolLog.php',
|
||||||
|
'PhabricatorPureChartFunction' => 'applications/fact/chart/PhabricatorPureChartFunction.php',
|
||||||
'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php',
|
'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php',
|
||||||
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
|
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
|
||||||
'PhabricatorQueryConstraint' => 'infrastructure/query/constraint/PhabricatorQueryConstraint.php',
|
'PhabricatorQueryConstraint' => 'infrastructure/query/constraint/PhabricatorQueryConstraint.php',
|
||||||
|
@ -9155,7 +9156,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting',
|
'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting',
|
||||||
'PhabricatorConsoleApplication' => 'PhabricatorApplication',
|
'PhabricatorConsoleApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorConsoleContentSource' => 'PhabricatorContentSource',
|
'PhabricatorConsoleContentSource' => 'PhabricatorContentSource',
|
||||||
'PhabricatorConstantChartFunction' => 'PhabricatorChartFunction',
|
'PhabricatorConstantChartFunction' => 'PhabricatorPureChartFunction',
|
||||||
'PhabricatorContactNumbersSettingsPanel' => 'PhabricatorSettingsPanel',
|
'PhabricatorContactNumbersSettingsPanel' => 'PhabricatorSettingsPanel',
|
||||||
'PhabricatorContentSource' => 'Phobject',
|
'PhabricatorContentSource' => 'Phobject',
|
||||||
'PhabricatorContentSourceModule' => 'PhabricatorConfigModule',
|
'PhabricatorContentSourceModule' => 'PhabricatorConfigModule',
|
||||||
|
@ -9167,7 +9168,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCoreCreateTransaction' => 'PhabricatorCoreTransactionType',
|
'PhabricatorCoreCreateTransaction' => 'PhabricatorCoreTransactionType',
|
||||||
'PhabricatorCoreTransactionType' => 'PhabricatorModularTransactionType',
|
'PhabricatorCoreTransactionType' => 'PhabricatorModularTransactionType',
|
||||||
'PhabricatorCoreVoidTransaction' => 'PhabricatorModularTransactionType',
|
'PhabricatorCoreVoidTransaction' => 'PhabricatorModularTransactionType',
|
||||||
'PhabricatorCosChartFunction' => 'PhabricatorChartFunction',
|
'PhabricatorCosChartFunction' => 'PhabricatorPureChartFunction',
|
||||||
'PhabricatorCountFact' => 'PhabricatorFact',
|
'PhabricatorCountFact' => 'PhabricatorFact',
|
||||||
'PhabricatorCountdown' => array(
|
'PhabricatorCountdown' => array(
|
||||||
'PhabricatorCountdownDAO',
|
'PhabricatorCountdownDAO',
|
||||||
|
@ -10068,7 +10069,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMarkupInterface',
|
'PhabricatorMarkupInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorMarkupPreviewController' => 'PhabricatorController',
|
'PhabricatorMarkupPreviewController' => 'PhabricatorController',
|
||||||
'PhabricatorMaxChartFunction' => 'PhabricatorChartFunction',
|
'PhabricatorMaxChartFunction' => 'PhabricatorPureChartFunction',
|
||||||
'PhabricatorMemeEngine' => 'Phobject',
|
'PhabricatorMemeEngine' => 'Phobject',
|
||||||
'PhabricatorMemeRemarkupRule' => 'PhutilRemarkupRule',
|
'PhabricatorMemeRemarkupRule' => 'PhutilRemarkupRule',
|
||||||
'PhabricatorMentionRemarkupRule' => 'PhutilRemarkupRule',
|
'PhabricatorMentionRemarkupRule' => 'PhutilRemarkupRule',
|
||||||
|
@ -10135,7 +10136,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMetronome' => 'Phobject',
|
'PhabricatorMetronome' => 'Phobject',
|
||||||
'PhabricatorMetronomeTestCase' => 'PhabricatorTestCase',
|
'PhabricatorMetronomeTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorMetronomicTriggerClock' => 'PhabricatorTriggerClock',
|
'PhabricatorMetronomicTriggerClock' => 'PhabricatorTriggerClock',
|
||||||
'PhabricatorMinChartFunction' => 'PhabricatorChartFunction',
|
'PhabricatorMinChartFunction' => 'PhabricatorPureChartFunction',
|
||||||
'PhabricatorModularTransaction' => 'PhabricatorApplicationTransaction',
|
'PhabricatorModularTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
'PhabricatorModularTransactionType' => 'Phobject',
|
'PhabricatorModularTransactionType' => 'Phobject',
|
||||||
'PhabricatorMonogramDatasourceEngineExtension' => 'PhabricatorDatasourceEngineExtension',
|
'PhabricatorMonogramDatasourceEngineExtension' => 'PhabricatorDatasourceEngineExtension',
|
||||||
|
@ -10950,6 +10951,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectsWatchersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
'PhabricatorProjectsWatchersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
||||||
'PhabricatorPronounSetting' => 'PhabricatorSelectSetting',
|
'PhabricatorPronounSetting' => 'PhabricatorSelectSetting',
|
||||||
'PhabricatorProtocolLog' => 'Phobject',
|
'PhabricatorProtocolLog' => 'Phobject',
|
||||||
|
'PhabricatorPureChartFunction' => 'PhabricatorChartFunction',
|
||||||
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
|
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorQuery' => 'Phobject',
|
'PhabricatorQuery' => 'Phobject',
|
||||||
'PhabricatorQueryConstraint' => 'Phobject',
|
'PhabricatorQueryConstraint' => 'Phobject',
|
||||||
|
@ -11208,7 +11210,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorSavedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhabricatorSavedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhabricatorScaleChartFunction' => 'PhabricatorChartFunction',
|
'PhabricatorScaleChartFunction' => 'PhabricatorPureChartFunction',
|
||||||
'PhabricatorScheduleTaskTriggerAction' => 'PhabricatorTriggerAction',
|
'PhabricatorScheduleTaskTriggerAction' => 'PhabricatorTriggerAction',
|
||||||
'PhabricatorScopedEnv' => 'Phobject',
|
'PhabricatorScopedEnv' => 'Phobject',
|
||||||
'PhabricatorSearchAbstractDocument' => 'Phobject',
|
'PhabricatorSearchAbstractDocument' => 'Phobject',
|
||||||
|
@ -11299,12 +11301,12 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSetupIssue' => 'Phobject',
|
'PhabricatorSetupIssue' => 'Phobject',
|
||||||
'PhabricatorSetupIssueUIExample' => 'PhabricatorUIExample',
|
'PhabricatorSetupIssueUIExample' => 'PhabricatorUIExample',
|
||||||
'PhabricatorSetupIssueView' => 'AphrontView',
|
'PhabricatorSetupIssueView' => 'AphrontView',
|
||||||
'PhabricatorShiftChartFunction' => 'PhabricatorChartFunction',
|
'PhabricatorShiftChartFunction' => 'PhabricatorPureChartFunction',
|
||||||
'PhabricatorShortSite' => 'PhabricatorSite',
|
'PhabricatorShortSite' => 'PhabricatorSite',
|
||||||
'PhabricatorShowFiletreeSetting' => 'PhabricatorSelectSetting',
|
'PhabricatorShowFiletreeSetting' => 'PhabricatorSelectSetting',
|
||||||
'PhabricatorSignDocumentsUserLogType' => 'PhabricatorUserLogType',
|
'PhabricatorSignDocumentsUserLogType' => 'PhabricatorUserLogType',
|
||||||
'PhabricatorSimpleEditType' => 'PhabricatorEditType',
|
'PhabricatorSimpleEditType' => 'PhabricatorEditType',
|
||||||
'PhabricatorSinChartFunction' => 'PhabricatorChartFunction',
|
'PhabricatorSinChartFunction' => 'PhabricatorPureChartFunction',
|
||||||
'PhabricatorSite' => 'AphrontSite',
|
'PhabricatorSite' => 'AphrontSite',
|
||||||
'PhabricatorSlackAuthProvider' => 'PhabricatorOAuth2AuthProvider',
|
'PhabricatorSlackAuthProvider' => 'PhabricatorOAuth2AuthProvider',
|
||||||
'PhabricatorSlowvoteApplication' => 'PhabricatorApplication',
|
'PhabricatorSlowvoteApplication' => 'PhabricatorApplication',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorConstantChartFunction
|
final class PhabricatorConstantChartFunction
|
||||||
extends PhabricatorChartFunction {
|
extends PhabricatorPureChartFunction {
|
||||||
|
|
||||||
const FUNCTIONKEY = 'constant';
|
const FUNCTIONKEY = 'constant';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorCosChartFunction
|
final class PhabricatorCosChartFunction
|
||||||
extends PhabricatorChartFunction {
|
extends PhabricatorPureChartFunction {
|
||||||
|
|
||||||
const FUNCTIONKEY = 'cos';
|
const FUNCTIONKEY = 'cos';
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorMaxChartFunction
|
final class PhabricatorMaxChartFunction
|
||||||
extends PhabricatorChartFunction {
|
extends PhabricatorPureChartFunction {
|
||||||
|
|
||||||
const FUNCTIONKEY = 'max';
|
const FUNCTIONKEY = 'max';
|
||||||
|
|
||||||
protected function newArguments() {
|
protected function newArguments() {
|
||||||
return array(
|
return array(
|
||||||
$this->newArgument()
|
|
||||||
->setName('x')
|
|
||||||
->setType('function'),
|
|
||||||
$this->newArgument()
|
$this->newArgument()
|
||||||
->setName('max')
|
->setName('max')
|
||||||
->setType('number'),
|
->setType('number'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDomain() {
|
|
||||||
return $this->getArgument('x')->getDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function newInputValues(PhabricatorChartDataQuery $query) {
|
|
||||||
return $this->getArgument('x')->newInputValues($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function evaluateFunction(array $xv) {
|
public function evaluateFunction(array $xv) {
|
||||||
$yv = $this->getArgument('x')->evaluateFunction($xv);
|
|
||||||
$max = $this->getArgument('max');
|
$max = $this->getArgument('max');
|
||||||
|
|
||||||
foreach ($yv as $k => $y) {
|
$yv = array();
|
||||||
if ($y > $max) {
|
foreach ($xv as $x) {
|
||||||
$yv[$k] = null;
|
if ($x > $max) {
|
||||||
|
$yv[] = null;
|
||||||
|
} else {
|
||||||
|
$yv[] = $x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorMinChartFunction
|
final class PhabricatorMinChartFunction
|
||||||
extends PhabricatorChartFunction {
|
extends PhabricatorPureChartFunction {
|
||||||
|
|
||||||
const FUNCTIONKEY = 'min';
|
const FUNCTIONKEY = 'min';
|
||||||
|
|
||||||
protected function newArguments() {
|
protected function newArguments() {
|
||||||
return array(
|
return array(
|
||||||
$this->newArgument()
|
|
||||||
->setName('x')
|
|
||||||
->setType('function'),
|
|
||||||
$this->newArgument()
|
$this->newArgument()
|
||||||
->setName('min')
|
->setName('min')
|
||||||
->setType('number'),
|
->setType('number'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDomain() {
|
|
||||||
return $this->getArgument('x')->getDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function newInputValues(PhabricatorChartDataQuery $query) {
|
|
||||||
return $this->getArgument('x')->newInputValues($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function evaluateFunction(array $xv) {
|
public function evaluateFunction(array $xv) {
|
||||||
$yv = $this->getArgument('x')->evaluateFunction($xv);
|
|
||||||
$min = $this->getArgument('min');
|
$min = $this->getArgument('min');
|
||||||
|
|
||||||
foreach ($yv as $k => $y) {
|
$yv = array();
|
||||||
if ($y < $min) {
|
foreach ($xv as $x) {
|
||||||
$yv[$k] = null;
|
if ($x < $min) {
|
||||||
|
$yv[] = null;
|
||||||
|
} else {
|
||||||
|
$yv[] = $x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class PhabricatorPureChartFunction
|
||||||
|
extends PhabricatorChartFunction {}
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorScaleChartFunction
|
final class PhabricatorScaleChartFunction
|
||||||
extends PhabricatorChartFunction {
|
extends PhabricatorPureChartFunction {
|
||||||
|
|
||||||
const FUNCTIONKEY = 'scale';
|
const FUNCTIONKEY = 'scale';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorShiftChartFunction
|
final class PhabricatorShiftChartFunction
|
||||||
extends PhabricatorChartFunction {
|
extends PhabricatorPureChartFunction {
|
||||||
|
|
||||||
const FUNCTIONKEY = 'shift';
|
const FUNCTIONKEY = 'shift';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorSinChartFunction
|
final class PhabricatorSinChartFunction
|
||||||
extends PhabricatorChartFunction {
|
extends PhabricatorPureChartFunction {
|
||||||
|
|
||||||
const FUNCTIONKEY = 'sin';
|
const FUNCTIONKEY = 'sin';
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,14 @@ final class PhabricatorProjectBurndownChartEngine
|
||||||
if ($project_phids) {
|
if ($project_phids) {
|
||||||
foreach ($project_phids as $project_phid) {
|
foreach ($project_phids as $project_phid) {
|
||||||
$function = $this->newFunction(
|
$function = $this->newFunction(
|
||||||
'min',
|
|
||||||
array(
|
array(
|
||||||
'accumulate',
|
'accumulate',
|
||||||
array('fact', 'tasks.open-count.assign.project', $project_phid),
|
array('fact', 'tasks.open-count.assign.project', $project_phid),
|
||||||
),
|
),
|
||||||
0);
|
array(
|
||||||
|
'min',
|
||||||
|
0,
|
||||||
|
));
|
||||||
|
|
||||||
$function->getFunctionLabel()
|
$function->getFunctionLabel()
|
||||||
->setName(pht('Tasks Moved Into Project'))
|
->setName(pht('Tasks Moved Into Project'))
|
||||||
|
@ -47,12 +49,14 @@ final class PhabricatorProjectBurndownChartEngine
|
||||||
$functions[] = $function;
|
$functions[] = $function;
|
||||||
|
|
||||||
$function = $this->newFunction(
|
$function = $this->newFunction(
|
||||||
'min',
|
|
||||||
array(
|
array(
|
||||||
'accumulate',
|
'accumulate',
|
||||||
array('fact', 'tasks.open-count.status.project', $project_phid),
|
array('fact', 'tasks.open-count.status.project', $project_phid),
|
||||||
),
|
),
|
||||||
0);
|
array(
|
||||||
|
'min',
|
||||||
|
0,
|
||||||
|
));
|
||||||
|
|
||||||
$function->getFunctionLabel()
|
$function->getFunctionLabel()
|
||||||
->setName(pht('Tasks Reopened'))
|
->setName(pht('Tasks Reopened'))
|
||||||
|
@ -68,20 +72,24 @@ final class PhabricatorProjectBurndownChartEngine
|
||||||
array('fact', 'tasks.open-count.create.project', $project_phid),
|
array('fact', 'tasks.open-count.create.project', $project_phid),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'max',
|
|
||||||
array(
|
array(
|
||||||
'accumulate',
|
'accumulate',
|
||||||
array('fact', 'tasks.open-count.status.project', $project_phid),
|
array('fact', 'tasks.open-count.status.project', $project_phid),
|
||||||
),
|
),
|
||||||
0,
|
array(
|
||||||
|
'max',
|
||||||
|
0,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'max',
|
|
||||||
array(
|
array(
|
||||||
'accumulate',
|
'accumulate',
|
||||||
array('fact', 'tasks.open-count.assign.project', $project_phid),
|
array('fact', 'tasks.open-count.assign.project', $project_phid),
|
||||||
),
|
),
|
||||||
0,
|
array(
|
||||||
|
'max',
|
||||||
|
0,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$function->getFunctionLabel()
|
$function->getFunctionLabel()
|
||||||
|
|
Loading…
Reference in a new issue