Skip to content

Commit c2225ca

Browse files
committed
Change queue priorities
1 parent ee771ae commit c2225ca

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

www/common/AttachUser.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@
114114
}
115115
}
116116

117-
if ($user->isPaid() || $user->isApiUser()) {
118-
//calculate based on paid priority
119-
$user->setUserPriority((int)Util::getSetting('paid_priority', 0));
117+
if ($user->isApiUser()) {
118+
$user->setUserPriority((int) Util::getSetting('api_priority', 7));
119+
} else if ($user->isPaid()) {
120+
$user->setUserPriority((int) Util::getSetting('paid_priority', 6));
121+
} else if ($user->isFree()) {
122+
$user->setUserPriority((int) Util::getSetting('user_priority', 8));
120123
} else {
121-
$user->setUserPriority((int)Util::getSetting('user_priority', 0));
124+
$user->setUserPriority((int) Util::getSetting('anon_priority', 9));
122125
}
123126

124127
$user_email = $user->getEmail();

www/runtest.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
}
147147
if (array_key_exists('resubmit', $_POST)) {
148148
$test = GetTestInfo(trim($_POST['resubmit']));
149-
if (array_key_exists('key', $test)){
149+
if (array_key_exists('key', $test)) {
150150
$test['key'] = null;
151151
}
152152
if ($test) {
@@ -221,7 +221,7 @@
221221
$is_private = 0;
222222

223223
$is_private_api_call = !empty($user_api_key) && !empty($req_private) &&
224-
((int)$req_private == 1 || $req_private == 'true');
224+
((int)$req_private == 1 || $req_private == 'true');
225225
$is_private_web_call = $isPaid && ($_POST['private'] == 'on');
226226

227227
if ($is_private_api_call || $is_private_web_call) {
@@ -671,7 +671,7 @@
671671
if ((isset($test['batch']) && $test['batch']) || (isset($test['batch_locations']) && $test['batch_locations'])) {
672672
$test['priority'] = intval(GetSetting('bulk_priority', 7));
673673
} elseif ($_SERVER['REQUEST_METHOD'] == 'GET' || $xml || $json) {
674-
$test['priority'] = intval(GetSetting('api_priority', 5));
674+
$test['priority'] = intval(GetSetting('api_priority', 7));
675675
}
676676
}
677677

@@ -1628,7 +1628,7 @@ function ValidateKey(&$test, &$error, $key = null)
16281628
) {
16291629
$test['location'] = $keys[$key]['default location'];
16301630
}
1631-
$api_priority = intval(GetSetting('api_priority', 5));
1631+
$api_priority = intval(GetSetting('api_priority', 7));
16321632
$test['priority'] = $api_priority;
16331633
if (isset($keys[$key]['priority'])) {
16341634
$test['priority'] = intval($keys[$key]['priority']);
@@ -1719,9 +1719,8 @@ function ValidateKey(&$test, &$error, $key = null)
17191719
// Store the account info with the test
17201720
$test['accountId'] = $account['accountId'];
17211721
$test['contactId'] = $account['contactId'];
1722-
// success. See if there is a priority override for redis-based API tests
1723-
if (Util::getSetting('paid_priority')) {
1724-
$test['priority'] = intval(Util::getSetting('paid_priority'));
1722+
if (Util::getSetting('api_priority')) {
1723+
$test['priority'] = intval(Util::getSetting('api_priority'));
17251724
}
17261725
} else {
17271726
$error = 'The test request will exceed the remaining test balance for the given API key';
@@ -1827,9 +1826,24 @@ function ValidateParameters(&$test, $locations, &$error, $destination_url = null
18271826

18281827
// make sure on/off options are explicitly 1 or 0
18291828
$values = array(
1830-
'private', 'web10', 'ignoreSSL', 'tcpdump', 'standards', 'lighthouse',
1831-
'timeline', 'swrender', 'netlog', 'spdy3', 'noscript', 'fullsizevideo',
1832-
'blockads', 'sensitive', 'pngss', 'bodies', 'htmlbody', 'pss_advanced',
1829+
'private',
1830+
'web10',
1831+
'ignoreSSL',
1832+
'tcpdump',
1833+
'standards',
1834+
'lighthouse',
1835+
'timeline',
1836+
'swrender',
1837+
'netlog',
1838+
'spdy3',
1839+
'noscript',
1840+
'fullsizevideo',
1841+
'blockads',
1842+
'sensitive',
1843+
'pngss',
1844+
'bodies',
1845+
'htmlbody',
1846+
'pss_advanced',
18331847
'noheaders'
18341848
);
18351849
foreach ($values as $value) {
@@ -3555,7 +3569,7 @@ function CheckRateLimit($test, &$error, &$errorTitle)
35553569

35563570
$errorTemplate = "<p>Don't worry! You can keep testing for free once you log in, which will give you access to other excellent features like:</p>";
35573571
$errorTitleTemplate = "You've reached the limit for";
3558-
3572+
35593573
if (!$passesMonthly) {
35603574
$errorTitle = "{$errorTitleTemplate} this month";
35613575
$error = $errorTemplate;

www/src/User.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public function isPaid(): bool
8989
($this->payment_status == 'ACTIVE' || $this->isPendingCancelation());
9090
}
9191

92+
public function isFree(): bool
93+
{
94+
return !$this->isPaid() && !$this->isAnon();
95+
}
96+
9297
public function setPaidClient(bool $is_paid): void
9398
{
9499
$this->is_paid_cp_client = $is_paid;

0 commit comments

Comments
 (0)