Skip to content
Commits on Source (16)
......@@ -35,6 +35,12 @@ test:
script:
- bin/phpspec run
lint:
stage: test
image: minds/php-tests:latest
script:
- bin/php-cs-fixer fix --allow-risky=yes --verbose --dry-run
prepare:fpm:
stage: prepare
image: minds/ci:latest
......@@ -42,12 +48,12 @@ prepare:fpm:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- |
docker build \
-t $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF \
-t $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID \
-f containers/php-fpm/Dockerfile \
--build-arg MINDS_VERSION=$CI_BUILD_REF \
--build-arg MINDS_VERSION=$CI_PIPELINE_ID \
--build-arg SENTRY_DSN=$SENTRY_DSN \
.
- docker push $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF
- docker push $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID
prepare:runners:
stage: prepare
......@@ -56,22 +62,22 @@ prepare:runners:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- |
docker build \
-t $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF \
-t $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID \
-f containers/php-runners/Dockerfile \
--build-arg MINDS_VERSION=$CI_BUILD_REF \
--build-arg MINDS_VERSION=$CI_PIPELINE_ID \
--build-arg SENTRY_DSN=$SENTRY_DSN \
.
- docker push $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF
- docker push $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID
prepare:all:sentry:
stage: prepare
image: getsentry/sentry-cli
script:
- echo "Create a new release $CI_COMMIT_SHA"
- sentry-cli releases new $CI_COMMIT_SHA
- sentry-cli releases set-commits --auto $CI_COMMIT_SHA
- sentry-cli releases finalize $CI_COMMIT_SHA
- echo "Finalized release for $CI_COMMIT_SHA"
- echo "Create a new release $CI_PIPELINE_ID"
- sentry-cli releases new $CI_PIPELINE_ID
- sentry-cli releases set-commits --auto $CI_PIPELINE_ID
- sentry-cli releases finalize $CI_PIPELINE_ID
- echo "Finalized release for $CI_PIPELINE_ID"
review:start:
stage: review
......@@ -79,19 +85,21 @@ review:start:
script:
- aws eks update-kubeconfig --name=sandbox
- git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git
- echo "Upgrading helm for pipeline ${CI_PIPELINE_ID}"
- echo "Setting to image ${CI_REGISTRY_IMAGE}"
- "helm upgrade \
--install \
--reuse-values \
--set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \
--set phpfpm.image.tag=$CI_BUILD_REF \
--set-string phpfpm.image.tag=$CI_PIPELINE_ID \
--set runners.image.repository=$CI_REGISTRY_IMAGE/runners \
--set runners.image.tag=$CI_BUILD_REF \
--set-string runners.image.tag=$CI_PIPELINE_ID \
--set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \
--set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \
--wait \
$CI_BUILD_REF_SLUG \
./helm-charts/minds"
- sentry-cli releases deploys $CI_COMMIT_SHA new -e review-$CI_COMMIT_REF_SLUG
- sentry-cli releases deploys $CI_PIPELINE_ID new -e review-$CI_COMMIT_REF_SLUG
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
......@@ -126,17 +134,17 @@ staging:fpm:
- IMAGE_LABEL="staging"
- $(aws ecr get-login --no-include-email --region us-east-1)
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF
- docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID
# Push to AWS registry
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
# Push to Gitlab registry
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
- docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
# Deploy to staging
- aws ecs update-service --service=$ECS_APP_STAGING_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
# Update sentry
- sentry-cli releases deploys $CI_COMMIT_SHA new -e $IMAGE_LABEL
- sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL
environment:
name: staging
url: https://www.minds.com/?staging=1
......@@ -152,17 +160,17 @@ canary:fpm:
- IMAGE_LABEL="canary"
- $(aws ecr get-login --no-include-email --region us-east-1)
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF
- docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID
# Push to AWS registry
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
# Push to Gitlab registry
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
- docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
# Deploy to ECS
- aws ecs update-service --service=$ECS_APP_CANARY_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
# Update sentry
- sentry-cli releases deploys $CI_COMMIT_SHA new -e $IMAGE_LABEL
- sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL
only:
refs:
- master
......@@ -180,17 +188,17 @@ production:fpm:
- IMAGE_LABEL="production"
- $(aws ecr get-login --no-include-email --region us-east-1)
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF
- docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID
# Push to AWS registry
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL
# Push to Gitlab registry
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
- docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
# Delpoy to ECS
- aws ecs update-service --service=$ECS_APP_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
# Update sentry
- sentry-cli releases deploys $CI_COMMIT_SHA new -e $IMAGE_LABEL
- sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL
only:
refs:
- master
......@@ -199,7 +207,7 @@ production:fpm:
name: production
url: https://www.minds.com/
when: delayed
start_in: 2 hours # reduce? can always be deployed manually earlier too
start_in: 12 hours # reduce? can always be deployed manually earlier too
production:runners:
stage: deploy:production
......@@ -208,12 +216,12 @@ production:runners:
- IMAGE_LABEL="production"
- $(aws ecr get-login --no-include-email --region us-east-1)
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF
- docker pull $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID
# Push to production register
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL
# Push gitlab registry
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL
- docker push $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL
- aws ecs update-service --service=$ECS_RUNNERS_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
only:
......
......@@ -5,5 +5,10 @@ $finder = PhpCsFixer\Finder::create()
->in(__DIR__);
return PhpCsFixer\Config::create()
->fixers(['psr2', 'strict_param', 'short_array_syntax', 'no_blank_lines_after_class_opening'])
->finder($finder);
->setRules([
'@PSR2' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
'no_blank_lines_after_class_opening' => true,
])
->setFinder($finder);
......@@ -50,7 +50,7 @@ class Factory
if (!$handler instanceof Interfaces\ApiIgnorePam) {
self::pamCheck($request, $response);
}
$pages = array_splice($segments, $loop) ?: array();
$pages = array_splice($segments, $loop) ?: [];
return $handler->$method($pages);
}
}
......@@ -65,7 +65,7 @@ class Factory
if (!$handler instanceof Interfaces\ApiIgnorePam) {
self::pamCheck($request, $response);
}
$pages = array_splice($segments, $loop) ?: array();
$pages = array_splice($segments, $loop) ?: [];
return $handler->$method($pages);
}
--$loop;
......@@ -78,7 +78,7 @@ class Factory
*/
public static function pamCheck($request, $response)
{
if ( $request->getAttribute('oauth_user_id')
if ($request->getAttribute('oauth_user_id')
|| Security\XSRF::validateRequest()
) {
return true;
......@@ -89,7 +89,7 @@ class Factory
header("Access-Control-Allow-Origin: *");
header('HTTP/1.1 401 Unauthorized', true, 401);
echo json_encode([
'error' => 'Sorry, you are not authenticated',
'error' => 'Sorry, you are not authenticated',
'code' => 401,
'loggedin' => false
]);
......@@ -111,7 +111,7 @@ class Factory
header('Content-type: application/json');
header("Access-Control-Allow-Origin: *");
header('HTTP/1.1 401 Unauthorized', true, 401);
echo json_encode(array('error'=>'You are not an admin', 'code'=>401));
echo json_encode(['error'=>'You are not an admin', 'code'=>401]);
exit;
}
}
......@@ -122,7 +122,7 @@ class Factory
*/
public static function isLoggedIn()
{
if(Session::isLoggedIn()){
if (Session::isLoggedIn()) {
return true;
} else {
ob_end_clean();
......@@ -143,11 +143,11 @@ class Factory
* Builds an API response
* @param array $data
*/
public static function response($data = array())
public static function response($data = [])
{
$data = array_merge(array(
$data = array_merge([
'status' => 'success', //should success be assumed?
), $data);
], $data);
ob_end_clean();
......@@ -162,9 +162,9 @@ class Factory
* @return array - an array of the entities
* @deprecated
*/
public static function exportable($entities, $exceptions = array(), $exportContext = false)
public static function exportable($entities, $exceptions = [], $exportContext = false)
{
if(!$entities){
if (!$entities) {
return [];
}
foreach ($entities as $k => $entity) {
......
......@@ -6,7 +6,7 @@ namespace Minds\Api;
*/
class Routes
{
public static $routes = array();
public static $routes = [];
/**
* Adds a custom API route resolution
......
......@@ -61,11 +61,11 @@ class Factory
public static function toCamelNsp($namespace)
{
$namespace = explode('\\', $namespace);
$replacer = function($matches) {
$replacer = function ($matches) {
return strtoupper($matches[1]);
};
array_walk($namespace, function(&$segment) use ($replacer) {
array_walk($namespace, function (&$segment) use ($replacer) {
$segment = ucfirst(preg_replace_callback('/_([a-z])/', $replacer, $segment));
});
......
......@@ -6,7 +6,7 @@ namespace Minds\Cli;
*/
class Routes
{
public static $routes = array();
public static $routes = [];
/**
* Adds a custom CLI route resolution
......
......@@ -8,16 +8,15 @@ use Minds\Traits\MagicAttributes;
/**
* Class Cookie
* @method Cookie setName(string $name)
* @method Cookie setValue(string $value)
* @method Cookie setValue(string $value)
* @method Cookie setExpire(int $value)
* @method Cookie setPath(string $path)
* @method Cookie setDomain(string $domain)
* @method Cookie setDomain(string $domain)
* @method Cookie setSecure(bool $secure)
* @method Cookie setHttpOnly(bool $httpOnly)
*/
class Cookie
{
use MagicAttributes;
/** @var CONFIG $config */
......@@ -71,5 +70,4 @@ class Cookie
setcookie($this->name, $this->value, $this->expire, $this->path, $this->domain, $this->secure, $this->httpOnly);
$_COOKIE[$this->name] = $this->value; //set the global cookie
}
}
<?php
/**
* Converts a static class to use instances
*/
namespace Minds\Common;
class StaticToInstance
{
/** @var $class */
private $class;
public function __construct($class)
{
$this->setClass($class);
}
/**
* Set the class in question
* @return StripeStaticToOO
*/
public function setClass($class)
{
$this->class = new \ReflectionClass($class);
return clone $this;
}
/**
* Call the static functions as OO style
* @param string $method
* @param array $arguments
* @return midex
*/
public function __call($method, $arguments)
{
$instance = $this->class->newInstanceWithoutConstructor();
return $instance::$method(...$arguments);
}
}
......@@ -9,7 +9,8 @@ use Minds\Core\Di\Di;
* @todo Create a BaseController class (to be used on Api, Cli, etc) with core DI operations.
* @todo Ensure this class is used EVERYWHERE on Minds\Controllers\api
*/
class Controller {
class Controller
{
protected $di;
protected $config;
......
......@@ -34,7 +34,6 @@ class AbuseGuard extends Cli\Controller implements Interfaces\CliControllerInter
$interval = $this->getOpt('interval') ?: 5;
while (true) {
$guard->setPeriod(
time() - (60 * 60 * 10),
time()
......@@ -50,7 +49,6 @@ class AbuseGuard extends Cli\Controller implements Interfaces\CliControllerInter
sleep($interval);
}
}
public function sync_single()
......
......@@ -122,7 +122,7 @@ class Analytics extends Cli\Controller implements Interfaces\CliControllerInterf
foreach ($aggregates as $aggregate) {
$this->out("Syncing {$aggregate}");
try {
try {
$manager->sync([
'aggregate' => $aggregate,
'all' => true,
......@@ -132,7 +132,7 @@ class Analytics extends Cli\Controller implements Interfaces\CliControllerInterf
}
$this->out('Completed caching site metrics');
}
}
public function syncViews()
{
......@@ -158,5 +158,4 @@ class Analytics extends Cli\Controller implements Interfaces\CliControllerInterf
}
$this->out('Done');
}
}
......@@ -46,7 +46,7 @@ class Blockchain extends Cli\Controller implements Interfaces\CliControllerInter
if (function_exists('pcntl_signal')) {
// Intercept Ctrl+C
pcntl_signal(SIGINT, function() {
pcntl_signal(SIGINT, function () {
$this->filterCleanup();
exit;
});
......@@ -106,7 +106,6 @@ class Blockchain extends Cli\Controller implements Interfaces\CliControllerInter
}
}
}
}
usleep(500 * 1000); // 500ms
......@@ -143,24 +142,24 @@ class Blockchain extends Cli\Controller implements Interfaces\CliControllerInter
{
error_reporting(E_ALL);
ini_set('display_errors', 1);
while (true) {
$ethereum = Di::_()->get('Blockchain\Services\Ethereum');
$config = Di::_()->get('Config');
$ethRate = new EthRate;
$ethPrice = new EthPrice;
$ethPrice->setFrom(strtotime('24 hours ago'))
while (true) {
$ethereum = Di::_()->get('Blockchain\Services\Ethereum');
$config = Di::_()->get('Config');
$ethRate = new EthRate;
$ethPrice = new EthPrice;
$ethPrice->setFrom(strtotime('24 hours ago'))
->setTo(time())
->get();
$eth = round($ethPrice->getNearestPrice(strtotime('1 minute ago')));
$usd = 1.25;
$eth = round($ethPrice->getNearestPrice(strtotime('1 minute ago')));
$usd = 1.25;
$rate = round($eth/$usd);
if ($rate % 2 !== 0) {
$rate++;
}
$rate = round($eth/$usd);
if ($rate % 2 !== 0) {
$rate++;
}
$txHash = $ethereum->sendRawTransaction($config->blockchain['contracts']['token_sale_event']['rate_pkey'], [
$txHash = $ethereum->sendRawTransaction($config->blockchain['contracts']['token_sale_event']['rate_pkey'], [
'from' => $config->blockchain['contracts']['token_sale_event']['rate_address'],
'to' => $config->blockchain['contracts']['token_sale_event']['contract_address'],
'gasLimit' => BigNumber::_(200000)->toHex(true),
......@@ -170,31 +169,31 @@ while (true) {
])
]);
// Wait until mined before updating our backend
// Wait until mined before updating our backend
while (true) {
sleep(1);
$receipt = $ethereum->request('eth_getTransactionReceipt', [ $txHash ]);
echo "\n Waiting for $txHash";
if ($receipt && $receipt['status']) {
if ($receipt['status'] !== '0x1') {
echo "\n$txHash failed";
while (true) {
sleep(1);
$receipt = $ethereum->request('eth_getTransactionReceipt', [ $txHash ]);
echo "\n Waiting for $txHash";
if ($receipt && $receipt['status']) {
if ($receipt['status'] !== '0x1') {
echo "\n$txHash failed";
}
break;
}
break;
}
}
$ethRate->set($rate);
echo "\n Completed: new rate is $rate: $txHash";
echo "\n Now sleeping for one hour";
sleep(3600);
}
$ethRate->set($rate);
echo "\n Completed: new rate is $rate: $txHash";
echo "\n Now sleeping for one hour";
sleep(3600);
}
}
public function balance()
{
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_errors', 1);
$username = $this->getOpt('username');
$user = new \Minds\Entities\User($username);
......
......@@ -14,7 +14,6 @@ use Minds\Core\Rewards\Contributions\UsersIterator;
class Contributions extends Cli\Controller implements Interfaces\CliControllerInterface
{
private $start;
private $elasticsearch;
......@@ -49,7 +48,7 @@ class Contributions extends Cli\Controller implements Interfaces\CliControllerIn
$this->out("Getting rewards for all users");
$total = 0;
$total = 0;
$i = 0;
foreach ($users as $guid) {
$i++;
......@@ -120,7 +119,7 @@ class Contributions extends Cli\Controller implements Interfaces\CliControllerIn
$hash = $user->getPhoneNumberHash();
if (isset($hashes[$hash])) { //don't allow multiple phones to claim checkin
$duplicates++;
$duplicates++;
continue;
}
$hashes[$hash] = true;
......@@ -143,7 +142,7 @@ class Contributions extends Cli\Controller implements Interfaces\CliControllerIn
->setUser($checkin['user'])
->issueCheckins($checkin['amount']);
}
}
}
public function test()
{
......@@ -162,7 +161,7 @@ class Contributions extends Cli\Controller implements Interfaces\CliControllerIn
->setDryRun(true);
if ($user->guid) {
$manager->setUser($user);
$manager->setUser($user);
}
$results = $manager->sync();
......@@ -171,9 +170,8 @@ class Contributions extends Cli\Controller implements Interfaces\CliControllerIn
foreach ($results as $result) {
$totals += $result->getAmount();
$totals_by_type[$result->getMetric()] += $result->getAmount();
}
}
var_dump($totals);
var_dump($totals_by_type);
}
}
......@@ -12,7 +12,6 @@ use Minds\Core\Analytics\Iterators\SignupsOffsetIterator;
class CreateFoundersIndex extends Cli\Controller implements Interfaces\CliControllerInterface
{
public function help($command = null)
{
$this->out('TBD');
......@@ -21,7 +20,7 @@ class CreateFoundersIndex extends Cli\Controller implements Interfaces\CliContro
public function exec()
{
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_errors', 1);
$db = Di::_()->get('Database\Cassandra\Cql');
$entities_by_time = new Core\Data\Call('entities_by_time');
......@@ -34,9 +33,8 @@ class CreateFoundersIndex extends Cli\Controller implements Interfaces\CliContro
echo "\n[$i]:$user->guid";
if ($user->founder) {
echo "\n[$i]:$user->guid indexed";
$entities_by_time->insert('user:founders', [ (string) $user->guid => (string) $user->guid ]);
$entities_by_time->insert('user:founders', [ (string) $user->guid => (string) $user->guid ]);
}
}
}
}
......@@ -12,7 +12,6 @@ use Stripe;
class CustomerSync extends Cli\Controller implements Interfaces\CliControllerInterface
{
private $db;
public function __construct()
......@@ -35,7 +34,7 @@ class CustomerSync extends Cli\Controller implements Interfaces\CliControllerInt
$this->db = Di::_()->get('Database\Cassandra\Cql'); //construct not being hit?
$fo = fopen("/home/ubuntu/customers.csv", "r");
$row = 0;
while (($data = fgetcsv($fo, 10000, ",")) !== FALSE) {
while (($data = fgetcsv($fo, 10000, ",")) !== false) {
$row++;
$id = $data[0];
$guid = $data[29];
......@@ -50,9 +49,8 @@ class CustomerSync extends Cli\Controller implements Interfaces\CliControllerInt
$this->db->request($insert);
$this->out("$guid with customer id $id done");
} catch (\Exception $e) {
$this->out("$guid with customer id $id failed");
$this->out("$guid with customer id $id failed");
}
}
$this->out($count);
}
......
......@@ -34,18 +34,18 @@ class DWH extends Cli\Controller implements Interfaces\CliControllerInterface
$offset = "";
Core\Security\ACL::$ignore = false;
$i=0;
while(true){
while (true) {
echo "\n[$offset]: ";
$users = Core\Entities::get(['type'=>'user', 'limit' => $limit, 'offset'=>$offset]);
foreach($users as $user){
foreach ($users as $user) {
$i++;
$joined = date('d-m-Y h:i', $user->time_created);
echo "\n[$i/$joined]: $user->guid";
echo "\n[$i/$joined]: $user->guid";
$ts = Core\Analytics\Timestamps::get(['day', 'month'], $user->time_created);
//$db->insert("analytics:signup:day:{$ts['day']}", [$user->guid => $user->time_created]);
//$db->insert("analytics:signup:month:{$ts['month']}", [$user->guid => $user->time_created]);
}
if(count($users) < $limit/2){
if (count($users) < $limit/2) {
//break;
}
$offset = end($users)->guid;
......@@ -63,5 +63,4 @@ class DWH extends Cli\Controller implements Interfaces\CliControllerInterface
->increment();
$this->out('Done.');
}
}
......@@ -28,14 +28,13 @@ class GuidServer extends Cli\Controller implements Interfaces\CliControllerInter
$zks = 'localhost:2181';
$timer = new \Davegardnerisme\CruftFlake\Timer;
if ($machine !== NULL) {
$config = new \Davegardnerisme\CruftFlake\FixedConfig($machine);
if ($machine !== null) {
$config = new \Davegardnerisme\CruftFlake\FixedConfig($machine);
} else {
$config = new \Davegardnerisme\CruftFlake\ZkConfig($zks);
$config = new \Davegardnerisme\CruftFlake\ZkConfig($zks);
}
$generator = new \Davegardnerisme\CruftFlake\Generator($config, $timer);
$zmqRunner = new \Davegardnerisme\CruftFlake\ZeroMq($generator, $port);
$zmqRunner->run();
}
}
......@@ -62,7 +62,7 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac
try {
if ($installType == "all" || $installType == "cassandra") {
$this->out('- Provisioning Cassandra:', $this::OUTPUT_INLINE);
$this->out('- Provisioning Cassandra:', $this::OUTPUT_INLINE);
$isCleanCassandra = $this->getopt("cleanCassandra") != null;
$provisioner->provisionCassandra(null, $isCleanCassandra);
$this->out('OK');
......@@ -72,7 +72,7 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac
$this->out('OK');
}
} catch (Exception $ex) {
$this->out('Something BAD happened while provisioning Cassandra' . $ex->getMessage());
$this->out('Something BAD happened while provisioning Cassandra' . $ex->getMessage());
}
if (($installType == "all") || ($installType == "site")) {
......
......@@ -14,7 +14,6 @@ use Minds\Core\Analytics\Iterators\SignupsOffsetIterator;
class Boost extends Cli\Controller implements Interfaces\CliControllerInterface
{
private $db;
private $es;
......@@ -106,7 +105,7 @@ class Boost extends Cli\Controller implements Interfaces\CliControllerInterface
$body['@revoked'] = $export['last_updated'] * 1000;
} elseif ($boost->getState() === 'rejected') {
$body['@reviewed'] = $export['last_updated'] * 1000;
$body['@rejected'] = $export['last_updated'] * 1000;
$body['@rejected'] = $export['last_updated'] * 1000;
} elseif ($boost->getState() === 'completed') {
$body['@reviewed'] = $boost->getTimeCreated() * 1000;
$body['@completed'] = $export['last_updated'] * 1000;
......
......@@ -24,7 +24,8 @@ class Boosts extends Cli\Controller implements Interfaces\CliControllerInterface
$this->out('Syntax usage: cli migrations boosts [network|peer]');
}
public function exec() {
public function exec()
{
$this->out('Syntax usage: cli migrations boosts [network|peer]');
}
......@@ -73,7 +74,6 @@ class Boosts extends Cli\Controller implements Interfaces\CliControllerInterface
$this->out($done ? 'OK!' : 'Failed…');
}
}
}
}
......