Skip to content

Commit

Permalink
Filter staff advertiser report by campaign type
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfischer committed Feb 28, 2024
1 parent 6aeb961 commit 68ed246
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions adserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from rest_framework.authtoken.models import Token
from user_agents import parse as parse_user_agent

from .constants import ALL_CAMPAIGN_TYPES
from .constants import CAMPAIGN_TYPES
from .constants import CLICKS
from .constants import FLIGHT_STATE_CURRENT
Expand Down Expand Up @@ -78,6 +79,7 @@
from .models import Advertisement
from .models import Advertiser
from .models import AdvertiserImpression
from .models import Campaign
from .models import Flight
from .models import GeoImpression
from .models import KeywordImpression
Expand Down Expand Up @@ -1414,6 +1416,13 @@ def get_context_data(self, **kwargs):
start_date=context["start_date"],
end_date=context["end_date"],
).filter(advertiser=advertiser)
if context["campaign_type"] in ALL_CAMPAIGN_TYPES:
queryset = queryset.filter(
advertiser__in=Campaign.objects.filter(
campaign_type=context["campaign_type"],
advertiser=advertiser,
).values("advertiser_id")
)
report = self.report(queryset)
report.generate()

Expand All @@ -1432,6 +1441,7 @@ def get_context_data(self, **kwargs):
{
"advertisers": [a for a, _ in advertisers_and_reports],
"advertisers_and_reports": advertisers_and_reports,
"campaign_types": CAMPAIGN_TYPES,
"total_clicks": total_clicks,
"total_cost": total_cost,
"total_views": total_views,
Expand Down

0 comments on commit 68ed246

Please sign in to comment.