Skip to content

Fix issue with minimum-perc skip message#157

Merged
codegaze merged 1 commit intodevelfrom
fix-percentage-message
Feb 15, 2023
Merged

Fix issue with minimum-perc skip message#157
codegaze merged 1 commit intodevelfrom
fix-percentage-message

Conversation

@codegaze
Copy link
Contributor

@codegaze codegaze commented Feb 15, 2023

Before the fix, we were returning a message that a local file is newer than the remote one, which wasn't true.

This fix updates the shouldSkipDownload to return an additional value with a message in case it's different than the default one.

Also fixed a typo in readme regarding the minimum-perc flag.

Addresses #155

kbairak
kbairak previously approved these changes Feb 15, 2023
Copy link

@kbairak kbairak left a comment

Choose a reason for hiding this comment

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

Generally it's fine. I am approving this so if you want to discard my suggestion, go ahead and merge.

I don't like how the return values are inconsistent. Instead of (pseudocode in python-like language for speed):

def main():
    should_skip, msg = determine_if_should_skip()
    if should_skip:
        if msg:
            print(msg)
        else:
            print("Some default message")

def determine_if_should_skip():
    if some_condition:
        return True, ""
    elif some_other_condition:
        return True, "A very specific message"
    else:
        return False, ""

I think I would prefer

def main():
    should_skip, msg = determine_if_should_skip()
    if should_skip:
        print(msg)

def determine_if_should_skip():
    if some_condition:
        return True, "A default message"
    elif some_other_condition:
        return True, "A very specific message"
    else:
        return False, None

Yes this would mean that we would have to use the default message a few times inside the body of shouldSkipDownload but if this bothers you, you can define both messages as constant variables at the top of the function and use the variables when returning.

@codegaze codegaze force-pushed the fix-percentage-message branch 2 times, most recently from 67a8023 to ad9fbbc Compare February 15, 2023 14:32
Before the fix, we were returning a message that a local file is newer
than the remote one, which wasn't true.

This fix updates the `shouldSkipDownload` to return an additional value
with a message in case it's different than the default one.

Also fixed a typo in readme regarding the `minimum-perc` flag.
@codegaze codegaze force-pushed the fix-percentage-message branch from ad9fbbc to 84e2e99 Compare February 15, 2023 14:32
@codegaze
Copy link
Contributor Author

@kbairak Nahh, good feedback. I didn't like something either. 🙏
Updated

Copy link

@kbairak kbairak left a comment

Choose a reason for hiding this comment

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

That works (again approving in case you want to discard), but...

Lets try:

func shouldSkipDownload(...) (bool, string, error) {
  const minimumThresholdMessage = "Minimum translation completion threshold not satisfied, skipping"
  const newerThanRemoteMessage = "Local file is newer than remote, skipping"

  if something {
    return true, minimumThresholdMessage, nil
  } else if somethingElse {
    return true, newerThanRemoteMessage, nil
  } else {
    return false, "", nil
  }
}

@codegaze codegaze merged commit e07c3f1 into devel Feb 15, 2023
@codegaze codegaze deleted the fix-percentage-message branch February 15, 2023 16:57
3nids added a commit to opengisch/QgisModelBaker that referenced this pull request Oct 13, 2023
should bring better log messages
see transifex/cli#157
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