Ë
    jJøhV  ã                   óx   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
Z
 e	«       Z e«       Z G d„ d«      Zy)	é    )Úsample)Ú
app_logger)ÚUserAttributes)ÚExperimentService)ÚUserAttributeServiceNc                   ó   — e Zd Zd„ Zd„ Zy)ÚGroupAssignmentc                 ó¼  — g }i }t         j                  j                  «       }|D ]  }|j                  }|||<   Œ |D ]k  }	 |j                  }||   }t	        j
                  |j                  «      }	|	j                  d«      }
t        j                  ||
«      r|j                  |«       Œm |S # t        $ r%}t        j                  d› d|› «       Y d }~Œ-d }~ww xY w)NÚ	conditionzJGroup Assignment: Exception occurred while fetching attribute for user_id z. Error message: )r   ÚqueryÚget_all_user_attributesÚuser_idÚjsonÚloadsÚvalueÚgetÚuser_attribute_serviceÚ*is_user_attribute_fulfilling_the_conditionÚappendÚ	Exceptionr   Úerror)ÚselfÚexperiences_without_groupÚuser_attribute_conditionÚeligible_experiencesÚuser_attribute_dictÚuser_attributesÚuser_attributer   Ú
experienceÚcondition_valueÚconditions_listr   s               úN/var/www/dostadmin/dostadmin/experiment_categories_handler/group_assignment.pyÚ5get_eligible_experience_for_user_attribute_conditionszEGroupAssignment.get_eligible_experience_for_user_attribute_conditions   s  € ð  "ÐØ ÐÜ(×.Ñ.×FÑFÓHˆã-ˆNØ$×,Ñ,ˆGØ+9Ð Ò(ð .ó 4ˆJðØ$×,Ñ,Ø!4°WÑ!=Ü"&§*¡*Ð-E×-KÑ-KÓ"LØ"1×"5Ñ"5°kÓ"BÜ)×TÑTØ" Oôð )×/Ñ/°
Ô;ð
 ð 4ð  $Ð#øô ò Ü× Ñ Ø`ÐahÐ`iÐizð  |Að  {Bð  C÷ñ ûðús   ÁA(B-Â-	CÂ6CÃCc                 óÊ  — g }t        |«      }t        |«      D ]Â  \  }}t        |j                  «      dz  }t        ||z  «      }t	        ||«      }	|D 
cg c]	  }
|
|	vsŒ|
‘Œ }}
|}|	D ]+  }|j                  ||j                  |j                  dœ«       Œ- |t        |«      dz
  k(  sŒ|sŒ“|D ]+  }|j                  ||j                  |j                  dœ«       Œ- ŒÄ |S c c}
w )Néd   )r   Úexperiment_idÚ
group_nameé   )ÚlenÚ	enumerateÚintr   r   r   r&   Úexperiment_group_name)r   ÚexperiencesÚuser_percentage_conditionsr   Únum_experiencesÚindexr   Ú
percentageÚnum_assignedÚassigned_experiencesÚexpÚremaining_experiencesr   s                r"   Ú6get_eligible_experience_for_user_percentage_conditionszFGroupAssignment.get_eligible_experience_for_user_percentage_conditions,   s  € ð  "ÐÜ˜kÓ*ˆÜ )Ð*DÖ EÑˆE9Ü˜YŸ_™_Ó-°Ñ3ˆJÜ˜°Ñ;Ó<ˆLÜ#)¨+°|Ó#DÐ á*ó%Ù*˜¨cÐ9MÒ.M’˜{ð "ð %ð 0ˆKã2
Ø$×+Ñ+à&0Ø)2×)@Ñ)@Ø&/×&EÑ&Eñõð 3ð œÐ6Ó7¸!Ñ;Ó;Ò@UÛ"7JØ(×/Ñ/à*4Ø-6×-DÑ-DØ*3×*IÑ*Iñõñ #8ð' !Fð8 $Ð#ùò1%s   Á	C ÁC N)Ú__name__Ú
__module__Ú__qualname__r#   r6   © ó    r"   r	   r	      s   „ ò$ó:!$r;   r	   )Úrandomr   Ú	dostadminr   Ú"dostadmin.db_model.user_attributesr   Ú0dostadmin.services.experiment.experiment_servicer   Ú9dostadmin.services.user_attributes.user_attribute_servicer   r   r   Úexperiment_servicer	   r:   r;   r"   Ú<module>rB      s7   ðÝ Ý  Ý =Ý Nõó á-Ó/Ð Ù&Ó(Ð ÷?$ò ?$r;   