diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 9ddaad3f90..32c154adc4 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -158,7 +158,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download all workflow run artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 - uses: ncipollo/release-action@v1 with: artifacts: "**/upgrade-*.zip" diff --git a/backend/package.json b/backend/package.json index 33abc995d6..c8cd8ee4ac 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "ab_testing_backend", - "version": "6.0.0-prerelease.1", + "version": "6.0.0-prerelease.2", "description": "Backend for A/B Testing Project", "scripts": { "install:all": "npm ci && cd packages/Scheduler && npm ci && cd ../Upgrade && npm ci", diff --git a/backend/packages/Scheduler/package.json b/backend/packages/Scheduler/package.json index c4fa82a66b..3fda044e9e 100644 --- a/backend/packages/Scheduler/package.json +++ b/backend/packages/Scheduler/package.json @@ -1,6 +1,6 @@ { "name": "ppl-upgrade-serverless", - "version": "6.0.0-prerelease.1", + "version": "6.0.0-prerelease.2", "description": "Serverless webpack example using Typescript", "main": "handler.js", "scripts": { diff --git a/backend/packages/Upgrade/package.json b/backend/packages/Upgrade/package.json index e54b774353..7564dd467f 100644 --- a/backend/packages/Upgrade/package.json +++ b/backend/packages/Upgrade/package.json @@ -1,6 +1,6 @@ { "name": "ab_testing_backend", - "version": "6.0.0-prerelease.1", + "version": "6.0.0-prerelease.2", "description": "Backend for A/B Testing Project", "main": "index.js", "scripts": { diff --git a/backend/packages/Upgrade/src/api/services/FeatureFlagService.ts b/backend/packages/Upgrade/src/api/services/FeatureFlagService.ts index 0416ab30e8..47905af5f6 100644 --- a/backend/packages/Upgrade/src/api/services/FeatureFlagService.ts +++ b/backend/packages/Upgrade/src/api/services/FeatureFlagService.ts @@ -163,7 +163,7 @@ export class FeatureFlagService { return this.featureFlagRepository.count(); } - public findPaginated( + public async findPaginated( skip: number, take: number, logger: UpgradeLogger, @@ -172,10 +172,7 @@ export class FeatureFlagService { ): Promise { logger.info({ message: 'Find paginated Feature flags' }); - let queryBuilder = this.featureFlagRepository - .createQueryBuilder('feature_flag') - .leftJoinAndSelect('feature_flag.featureFlagSegmentInclusion', 'featureFlagSegmentInclusion') - .loadRelationCountAndMap('feature_flag.featureFlagExposures', 'feature_flag.featureFlagExposures'); + let queryBuilder = this.featureFlagRepository.createQueryBuilder('feature_flag'); if (searchParams) { const customSearchString = searchParams.string.split(' ').join(`:*&`); // add search query @@ -194,7 +191,34 @@ export class FeatureFlagService { // TODO: the type of queryBuilder.getMany() is Promise // However, the above query returns Promise<(Omit & { featureFlagExposures: number })[]> // This can be fixed by using a @VirtualColumn in the FeatureFlag entity, when we are on TypeORM 0.3 - return queryBuilder.getMany(); + const featureFlagsWithExposures = await queryBuilder + .loadRelationCountAndMap('feature_flag.featureFlagExposures', 'feature_flag.featureFlagExposures') + .getMany(); + + // Get the feature flag ids + const featureFlagIds = featureFlagsWithExposures.map(({ id }) => id); + + // Get the relevant segment inclusion documents + const featureFlagWithInclusionSegments = await this.featureFlagRepository.find({ + select: ['id', 'featureFlagSegmentInclusion'], + where: { id: In(featureFlagIds) }, + relations: ['featureFlagSegmentInclusion'], + }); + + // Add the inclusion documents to the featureFlagsWithExposures + return featureFlagsWithExposures.map((featureFlag) => { + // Find the matching featureFlagSegmentInclusion for the current item + const inclusionSegment = featureFlagWithInclusionSegments.find( + ({ id }) => id === featureFlag.id + )?.featureFlagSegmentInclusion; + + // Construct the new object with conditional properties + return { + ...featureFlag, + // Only include featureFlagSegmentInclusion if inclusionSegment is defined and not empty + ...(inclusionSegment && inclusionSegment.length > 0 ? { featureFlagSegmentInclusion: inclusionSegment } : {}), + }; + }); } public async delete( diff --git a/clientlibs/java/pom.xml b/clientlibs/java/pom.xml index 6da31f6226..a6675ada40 100644 --- a/clientlibs/java/pom.xml +++ b/clientlibs/java/pom.xml @@ -9,7 +9,7 @@ at the same time that happen to rev to the same new version will be caught by a merge conflict. --> - 6.0.0-prelease.0-prerelease.1 + 6.0.0-prelease.0-prerelease.2 diff --git a/clientlibs/js/package.json b/clientlibs/js/package.json index 7c04a1f0f9..e727a222d5 100644 --- a/clientlibs/js/package.json +++ b/clientlibs/js/package.json @@ -1,6 +1,6 @@ { "name": "upgrade_client_lib", - "version": "6.0.0-prerelease.1", + "version": "6.0.0-prerelease.2", "description": "Client library to communicate with the Upgrade server", "files": [ "dist/*" diff --git a/frontend/package.json b/frontend/package.json index fab355427d..7ce540d630 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "ab-testing", - "version": "6.0.0-prerelease.1", + "version": "6.0.0-prerelease.2", "license": "MIT", "scripts": { "ng": "ng", diff --git a/package.json b/package.json index a813ee2c95..f18ca4826f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "UpGrade", - "version": "6.0.0-prerelease.1", + "version": "6.0.0-prerelease.2", "description": "This is a combined repository for UpGrade, an open-source platform to support large-scale A/B testing in educational applications. Learn more at www.upgradeplatform.org", "main": "index.js", "devDependencies": { diff --git a/types/package.json b/types/package.json index f4488fa6cf..b655e034b3 100644 --- a/types/package.json +++ b/types/package.json @@ -1,6 +1,6 @@ { "name": "upgrade_types", - "version": "6.0.0-prerelease.1", + "version": "6.0.0-prerelease.2", "description": "", "main": "src/index.ts", "types": "src/index.ts",