-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advertiser domain report #968
Open
davidfischer
wants to merge
1
commit into
main
Choose a base branch
from
davidfischer/domain-report
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
adserver/templates/adserver/reports/advertiser-domain.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% extends "adserver/reports/advertiser.html" %} | ||
{% load humanize %} | ||
{% load i18n %} | ||
|
||
|
||
{% block title %}{% trans 'Advertiser Domain Report' %} - {{ advertiser }}{% endblock %} | ||
|
||
|
||
{% block heading %} | ||
{% blocktrans %}Advertiser Domain Report for {{ advertiser }}{% endblocktrans %} | ||
{% endblock heading %} | ||
|
||
{% block breadcrumbs %} | ||
{{ block.super }} | ||
<li class="breadcrumb-item active">{% trans 'Advertiser Domain Report' %}</li> | ||
{% endblock breadcrumbs %} | ||
|
||
|
||
{% block additional_filters %} | ||
{{ block.super }} | ||
|
||
<div class="col-xl-3 col-md-6 col-12 mb-3"> | ||
<label class="col-form-label" for="id_flight">{% trans 'Flight' %}</label> | ||
<select class="form-control" name="flight" id="id_flight"> | ||
<option value="">{% trans 'All flights' %}</option> | ||
{% for flight in flights %} | ||
<option value="{{ flight.slug }}"{% if flight.slug == request.GET.flight %} selected{% endif %}>{{ flight.name }}</option> | ||
{% endfor %} | ||
</select> | ||
</div> | ||
|
||
{% endblock additional_filters %} | ||
|
||
|
||
{% block explainer %} | ||
<section class="mb-5"> | ||
<h3>{% trans 'About this report' %}</h3> | ||
<p>{% trans 'This report shows the top domains where your ads are shown.' %}</p> | ||
<em> | ||
{% blocktrans %}This report shows the <strong>top {{ limit }} domains</strong> and updates daily. All previous days data is complete.{% endblocktrans %} | ||
</em> | ||
</section> | ||
{% endblock explainer %} | ||
|
||
|
||
{% block report %}{% endblock report %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ | |
from .models import Advertiser | ||
from .models import AdvertiserImpression | ||
from .models import Campaign | ||
from .models import DomainImpression | ||
from .models import Flight | ||
from .models import GeoImpression | ||
from .models import KeywordImpression | ||
|
@@ -107,6 +108,7 @@ | |
from .models import RegionTopicImpression | ||
from .models import Topic | ||
from .models import UpliftImpression | ||
from .reports import AdvertiserDomainReport | ||
from .reports import AdvertiserPublisherReport | ||
from .reports import AdvertiserReport | ||
from .reports import OptimizedAdvertiserReport | ||
|
@@ -1639,6 +1641,61 @@ def get_context_data(self, **kwargs): | |
return context | ||
|
||
|
||
class AdvertiserDomainReportView(AdvertiserAccessMixin, BaseReportView): | ||
LIMIT = 50 | ||
DATA_COLLECTION_START_DATE = datetime( | ||
year=2024, month=12, day=1, tzinfo=timezone.get_current_timezone() | ||
) | ||
|
||
impression_model = DomainImpression | ||
template_name = "adserver/reports/advertiser-domain.html" | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super().get_context_data(**kwargs) | ||
|
||
advertiser_slug = kwargs.get("advertiser_slug", "") | ||
advertiser = get_object_or_404(Advertiser, slug=advertiser_slug) | ||
|
||
flight_slug = self.request.GET.get("flight", "") | ||
flight = Flight.objects.filter( | ||
campaign__advertiser=advertiser, slug=flight_slug | ||
).first() | ||
|
||
if context["start_date"] < self.DATA_COLLECTION_START_DATE: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a nice affordance. |
||
messages.info( | ||
self.request, | ||
_( | ||
"Data for the domain report started being collected in %s. Data for this date range may be incomplete." | ||
) | ||
% (self.DATA_COLLECTION_START_DATE.strftime("%B %Y")), | ||
) | ||
|
||
queryset = self.get_queryset( | ||
advertiser=advertiser, | ||
flight=flight, | ||
start_date=context["start_date"], | ||
end_date=context["end_date"], | ||
) | ||
|
||
report = AdvertiserDomainReport( | ||
queryset, | ||
max_results=self.LIMIT, | ||
) | ||
report.generate() | ||
|
||
context.update( | ||
{ | ||
"advertiser": advertiser, | ||
"report": report, | ||
"flights": Flight.objects.filter( | ||
campaign__advertiser=advertiser | ||
).order_by("-start_date"), | ||
} | ||
) | ||
|
||
return context | ||
|
||
|
||
class StaffAdvertiserReportView(BaseReportView): | ||
"""A report aggregating all advertisers.""" | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to test this behind a staff flag before rolling it out more widely?