<commit_before>from core.models import *

def handle(site):
    """ 
    ensure ControllerSiteDeployment object exists for each of the site's SiteDeployment objects
    """
    from core.models import SiteDeployments, Controller, ControllerSiteDeployments 
    from collections import defaultdict
    
    
    # get current controller site deployments	
    ctrl_site_deployments = ControllerSiteDeployments.objects.filter(site_deployment__site = site)
    ctrl_site_deployments_dict = {} 
    for ctrl_site_depl in controller_site_deployments:
        ctrl_site_deployments_dict[ctrl_site_depl.site_deployment] = ctrl_cite_depl

    # get current site deployments
    site_deployments = SiteDeployments.objects.filter(site=site)
 
    # for each site deployment, if there is no controller site deployment create one 
    for site_deployment in site_deployments:
        if site_deployment not in ctrl_site_deployments_dict:
            ctrl_site_deployment = ControllerSiteDeployment(
                site_deployment=site_deployment,
                controller=site_deployment.controller,
            )
            ctrl_site_deployment.save()         <commit_msg>refactor<commit_after>from core.models import *

def handle(site):
    """ 
    ensure ControllerSiteDeployment object exists for each of the site's SiteDeployment objects
    """
    from core.models import SiteDeployments, Controller, ControllerSiteDeployments 
    from collections import defaultdict
    
    # get current controller site deployments	
    ctrl_site_deployments = ControllerSiteDeployments.objects.filter(site_deployment__site = site)
    ctrl_site_deployments_dict = {} 
    for ctrl_site_depl in controller_site_deployments:
        ctrl_site_deployments_dict[ctrl_site_depl.site_deployment] = ctrl_cite_depl

    # get current site deployments
    site_deployments = SiteDeployments.objects.filter(site=site)
 
    # for each site deployment, if there is no controller site deployment create one 
    for site_deployment in site_deployments:
        if site_deployment not in ctrl_site_deployments_dict:
            ctrl_site_deployment = ControllerSiteDeployment(
                site_deployment=site_deployment,
                controller=site_deployment.controller,
            )
            ctrl_site_deployment.save()         
{'fraction_non_alphanumeric': 0.04745470232959448, 'fraction_numerical': 0.0, 'mean_word_length': 3.494186046511628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3741147', 'n_tokens_mistral': 636, 'n_tokens_neox': 601, 'n_words': 148}