Exemplo n.º 1
0
def total():
	Source.objects.all().delete()
	
	google_clicks = 0
	google_impressions = 0
	google_cost = 0

	for current_google in GoogleKeyword.objects.all():
		google_clicks = google_clicks + current_google.clicks
		google_impressions = google_impressions + current_google.impressions
		google_cost = google_cost + current_google.cost
	
	google_model = Source()
	google_model.name = 'Google'
	google_model.clicks = google_clicks
	google_model.impressions = google_impressions
	google_model.cost = round(google_cost,2)
	if not google_model.impressions == 0:
		google_model.CTR = round(google_model.clicks * 100/google_model.impressions,2)
		google_model.CPM = round(google_model.cost * 1000 / google_model.impressions,2)
	if not google_model.clicks == 0:
		google_model.CPC = round(google_model.cost/google_model.clicks,2)
	google_model.save()
Exemplo n.º 2
0
def addUp(google, facebook_adSource):
    Source.objects.filter(name='Facebook').delete()
    Source.objects.filter(name='TOTAL').delete()

    facebook = Source()
    facebook.name = 'Facebook'
    facebook.clicks = facebook_adSource.clicks
    facebook.impressions = facebook_adSource.impressions
    facebook.cost = facebook_adSource.cost
    facebook.CTR = facebook_adSource.CTR
    facebook.CPC = facebook_adSource.CPC
    facebook.CPM = facebook_adSource.CPM
    facebook.save()

    total = Source()
    total.name = 'TOTAL'
    total.clicks = google.clicks + facebook.clicks
    total.impressions = google.impressions + facebook.impressions
    total.cost = google.cost + facebook.cost
    total.cost = round(total.cost, 2)
    if not total.impressions == 0:
        total.CTR = round(total.clicks * 100 / total.impressions, 2)
        total.CPM = round(total.cost * 1000 / total.impressions, 2)
    if not total.clicks == 0:
        total.CPC = round(total.cost / total.clicks, 2)
    total.save()
Exemplo n.º 3
0
def total():
    Source.objects.all().delete()

    google_clicks = 0
    google_impressions = 0
    google_cost = 0

    for current_google in GoogleKeyword.objects.all():
        google_clicks = google_clicks + current_google.clicks
        google_impressions = google_impressions + current_google.impressions
        google_cost = google_cost + current_google.cost

    google_model = Source()
    google_model.name = 'Google'
    google_model.clicks = google_clicks
    google_model.impressions = google_impressions
    google_model.cost = round(google_cost, 2)
    if not google_model.impressions == 0:
        google_model.CTR = round(
            google_model.clicks * 100 / google_model.impressions, 2)
        google_model.CPM = round(
            google_model.cost * 1000 / google_model.impressions, 2)
    if not google_model.clicks == 0:
        google_model.CPC = round(google_model.cost / google_model.clicks, 2)
    google_model.save()
Exemplo n.º 4
0
def addUp(google, facebook_adSource):
	Source.objects.filter(name='Facebook').delete()
	Source.objects.filter(name='TOTAL').delete()

	facebook = Source()
	facebook.name = 'Facebook'
	facebook.clicks = facebook_adSource.clicks
	facebook.impressions = facebook_adSource.impressions
	facebook.cost = facebook_adSource.cost
	facebook.CTR = facebook_adSource.CTR
	facebook.CPC = facebook_adSource.CPC
	facebook.CPM = facebook_adSource.CPM
	facebook.save()
	
	total = Source()
	total.name = 'TOTAL'
	total.clicks = google.clicks + facebook.clicks
	total.impressions = google.impressions + facebook.impressions 
	total.cost = google.cost + facebook.cost
	total.cost = round(total.cost,2)
	if not total.impressions == 0:	
		total.CTR = round(total.clicks * 100/total.impressions,2)
		total.CPM = round(total.cost * 1000/total.impressions,2)
	if not total.clicks == 0:		
		total.CPC = round(total.cost/total.clicks,2)
	total.save()