vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
388 stars 68 forks source link

When a job is done, progress information is overridden #214

Closed mitar closed 7 years ago

mitar commented 7 years ago

It seems that when a job is done, progress information is hard-coded to be completed=1, total=1. This removes any information in the progress set before.

I suggest we change this so that we set that completed=total, and percent=100.

I would change:

    doc = @findOne(
      {
        _id: id
        runId: runId
        status: "running"
      }
      {
        fields:
          log: 0
          failures: 0
          progress: 0
          updated: 0
          after: 0
          status: 0
        transform: null
      }
    )
    unless doc?
      unless @isSimulation
        console.warn "Running job not found", id, runId
      return false

    mods =
      $set:
        status: "completed"
        result: result
        progress:
          completed: 1
          total: 1
          percent: 100
        updated: time

To:

    doc = @findOne(
      {
        _id: id
        runId: runId
        status: "running"
      }
      {
        fields:
          log: 0
          failures: 0
          updated: 0
          after: 0
          status: 0
        transform: null
      }
    )
    unless doc?
      unless @isSimulation
        console.warn "Running job not found", id, runId
      return false

    mods =
      $set:
        status: "completed"
        result: result
        progress:
          completed: doc.progress.total or 1
          total: doc.progress.total or 1
          percent: 100
        updated: time
vsivsi commented 7 years ago

I'm fine with that. This "feature" was never documented or spec'ed one way or the other, so nobody should have written any code to depend on the current, arguably incorrect, behavior.

vsivsi commented 7 years ago

This is fixed in 1.5.0