Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Reports fields rename (M2-8268) #2002

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from

Conversation

andrevitalb
Copy link
Member

@andrevitalb andrevitalb commented Jan 3, 2025

  • Tests for the changes have been
  • Delivered the fix or feature branches into develop or release branches via Squash and Merge (to keep clean history)

📝 Description

🔗 Jira Ticket M2-8268

Renaming & reordering for both report.csv and activity_user_journey.csv fields. Also, renamed report.csv to responses.csv.

All these changes were added behind a workspace-wide feature flag, so won't be directly enabled by default.

Current expected columns & order (for report.csv)

id
activity_flow_submission_id
activity_scheduled_time
activity_start_time
activity_end_time
flag
secret_user_id
userId
source_user_subject_id
source_user_secret_id
source_user_nickname
source_user_relation
source_user_tag
target_user_subject_id
target_user_secret_id
target_user_nickname
target_user_tag
input_user_subject_id
input_user_secret_id
input_user_nickname
activity_id
activity_name
activity_flow_id
activity_flow_name
item
response
prompt
options
version
rawScore
reviewing_id
schedule_id
timezone_offset
legacy_user_id

New expected columns & order

target_id
target_secret_id
target_nickname
target_tag
source_id
source_secret_id
source_nickname
source_tag
source_relation
input_id
input_secret_id
input_nickname
userId
secret_user_id
legacy_user_id
applet_version
activity_flow_id
activity_flow_name
activity_flow_submission_id
activity_id
activity_name
activity_submission_id
activity_start_time
activity_end_time
activity_schedule_id
activity_schedule_start_time
utc_timezone_offset
activity_submission_review_id
item_id
item_name
item_prompt
item_response_options
item_response
item_response_status
rawScore

The changes get propagated to activity_user_journey.csv. Additional fields for said report were left unchanged.

🪤 Peer Testing

In order to test functionality, set enableDataExportRenaming feature flag to true.

✏️ Notes

Something to keep in mind is that changes to subscales will come in a separate ticket, under the same feature flag that was used for all the changes added here

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2002.d19gtpld8yi51u.amplifyapp.com

@andrevitalb andrevitalb marked this pull request as ready for review January 8, 2025 17:05
Copy link
Contributor

@felipeMetaLab felipeMetaLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling eslint and TS

Copy link
Contributor

@felipeMetaLab felipeMetaLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside the comment to disable Ts and eslint the code looks good for me.

@andrevitalb andrevitalb force-pushed the feature/M2-8268-reports-fields-rename branch from ad926a1 to 480a4f7 Compare January 22, 2025 17:54
Copy link
Contributor

@mbanting mbanting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Main comment is the flag is temporary. So try and minimize it's proliferation in the code to only where it's necessary. Reduces cleanup and risk later on when flag is archived and code needs to be updated to remove references to it, and where QA might not test to the same level as when the feature is first implemented. I pointed out a couple of places where this can be done.

const LEGACY_GENERAL_REPORT_NAME = 'report';
const NEW_GENERAL_REPORT_NAME = 'responses';

export const getGeneralReportName = (enableDataExportRenaming: boolean) =>
Copy link
Contributor

@mbanting mbanting Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if capturing this condition in a function is needed. It's only called in one place (exportDataSucceed) and the use of a feature flag is temporary. Once the enableDataExportRenaming flag is archived, we'll need to remove all references (or params based on it) to it, so it's good keep this to only where this is needed. Suggest removing this function and simply determine this in exportDataSucceed

await exportTemplate({
data: reportData,
fileName: GENERAL_REPORT_NAME + suffix,
defaultData: reportData.length > 0 ? null : reportHeader,
fileName: getGeneralReportName(enableDataExportRenaming) + suffix,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest simply determine the report name here

fileName: (enableDataExportRenaming ? NEW_GENERAL_REPORT_NAME : LEGACY_GENERAL_REPORT_NAME) + suffix,

];

export const activityJourneyHeader = [
export const getReportHeader = (enableDataExportRenaming?: boolean) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above. I realize this function is also used in the tests (exportDataSucceed.test.ts), but this function itself will likely be deleted once the flag is archived, so minimizing the use of this function in other places like the tests also make sense. Instead can you import legacyReportHeader and newReportHeader in the tests and compare against those values instead of relying on this function.

'response_option_selection_time',
];

export const getActivityJourneyHeader = (enableDataExportRenaming?: boolean) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

@@ -1,5 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
import { getActivityJourneyHeader, getReportHeader } from 'shared/consts';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this import legacyReportHeader, reportHeader, legacyActivityJourneyHeader, and activityJourneyHeader instead

@@ -387,6 +435,52 @@ export const activityJourneyHeader = [
'version',
];

export const newActivityJourneyHeader = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use activityJourneyHeader instead. One less change during flag cleanup.

fileName: GENERAL_REPORT_NAME + suffix,
defaultData: reportData.length > 0 ? null : reportHeader,
fileName: getGeneralReportName(enableDataExportRenaming) + suffix,
defaultData: reportData.length > 0 ? null : getReportHeader(enableDataExportRenaming),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above

});
await exportTemplate({
data: activityJourneyData,
fileName: JOURNEY_REPORT_NAME + suffix,
defaultData: activityJourneyData.length > 0 ? null : activityJourneyHeader,
defaultData:
activityJourneyData.length > 0 ? null : getActivityJourneyHeader(enableDataExportRenaming),
Copy link
Contributor

@mbanting mbanting Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above. Determine the headers here instead of relying on an external function that will be removed and unavailable when the flag is archived.

legacy_user_id: null,
};

const newResult = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of a nit, but let's just call this result as it is the result when the flag is on and also when it is ultimately archived. Minimizes cleanup when flag is removed.

@@ -160,8 +160,63 @@ const result = {
legacy_user_id: '',
};

const newResult = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of a nit, but let's just call this result as it is the result when the flag is on and also when it is ultimately archived. Minimizes cleanup when flag is removed.

@andrevitalb
Copy link
Member Author

On it 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants