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

feat(nimbus): add segments to new Nimbus UI summary page #11563

Merged
merged 2 commits into from
Oct 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ <h4>Overview</h4>
{% endfor %}
</td>
</tr>
<tr>
<th>Segments</th>
<td colspan="3">
{% for segment, url in segment_links %}
<a href="{{ url }}" target="_blank" rel="noopener noreferrer">{{ segment.title|remove_underscores }}</a>
{% if not forloop.last %},{% endif %}
{% empty %}
<span class="text-danger">Not set</span>
{% endfor %}
</td>
</tr>
<tr>
<th>Team projects</th>
<td>
Expand Down
16 changes: 14 additions & 2 deletions experimenter/experimenter/nimbus_ui_new/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ def setUp(self):
application="firefox-desktop",
primary_outcomes=["outcome1", "outcome2"],
secondary_outcomes=["outcome3", "outcome4"],
segments=["segment1", "segment2"],
risk_brand=True,
qa_status="NOT_SET",
takeaways_qbr_learning=True,
Expand All @@ -918,7 +919,7 @@ def test_render_to_response(self):
self.assertEqual(response.context["experiment"], self.experiment)
self.assertIn("RISK_QUESTIONS", response.context)

def test_outcome_links(self):
def test_outcome_and_segment_links(self):
response = self.client.get(
reverse("nimbus-new-detail", kwargs={"slug": self.experiment.slug}),
)
Expand All @@ -942,13 +943,24 @@ def test_outcome_links(self):
"https://mozilla.github.io/metric-hub/outcomes/firefox-desktop/outcome4",
),
]
expected_segment_links = [
(
"segment1",
"https://mozilla.github.io/metric-hub/segments/firefox_desktop/#segment1",
),
(
"segment2",
"https://mozilla.github.io/metric-hub/segments/firefox_desktop/#segment2",
),
]

self.assertEqual(
response.context["primary_outcome_links"], expected_primary_links
)
self.assertEqual(
response.context["secondary_outcome_links"], expected_secondary_links
)
self.assertEqual(response.context["segment_links"], expected_segment_links)

def test_qa_edit_mode_get(self):
response = self.client.get(
Expand Down Expand Up @@ -1114,7 +1126,7 @@ def test_get_renders_page(self):
)
self.assertEqual(response.status_code, 200)

def test_post_updates_metrics(self):
def test_post_updates_metrics_and_segments(self):
application = NimbusExperiment.Application.DESKTOP
experiment = NimbusExperimentFactory.create_with_lifecycle(
NimbusExperimentFactory.Lifecycles.CREATED,
Expand Down
19 changes: 16 additions & 3 deletions experimenter/experimenter/nimbus_ui_new/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,32 @@ def get(self, *args, **kwargs):


def build_experiment_context(experiment):
doc_base_url = "https://mozilla.github.io/metric-hub/outcomes/"
outcome_doc_base_url = "https://mozilla.github.io/metric-hub/outcomes/"
primary_outcome_links = [
(outcome, f"{doc_base_url}{experiment.application}/{outcome}")
(outcome, f"{outcome_doc_base_url}{experiment.application}/{outcome}")
for outcome in experiment.primary_outcomes
]
secondary_outcome_links = [
(outcome, f"{doc_base_url}{experiment.application}/{outcome}")
(outcome, f"{outcome_doc_base_url}{experiment.application}/{outcome}")
for outcome in experiment.secondary_outcomes
]

segment_doc_base_url = "https://mozilla.github.io/metric-hub/segments/"
segment_links = [
(
segment,
# ruff prefers this implicit syntax for concatenating strings
f"{segment_doc_base_url}"
f"{experiment.application.replace('-', '_')}/"
f"#{segment}",
RJAK11 marked this conversation as resolved.
Show resolved Hide resolved
)
for segment in experiment.segments
]
context = {
"RISK_QUESTIONS": RISK_QUESTIONS,
"primary_outcome_links": primary_outcome_links,
"secondary_outcome_links": secondary_outcome_links,
"segment_links": segment_links,
}
return context

Expand Down