Пример #1
0
def create_metric(name=None, slug=None): 
    """ Create a new type of metric to track """ 

    # See if this metric already exists 
    existing = Metric.objects.filter(name=name, slug=slug) 

    if existing: 
        return False 
    else: 
        new_metric = Metric(name=name, slug=slug)
        new_metric.save()
        return new_metric 
Пример #2
0
def create_metric(name, slug):
    """ Create a new type of metric to track """

    # This should be a NOOP for the non-database-backed backends
    if not should_create_models():
        return

    # See if this metric already exists
    existing = Metric.objects.filter(name=name, slug=slug)

    if existing:
        return False
    else:
        new_metric = Metric(name=name, slug=slug)
        new_metric.save()
        return new_metric
Пример #3
0
def create_metric(name, slug):
    """ Create a new type of metric to track """

    # This should be a NOOP for the non-database-backed backends
    if not should_create_models():
        return

    # See if this metric already exists
    existing = Metric.objects.filter(name=name, slug=slug)

    if existing:
        return False
    else:
        new_metric = Metric(name=name, slug=slug)
        new_metric.save()
        return new_metric
Пример #4
0
def create_metric(name, slug): 
    """ Create a new type of metric to track """ 

    # Make this a NOOP for the mixpanel backend 
    backend = get_backend() 
    if backend == 'app_metrics.backends.mixpanel': 
        return 

    # See if this metric already exists 
    existing = Metric.objects.filter(name=name, slug=slug) 

    if existing: 
        return False 
    else: 
        new_metric = Metric(name=name, slug=slug)
        new_metric.save()
        return new_metric 
Пример #5
0
def create_metric(name, slug):
    """ Create a new type of metric to track """

    # Make this a NOOP for the mixpanel backend
    backend = get_backend()
    if backend == 'app_metrics.backends.mixpanel':
        return

    # See if this metric already exists
    existing = Metric.objects.filter(name=name, slug=slug)

    if existing:
        return False
    else:
        new_metric = Metric(name=name, slug=slug)
        new_metric.save()
        return new_metric
def create_metric(**kwargs):
    """ Create a new type of metric to track """

    # This should be a NOOP for the non-database-backed backends
    if not should_create_models():
        return

    # See if this metric already exists
    assert len(kwargs.keys()), "Missing keys"

    existing = Metric.objects.filter(**kwargs)
    if existing:
        return False
    else:
        new_metric = Metric(**kwargs)
        new_metric.save()
        return new_metric