mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
chore: remove redundant check for project names in db (#6311)
Skips the fetching project names from db part in the proxy-repository that was done when the token had ALL_PROJECTS
This commit is contained in:
parent
dc214d376a
commit
3bfafcf87e
@ -11,7 +11,12 @@ import {
|
|||||||
ITag,
|
ITag,
|
||||||
PartialDeep,
|
PartialDeep,
|
||||||
} from '../../types';
|
} from '../../types';
|
||||||
import { DEFAULT_ENV, ensureStringValue, mapValues } from '../../util';
|
import {
|
||||||
|
ALL_PROJECTS,
|
||||||
|
DEFAULT_ENV,
|
||||||
|
ensureStringValue,
|
||||||
|
mapValues,
|
||||||
|
} from '../../util';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import FeatureToggleStore from '../feature-toggle/feature-toggle-store';
|
import FeatureToggleStore from '../feature-toggle/feature-toggle-store';
|
||||||
import { Db } from '../../db/db';
|
import { Db } from '../../db/db';
|
||||||
@ -166,7 +171,10 @@ export default class FeatureToggleClientStore
|
|||||||
.whereIn(['tag_type', 'tag_value'], featureQuery.tag);
|
.whereIn(['tag_type', 'tag_value'], featureQuery.tag);
|
||||||
query = query.whereIn('features.name', tagQuery);
|
query = query.whereIn('features.name', tagQuery);
|
||||||
}
|
}
|
||||||
if (featureQuery.project) {
|
if (
|
||||||
|
featureQuery.project &&
|
||||||
|
!featureQuery.project.includes(ALL_PROJECTS)
|
||||||
|
) {
|
||||||
query = query.whereIn('project', featureQuery.project);
|
query = query.whereIn('project', featureQuery.project);
|
||||||
}
|
}
|
||||||
if (featureQuery.namePrefix) {
|
if (featureQuery.namePrefix) {
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
import NotFoundError from '../../../error/notfound-error';
|
import NotFoundError from '../../../error/notfound-error';
|
||||||
import { IFeatureStrategiesStore } from '../types/feature-toggle-strategies-store-type';
|
import { IFeatureStrategiesStore } from '../types/feature-toggle-strategies-store-type';
|
||||||
import { IFeatureProjectUserParams } from '../feature-toggle-controller';
|
import { IFeatureProjectUserParams } from '../feature-toggle-controller';
|
||||||
|
import { ALL_PROJECTS } from '../../../util';
|
||||||
|
|
||||||
interface ProjectEnvironment {
|
interface ProjectEnvironment {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
@ -182,17 +183,20 @@ export default class FakeFeatureStrategiesStore
|
|||||||
if (featureQuery.namePrefix) {
|
if (featureQuery.namePrefix) {
|
||||||
if (featureQuery.project) {
|
if (featureQuery.project) {
|
||||||
return (
|
return (
|
||||||
toggle.name.startsWith(featureQuery.namePrefix) &&
|
(toggle.name.startsWith(featureQuery.namePrefix) &&
|
||||||
featureQuery.project.some((project) =>
|
featureQuery.project.some((project) =>
|
||||||
project.includes(toggle.project),
|
project.includes(toggle.project),
|
||||||
)
|
)) ||
|
||||||
|
featureQuery.project.includes(ALL_PROJECTS)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return toggle.name.startsWith(featureQuery.namePrefix);
|
return toggle.name.startsWith(featureQuery.namePrefix);
|
||||||
}
|
}
|
||||||
if (featureQuery.project) {
|
if (featureQuery.project) {
|
||||||
return featureQuery.project.some((project) =>
|
return (
|
||||||
project.includes(toggle.project),
|
featureQuery.project.some((project) =>
|
||||||
|
project.includes(toggle.project),
|
||||||
|
) || featureQuery.project.includes(ALL_PROJECTS)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return toggle.archived === archived;
|
return toggle.archived === archived;
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
mapFeaturesForClient,
|
mapFeaturesForClient,
|
||||||
mapSegmentsForClient,
|
mapSegmentsForClient,
|
||||||
} from '../features/playground/offline-unleash-client';
|
} from '../features/playground/offline-unleash-client';
|
||||||
import { ALL_ENVS, ALL_PROJECTS } from '../util/constants';
|
import { ALL_ENVS } from '../util/constants';
|
||||||
import { UnleashEvents } from 'unleash-client';
|
import { UnleashEvents } from 'unleash-client';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import ConfigurationRevisionService, {
|
import ConfigurationRevisionService, {
|
||||||
@ -151,7 +151,7 @@ export class ProxyRepository
|
|||||||
private async featuresForToken(): Promise<FeatureInterface[]> {
|
private async featuresForToken(): Promise<FeatureInterface[]> {
|
||||||
return mapFeaturesForClient(
|
return mapFeaturesForClient(
|
||||||
await this.services.featureToggleServiceV2.getClientFeatures({
|
await this.services.featureToggleServiceV2.getClientFeatures({
|
||||||
project: await this.projectIdsForToken(),
|
project: this.token.projects,
|
||||||
environment: this.environmentNameForToken(),
|
environment: this.environmentNameForToken(),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -163,15 +163,6 @@ export class ProxyRepository
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async projectIdsForToken(): Promise<string[]> {
|
|
||||||
if (this.token.projects.includes(ALL_PROJECTS)) {
|
|
||||||
const allProjects = await this.stores.projectStore.getAll();
|
|
||||||
return allProjects.map((project) => project.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.token.projects;
|
|
||||||
}
|
|
||||||
|
|
||||||
private environmentNameForToken(): string {
|
private environmentNameForToken(): string {
|
||||||
if (this.token.environment === ALL_ENVS) {
|
if (this.token.environment === ALL_ENVS) {
|
||||||
return 'default';
|
return 'default';
|
||||||
|
Loading…
Reference in New Issue
Block a user