From dd43c677b63123e716fa6d0440aac7b99c756547 Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Thu, 28 Nov 2024 11:00:44 +0100 Subject: [PATCH] fix: comments from PR, use whereIn instead of boolean field --- src/lib/db/feature-environment-store.ts | 6 +++++- .../client-feature-toggle-service.ts | 1 - .../project-environments/environment-store.ts | 16 ++++++++++++---- ...-enabled-in-oss-to-project-and-environment.js | 16 ---------------- 4 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 src/migrations/20241125115848-add-enabled-in-oss-to-project-and-environment.js diff --git a/src/lib/db/feature-environment-store.ts b/src/lib/db/feature-environment-store.ts index dd6f719076d1..3bb80159bff9 100644 --- a/src/lib/db/feature-environment-store.ts +++ b/src/lib/db/feature-environment-store.ts @@ -112,7 +112,11 @@ export class FeatureEnvironmentStore implements IFeatureEnvironmentStore { '=', `${T.featureEnvs}.environment`, ) - .where('environments.enabled_in_oss', true); + .whereIn('environments.name', [ + 'default', + 'development', + 'production', + ]); } return queryBuilder; } diff --git a/src/lib/features/client-feature-toggles/client-feature-toggle-service.ts b/src/lib/features/client-feature-toggles/client-feature-toggle-service.ts index 7e90ef21a3ea..c4a7f0e5bd0b 100644 --- a/src/lib/features/client-feature-toggles/client-feature-toggle-service.ts +++ b/src/lib/features/client-feature-toggles/client-feature-toggle-service.ts @@ -27,7 +27,6 @@ export class ClientFeatureToggleService { this.logger = getLogger('services/client-feature-toggle-service.ts'); this.segmentReadModel = segmentReadModel; this.clientFeatureToggleStore = clientFeatureToggleStore; - const isTest = process.env.NODE_ENV === 'test'; } async getActiveSegmentsForClient() { diff --git a/src/lib/features/project-environments/environment-store.ts b/src/lib/features/project-environments/environment-store.ts index c9d983a31112..3da9522b0018 100644 --- a/src/lib/features/project-environments/environment-store.ts +++ b/src/lib/features/project-environments/environment-store.ts @@ -158,7 +158,11 @@ export default class EnvironmentStore implements IEnvironmentStore { const stopTimer = this.timer('get'); let keyQuery = this.db(TABLE).where({ name: key }); if (this.isOss) { - keyQuery = keyQuery.where('enabled_in_oss', true); + keyQuery = keyQuery.whereIn('name', [ + 'default', + 'development', + 'production', + ]); } const row = await keyQuery.first(); stopTimer(); @@ -180,7 +184,7 @@ export default class EnvironmentStore implements IEnvironmentStore { qB = qB.where(query); } if (this.isOss) { - qB = qB.where('enabled_in_oss', true); + qB = qB.whereIn('name', ['default', 'development', 'production']); } const rows = await qB; stopTimer(); @@ -210,7 +214,7 @@ export default class EnvironmentStore implements IEnvironmentStore { qB = qB.where(query); } if (this.isOss) { - qB = qB.where('enabled_in_oss', true); + qB = qB.whereIn('name', ['default', 'development', 'production']); } const rows = await qB; stopTimer(); @@ -247,7 +251,11 @@ export default class EnvironmentStore implements IEnvironmentStore { qB = qB.where(query); } if (this.isOss) { - qB = qB.where('environments.enabled_in_oss', true); + qB = qB.whereIn('environments.name', [ + 'default', + 'production', + 'development', + ]); } const rows = await qB; diff --git a/src/migrations/20241125115848-add-enabled-in-oss-to-project-and-environment.js b/src/migrations/20241125115848-add-enabled-in-oss-to-project-and-environment.js deleted file mode 100644 index eb7baa2cd26c..000000000000 --- a/src/migrations/20241125115848-add-enabled-in-oss-to-project-and-environment.js +++ /dev/null @@ -1,16 +0,0 @@ -exports.up = function(db, cb) { - db.runSql(` - ALTER TABLE environments ADD COLUMN enabled_in_oss BOOLEAN NOT NULL DEFAULT false; - ALTER TABLE projects ADD COLUMN enabled_in_oss BOOLEAN NOT NULL DEFAULT false; - UPDATE environments SET enabled_in_oss = true WHERE name IN ('default', 'development', 'production'); - UPDATE projects SET enabled_in_oss = true WHERE id = 'default'; - `, cb); -}; - -exports.down = function(db, cb) { - db.runSql(` - ALTER TABLE projects DROP COLUMN enabled_in_oss; - ALTER TABLE environments DROP COLUMN enabled_in_oss; - `, cb); -}; -