SimonErm/react-native-job-queue

Priority seems to be broke

hannojg opened this issue ยท 3 comments

Hello,

first of all: thank you for this promising package ๐Ÿ˜Š I am integrating your package in our production app and it seems to me that the priority functionality is broke.

For demonstration purpose, I added this test: #17

I have a worker which adds the IDs of the jobs to an array. This worker is set to a concurrency of 1 (so I expect the jobs to be executed after each other).
As it can be seen the job with the lower priority gets executed first.

Okay, so there are basically two issues:

  • The mock is not handling priority and dates correctly ( I've fixed that in my PR )
  • Priority is sorted ascending in the SQL query. Thus a job with a priority less then another job will be executed first (job with priority -1 gets executed before a job with priority 0). Usually, when the priority of something is higher it is considered more urgent. I am not sure whether this was intended. I am going to propose in my PR a sorting for higher priorities.

Thank you for opening this issue and doing the fix :-) . You're right the higher priority should be executed first. I will take a look at the PR this evening.