Skip to content

Commit

Permalink
chore: remove featureSearchAPI flag (#6081)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus committed Jan 31, 2024
1 parent aae1d05 commit d7eb950
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 72 deletions.
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Expand Up @@ -64,7 +64,6 @@ export type UiFlags = {
doraMetrics?: boolean;
dependentFeatures?: boolean;
scheduledConfigurationChanges?: boolean;
featureSearchAPI?: boolean;
newStrategyConfiguration?: boolean;
incomingWebhooks?: boolean;
automatedActions?: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -95,7 +95,6 @@ exports[`should create default config 1`] = `
"executiveDashboard": false,
"extendedUsageMetrics": false,
"extendedUsageMetricsUI": false,
"featureSearchAPI": true,
"featureSearchFeedback": false,
"featureSearchFeedbackPosting": false,
"featuresExportImport": true,
Expand Down
122 changes: 59 additions & 63 deletions src/lib/features/feature-search/feature-search-controller.ts
Expand Up @@ -15,7 +15,6 @@ import {
searchFeaturesSchema,
} from '../../openapi';
import { IAuthRequest } from '../../routes/unleash-types';
import { InvalidOperationError } from '../../error';
import {
FeatureSearchQueryParameters,
featureSearchQueryParameters,
Expand Down Expand Up @@ -75,68 +74,65 @@ export default class FeatureSearchController extends Controller {
req: IAuthRequest<any, any, any, FeatureSearchQueryParameters>,
res: Response,
): Promise<void> {
if (this.config.flagResolver.isEnabled('featureSearchAPI')) {
const {
query,
project,
type,
tag,
segment,
createdAt,
state,
status,
offset,
limit = '50',
sortOrder,
sortBy,
favoritesFirst,
} = req.query;
const userId = req.user.id;
const normalizedQuery = query
?.split(',')
.map((query) => query.trim())
.filter((query) => query);
const normalizedStatus = status
?.map((tag) => tag.split(':'))
.filter(
(tag) =>
tag.length === 2 &&
['enabled', 'disabled'].includes(tag[1]),
);
const normalizedLimit =
Number(limit) > 0 && Number(limit) <= 100 ? Number(limit) : 25;
const normalizedOffset = Number(offset) > 0 ? Number(offset) : 0;
const normalizedSortBy: string = sortBy ? sortBy : 'createdAt';
const normalizedSortOrder =
sortOrder === 'asc' || sortOrder === 'desc' ? sortOrder : 'asc';
const normalizedFavoritesFirst = favoritesFirst === 'true';
const { features, total } = await this.featureSearchService.search({
searchParams: normalizedQuery,
project,
type,
userId,
tag,
segment,
state,
createdAt,
status: normalizedStatus,
offset: normalizedOffset,
limit: normalizedLimit,
sortBy: normalizedSortBy,
sortOrder: normalizedSortOrder,
favoritesFirst: normalizedFavoritesFirst,
});

this.openApiService.respondWithValidation(
200,
res,
searchFeaturesSchema.$id,
serializeDates({ features, total }),
);
} else {
throw new InvalidOperationError(
'Feature Search API is not enabled',
const {
query,
project,
type,
tag,
segment,
createdAt,
state,
status,
offset,
limit = '50',
sortOrder,
sortBy,
favoritesFirst,
} = req.query;
const userId = req.user.id;
const normalizedQuery = query
?.split(',')
.map((query) => query.trim())
.filter((query) => query);
const normalizedStatus = status
?.map((tag) => tag.split(':'))
.filter(
(tag) =>
tag.length === 2 &&
['enabled', 'disabled'].includes(tag[1]),
);
}
const normalizedLimit =
Number(limit) > 0 && Number(limit) <= 100 ? Number(limit) : 25;
const normalizedOffset = Number(offset) > 0 ? Number(offset) : 0;
const normalizedSortBy: string = sortBy ? sortBy : 'createdAt';
const normalizedSortOrder =
sortOrder === 'asc' || sortOrder === 'desc' ? sortOrder : 'asc';
const normalizedFavoritesFirst = favoritesFirst === 'true';
const { features, total } = await this.featureSearchService.search({
searchParams: normalizedQuery,
project,
type,
userId,
tag,
segment,
state,
createdAt,
status: normalizedStatus,
offset: normalizedOffset,
limit: normalizedLimit,
sortBy: normalizedSortBy,
sortOrder: normalizedSortOrder,
favoritesFirst: normalizedFavoritesFirst,
});

this.openApiService.respondWithValidation(
200,
res,
searchFeaturesSchema.$id,
serializeDates({
features,
total,
}),
);
}
}
1 change: 0 additions & 1 deletion src/lib/features/feature-search/feature.search.e2e.test.ts
Expand Up @@ -21,7 +21,6 @@ beforeAll(async () => {
experimental: {
flags: {
strictSchemaValidation: true,
featureSearchAPI: true,
},
},
},
Expand Down
5 changes: 0 additions & 5 deletions src/lib/types/experimental.ts
Expand Up @@ -27,7 +27,6 @@ export type IFlagKey =
| 'filterInvalidClientMetrics'
| 'customRootRolesKillSwitch'
| 'disableMetrics'
| 'featureSearchAPI'
| 'scheduledConfigurationChanges'
| 'detectSegmentUsageInChangeRequests'
| 'stripClientHeadersOn304'
Expand Down Expand Up @@ -130,10 +129,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_DISABLE_METRICS,
false,
),
featureSearchAPI: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_FEATURE_SEARCH_API,
true,
),
scheduledConfigurationChanges: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_SCHEDULED_CONFIGURATION_CHANGES,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Expand Up @@ -40,7 +40,6 @@ process.nextTick(async () => {
embedProxyFrontend: true,
anonymiseEventLog: false,
responseTimeWithAppNameKillSwitch: false,
featureSearchAPI: true,
stripClientHeadersOn304: true,
newStrategyConfiguration: true,
stripHeadersOnAPI: true,
Expand Down

0 comments on commit d7eb950

Please sign in to comment.