Skip to content

Commit

Permalink
hotfix to handle duplicate export data csv rows for marking multiple …
Browse files Browse the repository at this point in the history
…decision points by same user
  • Loading branch information
ppratikcr7 committed Nov 18, 2024
1 parent f6c4c6d commit ca84d0a
Showing 1 changed file with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,22 @@ export class AnalyticsRepository extends Repository<AnalyticsRepository> {
'"individualEnrollment"."experimentId" as "experimentId"',
'"individualEnrollment"."conditionId" as "conditionId"',
'"individualEnrollment"."partitionId" as "partitionId"',
'"decisionPointData"."site" as "site"',
'"decisionPointData"."target" as "target"',
])
.leftJoin(
DecisionPoint,
'decisionPointData',
'decisionPointData.experimentId = individualEnrollment.experimentId AND decisionPointData.id = individualEnrollment.partitionId'
)
.groupBy('individualEnrollment.userId')
.addGroupBy('individualEnrollment.groupId')
.addGroupBy('individualEnrollment.enrollmentCode')
.addGroupBy('individualEnrollment.experimentId')
.addGroupBy('individualEnrollment.conditionId')
.addGroupBy('individualEnrollment.partitionId')
.addGroupBy('decisionPointData.site')
.addGroupBy('decisionPointData.target')
.orderBy('individualEnrollment.userId', 'ASC')
.where('individualEnrollment.experimentId = :experimentId::uuid', { experimentId });

Expand Down Expand Up @@ -515,6 +524,8 @@ export class AnalyticsRepository extends Repository<AnalyticsRepository> {
enrollmentCode: individualEnrollmentQueryResult.enrollmentCode,
expDecisionPointId: individualEnrollmentQueryResult.partitionId,
expConditionId: individualEnrollmentQueryResult.conditionId,
site: individualEnrollmentQueryResult.site,
target: individualEnrollmentQueryResult.target,
});
}
});
Expand Down Expand Up @@ -549,16 +560,22 @@ export class AnalyticsRepository extends Repository<AnalyticsRepository> {
const userMonitoredResults =
groupedMonitoredDecisionPointQueryResults[individualEnrollmentExperiment.userId] || [];

return userMonitoredResults.map((monitoredDecisionPointQueryResult) => ({
...individualEnrollmentExperiment,
site: monitoredDecisionPointQueryResult.site,
target: monitoredDecisionPointQueryResult.target,
markExperimentPointTime: monitoredDecisionPointQueryResult.markExperimentPointTime,
stratificationValue: experimentsData.stratification
? userStratificationFactorQueryResult.find((user) => user.userId === individualEnrollmentExperiment.userId)
?.stratificationFactorValue
: null,
}));
return userMonitoredResults
.filter(
(monitoredDecisionPointQueryResult) =>
monitoredDecisionPointQueryResult.site === individualEnrollmentExperiment.site &&
monitoredDecisionPointQueryResult.target === individualEnrollmentExperiment.target
)
.map((monitoredDecisionPointQueryResult) => ({
...individualEnrollmentExperiment,
site: monitoredDecisionPointQueryResult.site,
target: monitoredDecisionPointQueryResult.target,
markExperimentPointTime: monitoredDecisionPointQueryResult.markExperimentPointTime,
stratificationValue: experimentsData.stratification
? userStratificationFactorQueryResult.find((user) => user.userId === individualEnrollmentExperiment.userId)
?.stratificationFactorValue
: null,
}));
});
return combinedCSVExportData;
}
Expand Down

0 comments on commit ca84d0a

Please sign in to comment.