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

Fix issue with minimum-perc skip message #157

Merged
merged 1 commit into from
Feb 15, 2023
Merged

Conversation

codegaze
Copy link
Member

@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
Member

@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.

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
Copy link
Member Author

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

Copy link
Member

@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