Skip to content

Commit

Permalink
WIP: Pass existing experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
djarran committed Oct 17, 2024
1 parent fa8c128 commit f863565
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions classes/experiment_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ public function get_experiments() {
* Get active requests
* @return mixed
*/
public function get_active_request() {
$experiments = self::get_experiments();

public function get_active_request($experiments) {
// Filter array for only enabled session experiments.
return array_filter($experiments, function ($experiment) {
if ($experiment['enabled'] == 1 && $experiment['scope'] == 'request') {
Expand All @@ -287,8 +285,10 @@ public function get_active_request() {
* Get the active session
* @return mixed
*/
public function get_active_session() {
$experiments = self::get_experiments();
public function get_active_session($experiments = null) {
if (is_null($experiments)) {
$experiments = self::get_experiments();
}

// Filter array for only enabled session experiments.
return array_filter($experiments, function ($experiment) {
Expand Down
4 changes: 2 additions & 2 deletions classes/hook_callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static function after_config(\core\hook\after_config $hook) {
// First, Build a list of all commands that need to be executed.

// Start with request scope.
$requestexperiments = $manager->get_active_request();
$requestexperiments = $manager->get_active_request($experiments);
if (!empty($requestexperiments)) {
foreach ($requestexperiments as $record) {

Expand Down Expand Up @@ -143,7 +143,7 @@ public static function after_config(\core\hook\after_config $hook) {
}

// Now session scope.
$sessionexperiments = $manager->get_active_session();
$sessionexperiments = $manager->get_active_session($experiments);
if (!empty($sessionexperiments)) {
foreach ($sessionexperiments as $record) {
// Check if a session var has been set for this experiment, only care if has been set.
Expand Down

0 comments on commit f863565

Please sign in to comment.