Commits

fak3 committed a0430ad

update stats only once after ordering

Comments (0)

Files changed (2)

 
         def orderproc():
             try:
-                for id in uiks:
-                    uik = UIK.objects.get(id=id)
-                    cookies = utils.cookies_simple(self.mframe.sites['fed']['cookies'])
-                    main_utils.order_uik(uik, start, end, cookies)
+                cookies = utils.cookies_simple(self.mframe.sites['fed']['cookies'])
+                main_utils.order_uiks(uiks, start, end, cookies)
             finally:
                 logging.info(u'Отправка заказов завершена')
                 self.start_action_sig.emit(False)
 
 
 @update_stats
+def order_uiks(uik_ids, start, end, cookies, update_uiks):
+    ''' Заказывает много 30-минутных фрагментов по очереди '''
+    for uik in UIK.objects.iter_bulk(id__in=uik_ids):
+        _order_uik(uik, start, end, cookies, update_uiks)
+    
+    
+@update_stats
 def order_uik(uik, start, end, cookies, update_uiks):
     ''' Заказывает много 30-минутных фрагментов по очереди '''
+    _order_uik(uik, start, end, cookies, update_uiks)
+    
+    
+def _order_uik(uik, start, end, cookies, update_uiks):
+    ''' Заказывает много 30-минутных фрагментов по очереди '''
     span = timedelta(minutes = 30)
     t = start
     update_uiks.add(uik.pk)