mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
[Gitar] Cleaning up stale feature flag: applicationOverviewNewQuery with value true (#6956)
--------- Co-authored-by: Gitar Bot <noreply@gitar.co> Co-authored-by: sjaanus <sellinjaanus@gmail.com>
This commit is contained in:
parent
d1cad6ece3
commit
010c4ee57b
@ -76,7 +76,6 @@ exports[`should create default config 1`] = `
|
||||
"experiments": {
|
||||
"adminTokenKillSwitch": false,
|
||||
"anonymiseEventLog": false,
|
||||
"applicationOverviewNewQuery": false,
|
||||
"automatedActions": false,
|
||||
"caseInsensitiveInOperators": false,
|
||||
"celebrateUnleash": false,
|
||||
|
@ -301,9 +301,6 @@ export default class ClientApplicationsStore
|
||||
async getApplicationOverview(
|
||||
appName: string,
|
||||
): Promise<IApplicationOverview> {
|
||||
if (!this.flagResolver.isEnabled('applicationOverviewNewQuery')) {
|
||||
return this.getOldApplicationOverview(appName);
|
||||
}
|
||||
const stopTimer = this.timer('getApplicationOverview');
|
||||
const query = this.db
|
||||
.with('metrics', (qb) => {
|
||||
@ -351,58 +348,10 @@ export default class ClientApplicationsStore
|
||||
return this.mapApplicationOverviewData(rows, existingStrategies);
|
||||
}
|
||||
|
||||
async getOldApplicationOverview(
|
||||
appName: string,
|
||||
): Promise<IApplicationOverview> {
|
||||
const stopTimer = this.timer('getApplicationOverviewOld');
|
||||
const query = this.db
|
||||
.with('metrics', (qb) => {
|
||||
qb.distinct(
|
||||
'cme.app_name',
|
||||
'cme.environment',
|
||||
'cme.feature_name',
|
||||
).from('client_metrics_env as cme');
|
||||
})
|
||||
.select([
|
||||
'f.project',
|
||||
'cme.environment',
|
||||
'cme.feature_name',
|
||||
'ci.instance_id',
|
||||
'ci.sdk_version',
|
||||
'ci.last_seen',
|
||||
'a.strategies',
|
||||
])
|
||||
.from({ a: 'client_applications' })
|
||||
.leftJoin('metrics as cme', 'cme.app_name', 'a.app_name')
|
||||
.leftJoin('features as f', 'cme.feature_name', 'f.name')
|
||||
.leftJoin('client_instances as ci', function () {
|
||||
this.on('ci.app_name', '=', 'cme.app_name').andOn(
|
||||
'ci.environment',
|
||||
'=',
|
||||
'cme.environment',
|
||||
);
|
||||
})
|
||||
.where('a.app_name', appName)
|
||||
.orderBy('cme.environment', 'asc');
|
||||
const rows = await query;
|
||||
stopTimer();
|
||||
if (!rows.length) {
|
||||
throw new NotFoundError(`Could not find appName=${appName}`);
|
||||
}
|
||||
const existingStrategies: string[] = await this.db
|
||||
.select('name')
|
||||
.from('strategies')
|
||||
.pluck('name');
|
||||
return this.mapApplicationOverviewData(rows, existingStrategies);
|
||||
}
|
||||
|
||||
mapApplicationOverviewData(
|
||||
rows: any[],
|
||||
existingStrategies: string[],
|
||||
): IApplicationOverview {
|
||||
if (!this.flagResolver.isEnabled('applicationOverviewNewQuery')) {
|
||||
return this.mapOldApplicationOverviewData(rows, existingStrategies);
|
||||
}
|
||||
const featureCount = new Set(rows.flatMap((row) => row.features)).size;
|
||||
const missingStrategies: Set<string> = new Set();
|
||||
|
||||
@ -486,96 +435,6 @@ export default class ClientApplicationsStore
|
||||
};
|
||||
}
|
||||
|
||||
private mapOldApplicationOverviewData(
|
||||
rows: any[],
|
||||
existingStrategies: string[],
|
||||
): IApplicationOverview {
|
||||
const featureCount = new Set(rows.map((row) => row.feature_name)).size;
|
||||
const missingStrategies: Set<string> = new Set();
|
||||
|
||||
const environments = rows.reduce((acc, row) => {
|
||||
const {
|
||||
environment,
|
||||
instance_id,
|
||||
sdk_version,
|
||||
last_seen,
|
||||
project,
|
||||
feature_name,
|
||||
strategies,
|
||||
} = row;
|
||||
|
||||
if (!environment) return acc;
|
||||
|
||||
strategies.forEach((strategy) => {
|
||||
if (
|
||||
!DEPRECATED_STRATEGIES.includes(strategy) &&
|
||||
!existingStrategies.includes(strategy)
|
||||
) {
|
||||
missingStrategies.add(strategy);
|
||||
}
|
||||
});
|
||||
|
||||
const featureDoesNotExist = !project && feature_name;
|
||||
|
||||
let env = acc.find((e) => e.name === environment);
|
||||
if (!env) {
|
||||
env = {
|
||||
name: environment,
|
||||
instanceCount: instance_id ? 1 : 0,
|
||||
sdks: sdk_version ? [sdk_version] : [],
|
||||
lastSeen: last_seen,
|
||||
uniqueInstanceIds: new Set(
|
||||
instance_id ? [instance_id] : [],
|
||||
),
|
||||
issues: {
|
||||
missingFeatures: featureDoesNotExist
|
||||
? [feature_name]
|
||||
: [],
|
||||
},
|
||||
};
|
||||
acc.push(env);
|
||||
} else {
|
||||
if (instance_id) {
|
||||
env.uniqueInstanceIds.add(instance_id);
|
||||
env.instanceCount = env.uniqueInstanceIds.size;
|
||||
}
|
||||
if (
|
||||
featureDoesNotExist &&
|
||||
!env.issues.missingFeatures.includes(feature_name)
|
||||
) {
|
||||
env.issues.missingFeatures.push(feature_name);
|
||||
}
|
||||
if (sdk_version && !env.sdks.includes(sdk_version)) {
|
||||
env.sdks.push(sdk_version);
|
||||
}
|
||||
if (new Date(last_seen) > new Date(env.lastSeen)) {
|
||||
env.lastSeen = last_seen;
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
environments.forEach((env) => {
|
||||
delete env.uniqueInstanceIds;
|
||||
env.sdks.sort();
|
||||
});
|
||||
|
||||
return {
|
||||
projects: [
|
||||
...new Set(
|
||||
rows
|
||||
.filter((row) => row.project != null)
|
||||
.map((row) => row.project),
|
||||
),
|
||||
],
|
||||
featureCount,
|
||||
environments,
|
||||
issues: {
|
||||
missingStrategies: [...missingStrategies],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private remapUsageRow = (input) => {
|
||||
if (this.flagResolver.isEnabled('parseProjectFromSession')) {
|
||||
if (!input.projects || input.projects.length === 0) {
|
||||
|
@ -58,8 +58,7 @@ export type IFlagKey =
|
||||
| 'projectListFilterMyProjects'
|
||||
| 'projectsListNewCards'
|
||||
| 'parseProjectFromSession'
|
||||
| 'createProjectWithEnvironmentConfig'
|
||||
| 'applicationOverviewNewQuery';
|
||||
| 'createProjectWithEnvironmentConfig';
|
||||
|
||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||
|
||||
@ -280,10 +279,6 @@ const flags: IFlags = {
|
||||
process.env.UNLEASH_EXPERIMENTAL_CREATE_PROJECT_WITH_ENVIRONMENT_CONFIG,
|
||||
false,
|
||||
),
|
||||
applicationOverviewNewQuery: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_APPLICATION_OVERVIEW_NEW_QUERY,
|
||||
false,
|
||||
),
|
||||
projectsListNewCards: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_PROJECTS_LIST_NEW_CARDS,
|
||||
false,
|
||||
|
@ -55,7 +55,6 @@ process.nextTick(async () => {
|
||||
projectsListNewCards: true,
|
||||
parseProjectFromSession: true,
|
||||
createProjectWithEnvironmentConfig: true,
|
||||
applicationOverviewNewQuery: true,
|
||||
},
|
||||
},
|
||||
authentication: {
|
||||
|
@ -56,7 +56,6 @@ beforeAll(async () => {
|
||||
experimental: {
|
||||
flags: {
|
||||
strictSchemaValidation: true,
|
||||
applicationOverviewNewQuery: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user