Skip to content

Commit

Permalink
adding more data types and comments in export csv data function
Browse files Browse the repository at this point in the history
  • Loading branch information
ppratikcr7 committed Nov 5, 2024
1 parent a7e1521 commit a42743f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/packages/Upgrade/src/api/services/AnalyticsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ export class AnalyticsService {
if (!experimentQueryResult || experimentQueryResult.length === 0) {
throw new HttpError(404, `Experiment not found for id: ${experimentId}`);
}
const formattedExperiments = experimentQueryResult.reduce((acc, item) => {
const formattedExperiment: ExperimentCSVData[] = experimentQueryResult.reduce((acc, item) => {
let experiment: ExperimentCSVData = acc.find((e) => e.experimentId === item.experimentId);
// for the first run over the experiment data, prepare the experiment object
if (!experiment) {
experiment = {
experimentId: item.experimentId,
Expand All @@ -202,6 +203,7 @@ export class AnalyticsService {
};
acc.push(experiment);
}
// add the design details for the experiment for each experimentQueryResult item
experiment.details.push({
expConditionId: item.expConditionId,
conditionName: item.conditionName,
Expand All @@ -217,7 +219,7 @@ export class AnalyticsService {
if (experimentQueryResult[0].assignmentUnit === ASSIGNMENT_UNIT.WITHIN_SUBJECTS) {
csvExportData = await this.analyticsRepository.getCSVDataForWithInSubExport(experimentId);
} else {
csvExportData = await this.analyticsRepository.getCSVDataForSimpleExport(formattedExperiments[0], experimentId);
csvExportData = await this.analyticsRepository.getCSVDataForSimpleExport(formattedExperiment[0], experimentId);
}

const queryData = await this.logRepository.getLogPerExperimentQuery(experimentId);
Expand Down

0 comments on commit a42743f

Please sign in to comment.