def _create_calls(self, count, channel, contacts): """ Creates the given number of missed call events """ calls = [] date = timezone.now() for c in range(0, count): duration = random.randint(10, 30) contact = contacts[c % len(contacts)] contact_urn = contact.urn_objects.values()[0] calls.append( ChannelEvent(channel=channel, org=self.org, event_type='mt_miss', contact=contact, contact_urn=contact_urn, time=date, duration=duration, created_by=self.user, modified_by=self.user)) ChannelEvent.objects.bulk_create(calls) return calls