I'm working on a project that publish to a multiple websites using a multiple accounts. each account can publish to a specific website. as shown in the 'Dict' below. The problem is I'm trying to distribute the publishing jobs on accounts fairly and making a distance between accounts that has more than 1 job.
So, Let's say that we have the following accounts list:
and the following sites list:
Each account can publish to a specific site according to the following dynamic dictionary:
Key: Is the 'site ID' and value is a list of accounts IDs that can publish to that site.
Publishing jobs are created as follows:
when the jobs are created it is something similar to (Before re-adjusting the jobs distribution)
> Account-A Publish on Site-A
> Account-E Publish on Site-B
> Account-D Publish on Site-C
> Account-A Publish on Site-D
> Account-A Publish on Site-E
The publishing jobs created above are not fairly distributed to accounts, as you can see 'Account-A' has 3 jobs assigned while there's an other accounts can publish to the 'sites' as defined in 'Dict' so it should look something like:
> Account-C Publish on Site-A
> Account-E Publish on Site-B
> Account-A Publish on Site-D
> Account-D Publish on Site-C
> Account-A Publish on Site-E
In the output above the jobs are distributed fairly on accounts and also there's a distance between accounts that has more than 1 job
An example on distance between jobs
> Account-A Publish on Site-A
> Account-E Publish on Site-B
> Account-D Publish on Site-C
> Account-A Publish on Site-D
> Account-A Publish on Site-E
Job 4 and 5 are being processed by Account-A. An account should not process two jobs sequentially, so it could be swapped with another job, something like this
> Account-A Publish on Site-A
> Account-E Publish on Site-B
> Account-A Publish on Site-D
> Account-D Publish on Site-C
> Account-A Publish on Site-E
It will be highly appreciated if you could help. I need an algorithm that do the job distribution to get similar output. Performance is not important.
Thank you..