1. fak3
  2. gosvideo

Commits

fak3  committed 332a63e

main_utils.py - reorder orders with no_link errors

  • Participants
  • Parent commits df4f2d3
  • Branches default

Comments (0)

Files changed (2)

File gui_dialogs.py

View file
  • Ignore whitespace
 
 
 class SettingsDialog(Dialog):
-    sizeHint = lambda self: QSize(560, 780)
+    sizeHint = lambda self: QSize(1020, 780)
     
     def __init__(self, *args):
         super(SettingsDialog, self).__init__(*args)

File main_utils.py

View file
  • Ignore whitespace
     fromtime = datetime.now() - timedelta(days=days_ago)
     totime = datetime.now() - timedelta(days=1)
     to_order = {}
-    waiting = Order.objects.filter(waiting=True, created__range=[fromtime, totime]).values_list('uik_id', 'tstart')
-    just_ordered = Order.objects.filter(created__gt=totime).values_list('uik_id', 'tstart')
-    ready = Order.objects.filter(waiting=False).values_list('uik_id', 'tstart')
-    to_order = set(waiting) - set(ready) - set(just_ordered)
-    order_multi(to_order, cookies)
+    orders = lambda **kwargs: Order.objects.filter(**kwargs).values_list('uik_id', 'tstart')
+    waiting = orders(waiting=True, created__range=[fromtime, totime])
+    no_link = orders(no_link_err=True, created__range=[fromtime, totime])
+    just_ordered = orders(created__gt=totime)
+    ready = orders(waiting=False, no_link_err=False)
+    to_order = set(waiting) | set(no_link) - set(just_ordered) - set(ready) 
+    order_multi(to_order, cookies, sleep_time=2)
 
 @update_stats
-def order_multi(odata, cookies, update_uiks):
+def order_multi(odata, cookies, sleep_time=15, update_uiks=set()):
     ''' Заказывает много 30-минутных фрагментов  '''
     span = timedelta(minutes = 30)
     for uik_id, timekey in odata:
         update_uiks.add(uik_id)
         uik = UIK.objects.get(id=uik_id)
         order_timespan(uik, timekey, span, cookies = cookies)
-        utils.stoppable_sleep(15)
+        utils.stoppable_sleep(sleep_time)
 
 
 @update_stats