def main(): # check for expired reserve_untils and release them now = datetime.now() Message_responder.objects.filter(reserved_until__lt=now).update(reserved_by=None, reserved_until=None) if len(sys.argv) == 2: responder_ids = sys.argv[1].split(',') else: # get every possible responder and let the script figure out which messages to play, etc. responder_ids = Message_responder.objects.values_list('user', flat=True).distinct() router.route_calls(responder_ids, IVR_SCRIPT, CALLID_VAR_VAL)
def main(): # check for expired reserve_untils and release them now = datetime.now() Message_responder.objects.filter(reserved_until__lt=now).update( reserved_by=None, reserved_until=None) if len(sys.argv) == 2: responder_ids = sys.argv[1].split(',') else: # get every possible responder and let the script figure out which messages to play, etc. responder_ids = Message_responder.objects.values_list( 'user', flat=True).distinct() router.route_calls(responder_ids, IVR_SCRIPT, CALLID_VAR_VAL)
def make_calls(): call_ids = [] # Get all calls within the last INTERVAL interval = timedelta(minutes=INTERVAL_MINS) now = datetime.now() # get calls in the last INTERVAL calls = Call.objects.filter( complete=False, date__gte=now - interval, date__lt=now, dialer__machine_id=settings.MACHINE_ID).order_by('priority') for call in calls: # The way it works with backups: If we encounter a call scheduled for this run for this # subject, only use it if the first priority call time(s) up until this point were not # completed or made up if call.priority == 1: # if there is a P1, call it call_ids.append(call.id) else: # only make a P2 call if there have been unfullfilled P1s for this survey past_p1_cnt = Call.objects.filter( subject=call.subject, survey=call.survey, priority=1, date__lt=now - interval, dialer__machine_id=settings.MACHINE_ID).count() past_complete_cnt = Call.objects.filter( subject=call.subject, survey=call.survey, date__lt=now - interval, complete=True, dialer__machine_id=settings.MACHINE_ID).count() if past_p1_cnt > past_complete_cnt: call_ids.append(call.id) router.route_calls(call_ids, IVR_SCRIPT, CALLID_VAR_VAL)
def make_calls(): call_ids = [] # Get all calls within the last INTERVAL interval = timedelta(minutes=INTERVAL_MINS) now = datetime.now() # get calls in the last INTERVAL calls = Call.objects.filter( complete=False, date__gte=now - interval, date__lt=now, dialer__machine_id=settings.MACHINE_ID ).order_by("priority") for call in calls: # The way it works with backups: If we encounter a call scheduled for this run for this # subject, only use it if the first priority call time(s) up until this point were not # completed or made up if call.priority == 1: # if there is a P1, call it call_ids.append(call.id) else: # only make a P2 call if there have been unfullfilled P1s for this survey past_p1_cnt = Call.objects.filter( subject=call.subject, survey=call.survey, priority=1, date__lt=now - interval, dialer__machine_id=settings.MACHINE_ID, ).count() past_complete_cnt = Call.objects.filter( subject=call.subject, survey=call.survey, date__lt=now - interval, complete=True, dialer__machine_id=settings.MACHINE_ID, ).count() if past_p1_cnt > past_complete_cnt: call_ids.append(call.id) router.route_calls(call_ids, IVR_SCRIPT, CALLID_VAR_VAL)