Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Ask for promote when fully migrating a public app #326

Merged
merged 4 commits into from
Jun 12, 2018
Merged

Conversation

eliangcs
Copy link
Member

@eliangcs eliangcs commented Jun 8, 2018

Addresses PDE-160.

It makes little sense to migrate 100% without a promotion beforehand. This PR adjusts the behavior of zapier migrate so that when a dev does a 100% migration on a public app, we ask if the dev wants to promote that version first.

As for private apps, the 100% migration should automatically do an implicit promotion for the devs. It's already being implemented in the backend, so we don't need to handle that here.

@eliangcs eliangcs requested a review from xavdid June 8, 2018 14:34
@eliangcs
Copy link
Member Author

eliangcs commented Jun 8, 2018

cc @ibolmo for you may be interested in having a look.

Copy link
Contributor

@ibolmo ibolmo left a comment

Choose a reason for hiding this comment

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

Cool thanks for the heads up! Quick look made me wonder if we want to scope outside the app, but I suppose passing down a "context" object with something like { app, answer } could be more busy. The advantage in doing it this way, though, will make it easier to refactor into individual functions.

@@ -8,9 +15,45 @@ const migrate = (context, fromVersion, toVersion, optionalPercent = '100%') => {
return Promise.resolve();
}
optionalPercent = parseInt(optionalPercent, 10);

let app;
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason to scope this outside?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! Fixed in 032f11e with Promise.all.

Copy link
Contributor

@xavdid xavdid 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! my only other thought is that we're already using babel but not taking advantage of async // await anywhere, which seems silly. Could greatly simplify some of the promise chaining that happens in other commands (looking at you, build). Not related to this, but something I thought about while reading this.

.then(linkedApp => {
app = linkedApp;
if (
optionalPercent === 100 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any value in setting this threshold a little lower? presumably moving 90% of users to a version means you want that version to be public too. I could even see a case for going lower, maybe 75%.

Copy link
Member Author

@eliangcs eliangcs Jun 11, 2018

Choose a reason for hiding this comment

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

It's hard to define such a threshold. You can always ask why this value and why not that value. So I think it's easier for us to just assume when a dev does a partial migration, they're testing. In addition, for private apps, the backend does implicit promotion (such as moving ZTs to the new version) only if it's a 100% migration. To make it symmetry on the public apps, shouldn't we only suggest for promotion when it's 100% migration?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's fair! It's a pattern devs have some issues with, but maybe the consistency is worthwhile

return answer;
};

return utils.promiseDoWhile(action, stop);
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessarily something to fix in this PR, but it would be worth abstracting input like this into a prompUser(question: string, acceptedAnswers?: string[])-type method. We could also use a library since it seems like we're doing a big of hack here with the promise loop. ¯\_(ツ)_/¯

Copy link
Member Author

Choose a reason for hiding this comment

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

@xavdid totally agreed. I made it a function named getYesNoInput in 7510d13. Can I have another review? Thanks!

@@ -9,7 +9,7 @@ const hasCancelled = answer =>
const hasAccepted = answer =>
answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes';

const promote = (context, version) => {
const promote = (context, version, printMigrateHint = true) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like it!

@eliangcs
Copy link
Member Author

@xavdid async / await style is definitely something I'm looking forward to seeing. Coding in promises has been costing a lot of my brain power.

@xavdid
Copy link
Contributor

xavdid commented Jun 11, 2018

No need to wait! We're already running babel on cli, so write something with async (and remember to build) and you're good to go.

I'm not sure why we haven't been writing stuff that way already. Maybe just habit?

@eliangcs
Copy link
Member Author

@xavdid I know we can start using async / await. But promises are already everywhere, so I guess we've been writing in promises for consistency until there's a big refactor that moves all of them to async / await?

@eliangcs eliangcs merged commit 100e87a into master Jun 12, 2018
@eliangcs eliangcs deleted the ask-for-promote branch June 12, 2018 14:35
@xavdid
Copy link
Contributor

xavdid commented Jun 12, 2018

that's fair! Since they work with one another it might be easier to introduce them as we go. i'm excited for that future though

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

Successfully merging this pull request may close these issues.

3 participants