Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. def _get_notifications(self):
  2. """
  3. Получение нотификаций для отправки.
  4. """
  5. ft_notifications = NotificationTask.get_by_statuses('new')
  6. ft_notifications = \
  7. ft_notifications[:settings.NOTIFICATION_NUM_FIRST_TIME]
  8.  
  9. if settings.NOTIFICATION_TWO_DAEMONS:
  10. self.notification_count = ft_notifications.count()
  11.  
  12. return ft_notifications
  13. else:
  14. re_notifications = \
  15. NotificationTask.get_by_statuses('retry').filter(
  16. next_time__lte=datetime.datetime.now()).order_by('next_time')
  17. re_notifications = \
  18. re_notifications[:settings.NOTIFICATION_NUM_RETRY_TIME]
  19.  
  20. self.notification_count = \
  21. ft_notifications.count() + re_notifications.count()
  22.  
  23. return itertools.chain(ft_notifications, re_notifications)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement