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

migrate: find+replace flag prop with flags across all mock flow data #611

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

jessicamcinchak
Copy link
Member

@jessicamcinchak jessicamcinchak commented Jan 7, 2025

Per data migration plan here: https://docs.google.com/spreadsheets/d/1Vtxp5BLweDPDooQoNhgOCYjCIBPRYIcOuyArGJRqOkI/edit?gid=0#gid=0

Corresponds to planx-new PR here: theopensystemslab/planx-new#4098

Changes:

  • planx-core has multiple instances of very large mock flow data and instead of a find+replace of flag to flags (plus making value an array) across these, I've simply copied new versions from the entire flows from staging post-database migration scripts this morning. This means they now have the correct structure, but general content changes as well
  • getResultData methods are updated and synced to planx-new preview store (see comment below)

@@ -13,58 +12,63 @@ import {
resultOverrides,
} from "../types";

// Functions in this file need to stay in sync with planx-new/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts !!
// TODO eventually replace/combine ??
Copy link
Member Author

@jessicamcinchak jessicamcinchak Jan 7, 2025

Choose a reason for hiding this comment

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

This is important and annoying ! I'd missed this when updating result store functions in planx-new around the time of automation changes ~2 months ago - which means the CSV & overview HTML have only been including result data based on the legacy "flag" format of old questions/checklist options until now.

This change brings the functions back in sync, but ultimately we still need to revisit this so that we don't need to maintain these in x2 places to begin with. (Can we store result on session data & eliminate need to "calculate" it in planx-core at all?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree that this would be handly, took me a bit to work out the need for the two.

Are they both doing the same thing but using the return in different places. We recalculate the result for payload generation in planx-core while we use the resultData in the Result component in planx-new? ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct - result data is a computation based on breadcrumbs & flow data like the passport, but unlike the passport which is saved on lowcal_sessions.data, result is computed on the fly in planx-new and therefore needs to be re-computed when referenced in planx-core rather than simply fetched from the session data like we can with a passport

expect(path).toHaveLength(58);
expect(path[57].id).toBe("_root");
expect(path).toHaveLength(62);
expect(path[61].id).toBe("_root"); // _root is always last
Copy link
Member Author

Choose a reason for hiding this comment

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

The mock flows changed here so the length of node paths has legitimately changed too

export type NodeData = Record<string, Value> & NodeTags;
export type NodeFlags = { flags?: string[] };

export type NodeData = Record<string, Value> & NodeTags & NodeFlags;
Copy link
Member Author

@jessicamcinchak jessicamcinchak Jan 7, 2025

Choose a reason for hiding this comment

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

Duped again by Value type ! Explicitly defining NodeFlags is a "workaround" that lets us do stuff like node.data.flags.forEach without throwing a Value TypeError

Copy link
Contributor

@RODO94 RODO94 left a comment

Choose a reason for hiding this comment

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

Ran through the changes to check for any typos or overlooked changes but couldn't find any. Skimming the mocks seemed unwieldy so I kept that to a ctrl+f for possible typos or missed ones, but I imagine these to be pretty spot on.

These changes are scheduled before switching the flag values in the flatFlags array. Will we have to change the mocks again at this point to incorporate the new values?

I think it's the right approach to go step by step with the changes, I just want to check my understanding of upcoming changes on this.

All looks good to me though

@jessicamcinchak
Copy link
Member Author

@RODO94 thanks for review! Yes this change will merge first, then #595 will need to be rebased / updated - but that PR is schema-release-dependent as well so not part of this initial data migration

@jessicamcinchak jessicamcinchak merged commit ddf35f3 into main Jan 7, 2025
3 checks passed
@jessicamcinchak jessicamcinchak deleted the jess/flag-to-flags-prop branch January 7, 2025 15:38
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.

2 participants