...
 
Commits (2)
......@@ -78,7 +78,7 @@ class register implements Interfaces\Api, Interfaces\ApiIgnorePam
$hasSignupTags = false;
if (isset($_COOKIE['mexp'])) {
$manager = Core\Di\Di::_()->get('Experiments\Manager');
$bucket = $manager->getBucketForExperiment('Homepage200619');
$bucket = $manager->getBucketForExperiment('Homepage121119');
$user->expHomepage200619 = $bucket->getId();
}
......
......@@ -49,6 +49,7 @@ class experiments implements Interfaces\Api
$_COOKIE['mexp'] = $cookieid;
}
/** @var Core\Experiments\Manager $manager */
$manager = Di::_()->get('Experiments\Manager');
if (Core\Session::isLoggedIn()) {
......
......@@ -3,6 +3,7 @@
namespace Minds\Controllers\api\v2\onboarding;
use Minds\Api\Factory;
use Minds\Core\Di\Di;
use Minds\Core\Onboarding\Manager;
use Minds\Core\Session;
use Minds\Interfaces;
......@@ -11,7 +12,7 @@ class progress implements Interfaces\Api
{
/**
* Equivalent to HTTP GET method
* @param array $pages
* @param array $pages
* @return mixed|null
* @throws \Exception
*/
......@@ -23,11 +24,20 @@ class progress implements Interfaces\Api
$manager = new Manager();
$manager->setUser(Session::getLoggedInUser());
/** @var \Minds\Core\Features\Manager $manager */
$manager = Di::_()->get('Features\Manager');
if ($manager->has('onboarding-december-2019')) {
return Factory::response([
'show_onboarding' => !$manager->wasOnboardingShown(),
]);
}
$allItems = $manager->getAllItems();
$completedItems = $manager->getCompletedItems();
return Factory::response([
'show_onboarding' => !$manager->wasOnboardingShown() && count($allItems) > count($completedItems) ,
'show_onboarding' => !$manager->wasOnboardingShown() && count($allItems) > count($completedItems),
'all_items' => $allItems,
'completed_items' => $completedItems,
'creator_frequency' => $manager->getCreatorFrequency(),
......@@ -36,7 +46,7 @@ class progress implements Interfaces\Api
/**
* Equivalent to HTTP POST method
* @param array $pages
* @param array $pages
* @return mixed|null
* @throws \Exception
*/
......@@ -47,7 +57,7 @@ class progress implements Interfaces\Api
/**
* Equivalent to HTTP PUT method
* @param array $pages
* @param array $pages
* @return mixed|null
*/
public function put($pages)
......@@ -57,7 +67,7 @@ class progress implements Interfaces\Api
/**
* Equivalent to HTTP DELETE method
* @param array $pages
* @param array $pages
* @return mixed|null
*/
public function delete($pages)
......
<?php
namespace Minds\Core\Experiments\Hypotheses;
use Minds\Core\Experiments\Bucket;
class Homepage121119 implements HypothesisInterface
{
/**
* Return the id for the hypothesis
* @return string
*/
public function getId()
{
return "Homepage121119";
}
/**
* Return the buckets for the hypothesis
* @return Bucket[]
*/
public function getBuckets()
{
return [
(new Bucket)
->setId('base')
->setWeight(50),
(new Bucket)
->setId('form')
->setWeight(50),
];
}
}
......@@ -18,6 +18,7 @@ class Manager
private $experiments = [
'Homepage121118' => Hypotheses\Homepage121118::class,
'Homepage200619' => Hypotheses\Homepage200619::class,
'Homepage121119' => Hypotheses\Homepage121119::class,
];
public function __construct($sampler = null)
......@@ -49,6 +50,7 @@ class Manager
* Return the bucket for an experiment
* @param string $experimentId
* @return Bucket
* @throws \Exception
*/
public function getBucketForExperiment($experimentId)
{
......
......@@ -5,6 +5,9 @@
*/
namespace Minds\Core\Experiments;
use Minds\Core\Analytics\User;
use Minds\Core\Data\Client;
use Minds\Core\Experiments\Hypotheses\HypothesisInterface;
use Minds\Interfaces\ModuleInterface;
use Minds\Core\Di\Di;
use Minds\Core\Data\Cassandra\Prepared;
......@@ -17,7 +20,7 @@ class Sampler
/** @param User $user */
private $user;
/** @param HypthosesInterface $hypothesis */
/** @param HypothesisInterface $hypothesis */
private $hypothesis;
/** @param array $buckets */
......@@ -43,6 +46,7 @@ class Sampler
* Set the hypothesis to sample
* @param HypothesisInterface $hypothesis
* @return Sampler
* @throws \Exception
*/
public function setHypothesis($hypothesis)
{
......@@ -71,6 +75,7 @@ class Sampler
/**
* Return the bucket for a user
* @return Bucket
* @throws \Exception
*/
public function getBucket()
{
......
......@@ -921,7 +921,7 @@ CREATE TABLE minds.notifications (
CREATE MATERIALIZED VIEW minds.notifications_by_type_group AS
SELECT *
FROM minds.notifications
WHERE to_guid IS NOT NULL
WHERE to_guid IS NOT NULL
AND uuid IS NOT NULL
AND type_group IS NOT NULL
PRIMARY KEY (to_guid, type_group, uuid)
......@@ -1525,6 +1525,28 @@ CREATE TABLE minds.notification_batches (
primary key (user_guid, batch_id)
);
CREATE TABLE minds.experiments (
id text,
bucket text,
key text,
PRIMARY KEY (id, bucket, key)
) WITH CLUSTERING ORDER BY (bucket ASC, key ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
CREATE INDEX experiments_key_idx ON minds.experiments (key);
ALTER TABLE minds.withdrawals ADD (status text, address text, gas varint);
CREATE MATERIALIZED VIEW minds.withdrawals_by_status AS
......
......@@ -19,7 +19,7 @@ class ManagerSpec extends ObjectBehavior
public function it_should_return_a_list_of_experiments()
{
$this->getExperiments()->shouldHaveCount(2);
$this->getExperiments()->shouldHaveCount(3);
}
public function it_should_return_bucket_for_experiment(
......
......@@ -483,6 +483,9 @@ $CONFIG->set('features', [
'pro' => false,
'webtorrent' => false,
'top-feeds-by-age' => true,
'homepage-december-2019' => true,
'onboarding-december-2019' => true,
'register_pages-december-2019' => true,
]);
$CONFIG->set('email', [
......