-
Notifications
You must be signed in to change notification settings - Fork 110
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
Refactor migration logic for recorded app #501
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits!
Will take a closer look on my local.
Love how this makes it legible <3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good!
Thanks for making this one. LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This new pattern of doXANDY() felt odd, but I think it does make it more readable. I was trying to find a way to keep the flow of doX() if x { return y() }
instead of the doXandY()
style this introduces, but I couldn't see a nice way. I don't want to block the refactor as I think it's a step in a more readable direction, but if it's valuable I can go through and see if what I am trying to describe provides the value I am hoping it does...
foundMigratedApp, err := a.findAndUpdate(a.fqName(), labels)
if err != nil {
return err
}
if foundMigratedApp {
a.isMigrated = true
return nil
}
would love if this could remain something like: (only because I am a fan on functions doing one thing only - the pattern of AND or even OR I find confusing)
if exists, err := a.find(a.fqName()); err != nil {
return err
}
if exists {
a.isMigrated = true
return a.updateApp(labels)
}
Yeah, that sounds good. I will give this a shot. The only reason I didn't do it was because of the |
62ddfa7
to
fd26c9f
Compare
@neil-hickey Thanks a lot for your suggestions, I have made the relevant changes. Let me know your thoughts on it 😄 |
I prefer this pattern, it's more explicit what is going on. For example:
vs (now)
You can see that they are effectively the same even with the old refactor of update into the findAndUpdate function. To me, now it's really clear what's happening if the app is found.. we update it, whereas before it was kinda hidden. Curious to see what others think! |
I myself like the new changes more than previous one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still looking good to me 🚀
Here's an attempt at making the migration logic a bit more readable and simple.
I realised that I we were trying to avoid updating the
createOrUpdate
with the migration logic and in doing so it resulted increateOrUpdate
being used only for create operations and not for updates, and this led me to make these changes.find
andcreate
.CreateOrUpdate
,RenamePrevApp
,Exists
,Rename
,setMeta
, etc,. to make them more simple.createOrUpdate
isMigrated
at relevant places.