Skip to content

Commit 8eb2efc

Browse files
chore(nimbus): use cached dates in csv reports (#13818)
Because * Generating the CSV report for all current/past experiments can be very slow * One of the slowest parts is looking up all the start/end dates * Since we added the CSV report, we have added cache fields for both start/end date * Using the cached fields should greatly speedup the CSV report generation This commit * Switches the CSV report to use the cached start/end dates fixes #13810
1 parent efa49ae commit 8eb2efc

File tree

4 files changed

+21
-49
lines changed

4 files changed

+21
-49
lines changed

docs/experimenter/openapi-schema.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4073,17 +4073,19 @@
40734073
"type": "string",
40744074
"readOnly": true
40754075
},
4076-
"start_date": {
4076+
"_start_date": {
40774077
"type": "string",
4078-
"readOnly": true
4078+
"format": "date",
4079+
"nullable": true
40794080
},
40804081
"enrollment_duration": {
40814082
"type": "string",
40824083
"readOnly": true
40834084
},
4084-
"end_date": {
4085+
"_end_date": {
40854086
"type": "string",
4086-
"readOnly": true
4087+
"format": "date",
4088+
"nullable": true
40874089
},
40884090
"results_url": {
40894091
"type": "string",

docs/experimenter/swagger-ui.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4085,17 +4085,19 @@
40854085
"type": "string",
40864086
"readOnly": true
40874087
},
4088-
"start_date": {
4088+
"_start_date": {
40894089
"type": "string",
4090-
"readOnly": true
4090+
"format": "date",
4091+
"nullable": true
40914092
},
40924093
"enrollment_duration": {
40934094
"type": "string",
40944095
"readOnly": true
40954096
},
4096-
"end_date": {
4097+
"_end_date": {
40974098
"type": "string",
4098-
"readOnly": true
4099+
"format": "date",
4100+
"nullable": true
40994101
},
41004102
"results_url": {
41014103
"type": "string",

experimenter/experimenter/experiments/api/v5/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,9 +1099,9 @@ class Meta:
10991099
"experiment_name",
11001100
"owner",
11011101
"feature_configs",
1102-
"start_date",
1102+
"_start_date",
11031103
"enrollment_duration",
1104-
"end_date",
1104+
"_end_date",
11051105
"results_url",
11061106
"experiment_summary",
11071107
"rollout",

experimenter/experimenter/experiments/tests/api/v5/test_serializers/test_nimbus_experiment_csv_serializer.py

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,20 @@
1111

1212

1313
class TestNimbusExperimentCsvSerializer(TestCase):
14-
def test_serializer_outputs_expected_schema(self):
15-
application = NimbusExperiment.Application.DESKTOP
16-
feature_config = NimbusFeatureConfigFactory.create(application=application)
17-
18-
experiment = NimbusExperimentFactory.create(
19-
application=application, feature_configs=[feature_config]
20-
)
21-
22-
serializer = NimbusExperimentCsvSerializer(experiment)
23-
self.assertDictEqual(
24-
serializer.data,
25-
{
26-
"launch_month": experiment.launch_month,
27-
"product_area": experiment.application.value,
28-
"experiment_name": experiment.name,
29-
"owner": experiment.owner.email,
30-
"feature_configs": feature_config.name,
31-
"start_date": experiment.start_date,
32-
"enrollment_duration": experiment.enrollment_duration,
33-
"end_date": experiment.end_date,
34-
"results_url": "",
35-
"experiment_summary": experiment.experiment_url,
36-
"rollout": experiment.is_rollout,
37-
"hypothesis": experiment.hypothesis,
38-
"takeaways_metric_gain": experiment.takeaways_metric_gain,
39-
"takeaways_gain_amount": experiment.takeaways_gain_amount,
40-
"takeaways_qbr_learning": experiment.takeaways_qbr_learning,
41-
"takeaways_summary": experiment.takeaways_summary,
42-
},
43-
)
14+
maxDiff = None
4415

4516
def test_serializer_outputs_expected_schema_with_results_link(self):
4617
application = NimbusExperiment.Application.DESKTOP
4718
feature_config = NimbusFeatureConfigFactory.create(application=application)
4819

4920
experiment = NimbusExperimentFactory.create_with_lifecycle(
50-
NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_APPROVE,
21+
NimbusExperimentFactory.Lifecycles.ENDING_APPROVE_APPROVE,
5122
application=application,
5223
feature_configs=[feature_config],
24+
start_date=datetime.date(2019, 5, 1),
25+
end_date=datetime.date(2019, 5, 2),
5326
)
54-
experiment.changes.all().filter(
55-
old_status=NimbusExperiment.Status.DRAFT,
56-
new_status=NimbusExperiment.Status.LIVE,
57-
).update(
58-
changed_on=datetime.date(2019, 5, 1),
59-
)
27+
6028
serializer = NimbusExperimentCsvSerializer(experiment)
6129
self.assertDictEqual(
6230
serializer.data,
@@ -66,9 +34,9 @@ def test_serializer_outputs_expected_schema_with_results_link(self):
6634
"experiment_name": experiment.name,
6735
"owner": experiment.owner.email,
6836
"feature_configs": feature_config.name,
69-
"start_date": experiment.start_date,
37+
"_start_date": "2019-05-01",
7038
"enrollment_duration": experiment.enrollment_duration,
71-
"end_date": experiment.end_date,
39+
"_end_date": "2019-05-02",
7240
"results_url": f"{experiment.experiment_url}results",
7341
"experiment_summary": experiment.experiment_url,
7442
"rollout": experiment.is_rollout,

0 commit comments

Comments
 (0)