Skip to content

Commit

Permalink
fix: consider milestone strategies in enabled false response
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogois committed Nov 28, 2024
1 parent bf2f60e commit 32c6cd4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,13 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
return a.sortOrder - b.sortOrder;
});
featureToggle.environments = featureToggle.environments.map((e) => {
e.strategies = e.strategies.sort(
(a, b) => a.sortOrder - b.sortOrder,
);
if (e.strategies && e.strategies.length === 0) {
e.enabled = false;
}
e.strategies = e.strategies
.filter(({ milestoneId }) => !milestoneId)
.map(({ milestoneId, ...strategy }) => strategy)
.sort((a, b) => a.sortOrder - b.sortOrder);
return e;
});

Expand Down Expand Up @@ -860,6 +861,7 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
id: r.strategy_id,
title: r.strategy_title,
disabled: r.strategy_disabled || false,
milestoneId: r.strategy_milestone_id,
};
if (!includeId) {
delete strategy.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ exports.up = function (db, callback) {
feature_strategies.title as strategy_title,
feature_strategies.disabled as strategy_disabled,
feature_strategies.variants as strategy_variants,
feature_strategies.milestone_id as strategy_milestone_id,
users.id as user_id,
users.name as user_name,
users.username as user_username,
users.email as user_email
FROM
features
LEFT JOIN feature_environments ON feature_environments.feature_name = features.name
LEFT JOIN (
SELECT *
FROM feature_strategies
WHERE milestone_id IS NULL
) AS feature_strategies ON feature_strategies.feature_name = feature_environments.feature_name
LEFT JOIN feature_strategies ON feature_strategies.feature_name = feature_environments.feature_name
and feature_strategies.environment = feature_environments.environment
LEFT JOIN environments ON feature_environments.environment = environments.name
LEFT JOIN feature_strategy_segment as fss ON fss.feature_strategy_id = feature_strategies.id
Expand Down

0 comments on commit 32c6cd4

Please sign in to comment.