diff --git a/packages/server/lib/cache.js b/packages/server/lib/cache.js index 69840844181c..5cad00e6d63c 100644 --- a/packages/server/lib/cache.js +++ b/packages/server/lib/cache.js @@ -186,7 +186,13 @@ module.exports = { }, getCohorts () { - return fileUtil.get('COHORTS', {}) + return fileUtil.get('COHORTS', {}).then((cohorts) => { + Object.keys(cohorts).forEach((key) => { + cohorts[key].name = key + }) + + return cohorts + }) }, insertCohort (cohort) { @@ -194,7 +200,9 @@ module.exports = { return tx.get('COHORTS', {}).then((cohorts) => { return tx.set('COHORTS', { ...cohorts, - [cohort.name]: cohort, + [cohort.name]: { + cohort: cohort.cohort, + }, }) }) }) diff --git a/packages/server/test/unit/cohort_spec.ts b/packages/server/test/unit/cohort_spec.ts index aa33c0f83743..8915df45c622 100644 --- a/packages/server/test/unit/cohort_spec.ts +++ b/packages/server/test/unit/cohort_spec.ts @@ -55,7 +55,7 @@ describe('lib/cohort', () => { return cohorts.set(cohortTest).then(() => { return cohorts.getByName(cohortTest.name).then((cohort) => { - expect(cohort).to.eq(cohortTest) + expect(cohort).to.deep.eq(cohortTest) }) }) })