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

Emails are being sent latest first and I need vice versa #86

Closed
embedded1 opened this issue Nov 10, 2014 · 7 comments
Closed

Emails are being sent latest first and I need vice versa #86

embedded1 opened this issue Nov 10, 2014 · 7 comments

Comments

@embedded1
Copy link
Contributor

I'm using the default priority which is Medium and a cron job to pick the emails out
of the queue for sending but emails are being sent lastest first due to "order_by(-priority)"

How can I achieve my goal which is sending out the oldest email in queue first?

thanks for this wonderful library

@embedded1
Copy link
Contributor Author

An easy solution is to use order_by(priority) and set 0 to be the higher priority(now) and so on.

@selwin
Copy link
Collaborator

selwin commented Nov 17, 2014

An easy way to do this would be to change the order_by argument in line 175 to order_by('-priority', 'id') so mails get sent out by priority and from oldest to newest.

I don't want to merge this into post_office because ordering by two columns could be an expensive operation when you have hundreds of thousands or millions of emails to send, but that's how I would do it :).

@selwin selwin closed this as completed Nov 17, 2014
@embedded1
Copy link
Contributor Author

I don't want to patch the official release.
Could you please add an option to send out mails based on the created attribute instead of using the priority attribute?

this can be configure using a settings parameter while keeping the default behavior as it now which is by priority.

@selwin
Copy link
Collaborator

selwin commented Nov 17, 2014

I suppose we could take an optional SENDING_ORDER so you'd be able to do this:

POST_OFFICE = {
    'SENDING_ORDER': ['-id', '-priority']
}

Pull request welcome :)

@selwin selwin reopened this Nov 17, 2014
@embedded1
Copy link
Contributor Author

OK, this would be great, for my needs I would order by the created attribute to send emails with the FIFO order.

I will add the pull request.
10x

@embedded1
Copy link
Contributor Author

pull request submitted.

@selwin
Copy link
Collaborator

selwin commented Nov 23, 2014

Fixed in #87

@selwin selwin closed this as completed Nov 23, 2014
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

No branches or pull requests

2 participants