@first_event_received.connect(weak=False)
def record_first_event(project, group, **kwargs):
 (rows_affected, created) = OrganizationOnboardingTask.objects.create_or_update(organization_id=project.organization_id, task=OnboardingTask.FIRST_EVENT, status=OnboardingTaskStatus.PENDING, values={'status': OnboardingTaskStatus.COMPLETE, 'project_id': project.id, 'date_completed': project.first_event, 'data': {'platform': group.platform}})
 if ((not rows_affected) and (not created)):
  try:
   oot = OrganizationOnboardingTask.objects.filter(organization_id=project.organization_id, task=OnboardingTask.FIRST_EVENT)[0]
  except IndexError:
   return
  if ((oot.project_id != project.id) and (oot.data.get('platform', group.platform) != group.platform)):
   OrganizationOnboardingTask.objects.create_or_update(organization_id=project.organization_id, task=OnboardingTask.SECOND_PLATFORM, status=OnboardingTaskStatus.PENDING, values={'status': OnboardingTaskStatus.COMPLETE, 'project_id': project.id, 'date_completed': project.first_event, 'data': {'platform': group.platform}})

@ first_event_received . connect ( weak = False ) def record_first_event ( project , group , ** kwargs ) : ( rows_affected , created ) = OrganizationOnboardingTask . objects . create_or_update ( organization_id = project . organization_id , task = OnboardingTask . FIRST_EVENT , status = OnboardingTaskStatus . PENDING , values = { 'status' : OnboardingTaskStatus . COMPLETE , 'project_id' : project . id , 'date_completed' : project . first_event , 'data' : { 'platform' : group . platform } } ) if ( ( not rows_affected ) and ( not created ) ) : try : oot = OrganizationOnboardingTask . objects . filter ( organization_id = project . organization_id , task = OnboardingTask . FIRST_EVENT ) [ 0 ] except IndexError : return if ( ( oot . project_id != project . id ) and ( oot . data . get ( 'platform' , group . platform ) != group . platform ) ) : OrganizationOnboardingTask . objects . create_or_update ( organization_id = project . organization_id , task = OnboardingTask . SECOND_PLATFORM , status = OnboardingTaskStatus . PENDING , values = { 'status' : OnboardingTaskStatus . COMPLETE , 'project_id' : project . id , 'date_completed' : project . first_event , 'data' : { 'platform' : group . platform } } )
requires up to 2 database calls .