Skip to content
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

Add publisher eCPM to report table #833

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions adserver/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ def generate(self):
results[index]["revenue_share"] = results[index]["revenue"] * (
applied_rev_share / 100.0
)
results[index]["revenue_share_ecpm"] = calculate_ecpm(
results[index]["revenue_share"], results[index]["views"]
)
results[index]["our_revenue"] = (
results[index]["revenue"] - results[index]["revenue_share"]
)
Expand Down Expand Up @@ -301,6 +304,9 @@ def calculate_totals(self):
self.total["revenue_share"] = sum(
result["revenue_share"] for result in self.results
)
self.total["revenue_share_ecpm"] = calculate_ecpm(
self.total["revenue_share"], self.total["views"]
)
self.total["our_revenue"] = self.total["revenue"] - self.total["revenue_share"]
self.total["ctr"] = calculate_ctr(self.total["clicks"], self.total["views"])
self.total["ecpm"] = calculate_ecpm(self.total["revenue"], self.total["views"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
<th class="text-right"><strong>{% blocktrans %}<abbr title="Click through rate">CTR</abbr>{% endblocktrans %}</strong></th>
<th class="text-right"><strong>{% blocktrans %}<abbr title="% of traffic that viewed the ad">View Rate</abbr>{% endblocktrans %}</strong></th>
{% if publisher.saas %}
<th class="text-right"><strong>{% blocktrans %}<abbr title="Billable API requests">API Requests</abbr>{% endblocktrans %}</strong></th>
<th class="text-right"><strong>{% blocktrans %}<abbr title="Billable API requests">API Requests</abbr>{% endblocktrans %}</strong></th>
{% else %}
<th class="text-right"><strong>{% trans 'Revenue' %}</strong></th>
<th class="text-right"><strong>{% blocktrans %}<abbr title="Effective publisher revenue per thousand impressions">eCPM</abbr>{% endblocktrans %}</strong></th>
<th class="text-right"><strong>{% trans 'Revenue' %}</strong></th>
{% endif %}
{% if "adserver.staff_publisher_fields" in perms %}
<th class="text-right staff-only"><strong>{% trans 'Our&nbsp;Rev' %}</strong></th>
Expand All @@ -34,6 +35,7 @@
{% if publisher.saas %}
<td class="text-right">{{ result.decisions|intcomma }}</td>
{% else %}
<td class="text-right">${{ result.revenue_share_ecpm|floatformat:2|intcomma }}</td>
<td class="text-right">${{ result.revenue_share|floatformat:2|intcomma }}</td>
{% endif %}
{% if "adserver.staff_publisher_fields" in perms %}
Expand All @@ -54,6 +56,7 @@
{% if publisher.saas %}
<td class="text-right"><strong>{{ report.total.decisions|intcomma }}</strong></td>
{% else %}
<td class="text-right"><strong>${{ report.total.revenue_share_ecpm|floatformat:2|intcomma }}</strong></td>
<td class="text-right"><strong>${{ report.total.revenue_share|floatformat:2|intcomma }}</strong></td>
{% endif %}
{% if "adserver.staff_publisher_fields" in perms %}
Expand Down
4 changes: 2 additions & 2 deletions adserver/tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def test_publisher_report_contents(self):
self.assertContains(response, "CSV Export")

# Check staff fields not present since the permission wasn't configured
self.assertNotContains(response, "eCPM")
self.assertNotContains(response, "Fill Rate")

# Add the permission
self.staff_user.user_permissions.add(
Expand All @@ -567,7 +567,7 @@ def test_publisher_report_contents(self):
)
)
response = self.client.get(url)
self.assertContains(response, "eCPM")
self.assertContains(response, "Fill Rate")

def test_publisher_placement_report_contents(self):
self.client.force_login(self.staff_user)
Expand Down
Loading