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

fixes 2-456: Preserve all data from strategy import #2720

Merged
merged 2 commits into from Dec 21, 2022

Conversation

chriswk
Copy link
Contributor

@chriswk chriswk commented Dec 21, 2022

What

Previously when importing strategies we've used the same data type we've used for creating strategies (the minimal, a name, an optional description, optional parameters and an optional editable column). This meant that exporting strategies and then importing them would reactivate deprecated strategies. This PR changes to allow the import to preserve all the data coming in the export file.

Tests

Added four new tests, two new unit tests using our fake stores and two new e2e tests. Interestingly the ones in the fake store ran green before this change as well, probably because we just insert the parsed json object in the fake store, whereas the real store actually converts the object from camelCasing to the postgresql snake_casing standard.

Discussion points:

Mismatch between fake and real stores

This is inevitable since storing things in javascript arrays vs saving in a real database will have some differences, but this again shows the value of our e2e tests.

Invariants

Should we see if we can add some invariants to our import/export so that we can write some proptests for it? One candidate is commutativity of import/export. On a fresh database importing and then exporting should yield the same file that was imported provided all flags are turned on. Candidate for Q1 improvement of import/export.

Previously the strategy was to use the IMinimalStrategyRow.
This PR changes to use the full data from the export in the import.

* Discussion point:
Should we see if we can add some invariants to our import/export so that
we can write some proptests for it. One candidate is commutativity of
import/export. On a fresh database importing and then exporting should
yield the same file that was imported provided all flags are turned on
@vercel
Copy link

vercel bot commented Dec 21, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Dec 21, 2022 at 11:46AM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
unleash-docs ⬜️ Ignored (Inspect) Dec 21, 2022 at 11:46AM (UTC)

@chriswk chriswk changed the title fix: Preserve all data from strategy import fixes 2-456: Preserve all data from strategy import Dec 21, 2022
Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

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

Looks good, just 2 small comments

@@ -23,6 +23,16 @@ export interface IMinimalStrategy {
parameters?: any[];
}

export interface IStrategyImport {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at IMinimalStrategy there's a missing property in IStrategyImport:

  • editable?: boolean

Just checking if this is intentional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we call it builtIn in the export as well as built_in in the table. where editable is built_in === 0. Unfortunately built_in is still an integer in our table for some reason :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I just checked the previous code using

eventDataToRow(data): IMinimalStrategyRow {
return {
name: data.name,
description: data.description,
parameters: JSON.stringify(data.parameters),
};
}

and I see that editable although present in the type was completely ignored 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup :(

src/lib/db/strategy-store.ts Show resolved Hide resolved
@chriswk chriswk merged commit 5b66346 into main Dec 21, 2022
@chriswk chriswk deleted the chriswk/2-456-when-importing-strategies-we-are-not branch December 21, 2022 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants