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

Request: Job progress count instead of percentage #17

Closed
sephirothmk opened this issue Sep 19, 2019 · 1 comment · Fixed by #20
Closed

Request: Job progress count instead of percentage #17

sephirothmk opened this issue Sep 19, 2019 · 1 comment · Fixed by #20

Comments

@sephirothmk
Copy link

sephirothmk commented Sep 19, 2019

Hello.

First of all, thank you for making a nice and clean interface for bull. I use it in my project that syncs data between databases. I do the work using batches, so I never know the max value of things that need processing in order to calculate the percentage. So if i do job.progress(item.count) where item.count is for example 4235 items, the frontend interface will go crazy because the green progressbar will be style="width: 4235%".

What im proposing is a simple check, something along the lines of:
if (job.progress > 100) // Don't render class="progress-bar", style="width: 4235%" and the % sign

progress: ({ job }) => {
    switch (type(job.progress)) {
      case 'Object':
        return (
          <Highlight className="json">
            {JSON.stringify(job.progress, null, 2)}
          </Highlight>
        )
      case 'Number':
       if (job.progress > 100)  {
            return (
          <div className="progress-wrapper"> {job.progress}</div>
        )
        }
        return (
          <div className="progress-wrapper">
            <div
              className="progress-bar"
              style={{
                width: `${job.progress}%`,
              }}
            >
              {job.progress}
              %&nbsp;
            </div>
          </div>
        )
      default:
        return '--'
    }
  },

Thanks in advance

@vcapretz
Copy link
Contributor

hey @sephirothmk, thank you for reporting the issue, I do see the problem 😅

the docs for bull specify the progress to be a number between 0 and 100 as such: https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#jobprogress

So I wonder if in this case there's something that should be done application wise, instead of in bull-board

I actually noticed we handle cases when progress is an object, which might be weird so I guess adding the check for at least not breaking for values above 100 is fine 👍

I'll open a PR with the fix

vcapretz added a commit that referenced this issue Sep 23, 2019
jobs might have progress reports with values that are bigger than 100
this at least prevents the progress bar to break and instead show only the number

fixes #17
vcapretz added a commit that referenced this issue Sep 23, 2019
jobs might have progress reports with values that are bigger than 100
this at least prevents the progress bar to break and instead show only the number

fixes #17
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 a pull request may close this issue.

2 participants