-
Notifications
You must be signed in to change notification settings - Fork 28
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
Bundle analysis: create timeseries dataset upon upload #601
Changes from all commits
185a6db
b207165
e21556c
bdcafe1
8907367
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||||||||||||||
import logging | ||||||||||||||||||
import uuid | ||||||||||||||||||
|
||||||||||||||||||
from django.conf import settings | ||||||||||||||||||
from rest_framework import serializers, status | ||||||||||||||||||
from rest_framework.exceptions import NotAuthenticated | ||||||||||||||||||
from rest_framework.permissions import BasePermission | ||||||||||||||||||
|
@@ -21,6 +22,7 @@ | |||||||||||||||||
from reports.models import CommitReport | ||||||||||||||||||
from services.archive import ArchiveService | ||||||||||||||||||
from services.redis_configuration import get_redis_connection | ||||||||||||||||||
from timeseries.models import Dataset, MeasurementName | ||||||||||||||||||
from upload.helpers import dispatch_upload_task, generate_upload_sentry_metrics_tags | ||||||||||||||||||
from upload.views.base import ShelterMixin | ||||||||||||||||||
from upload.views.helpers import get_repository_from_string | ||||||||||||||||||
|
@@ -142,4 +144,29 @@ def post(self, request): | |||||||||||||||||
is_shelter_request=self.is_shelter_request(), | ||||||||||||||||||
), | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
if settings.TIMESERIES_ENABLED: | ||||||||||||||||||
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. do we want to jump right to creating or do we want to create if it doesn't already exist / isn't backfilled? the latter is what is done for coverage i think codecov-api/timeseries/helpers.py Lines 341 to 348 in 66ec9fa
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. I think its better to create it as soon as possible then it is to create it when we fetch the measurements, that way we don't miss out on a datapoint in the general flow of upload->process->query since the process step is when we insert the measurement datapoints which relies on the presence of the dataset rows being inserted. With the coverage measurements its ok because when querying and not having dataset created it can still compute and return measurements on the fly and then do a backfill. Also with BA we don't plan on doing backfills because the previous bundle schemas don't support it. 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. oh on second read the code is |
||||||||||||||||||
supported_bundle_analysis_measurement_types = [ | ||||||||||||||||||
MeasurementName.BUNDLE_ANALYSIS_ASSET_SIZE, | ||||||||||||||||||
MeasurementName.BUNDLE_ANALYSIS_FONT_SIZE, | ||||||||||||||||||
MeasurementName.BUNDLE_ANALYSIS_IMAGE_SIZE, | ||||||||||||||||||
MeasurementName.BUNDLE_ANALYSIS_JAVASCRIPT_SIZE, | ||||||||||||||||||
MeasurementName.BUNDLE_ANALYSIS_REPORT_SIZE, | ||||||||||||||||||
MeasurementName.BUNDLE_ANALYSIS_STYLESHEET_SIZE, | ||||||||||||||||||
] | ||||||||||||||||||
for measurement_type in supported_bundle_analysis_measurement_types: | ||||||||||||||||||
_, created = Dataset.objects.get_or_create( | ||||||||||||||||||
name=measurement_type.value, | ||||||||||||||||||
repository_id=repo.pk, | ||||||||||||||||||
) | ||||||||||||||||||
if created: | ||||||||||||||||||
log.info( | ||||||||||||||||||
"Created new timescale dataset for bundle analysis", | ||||||||||||||||||
extra=dict( | ||||||||||||||||||
commit=commit.commitid, | ||||||||||||||||||
repoid=repo.repoid, | ||||||||||||||||||
measurement_type=measurement_type, | ||||||||||||||||||
), | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
return Response({"url": url}, status=201) |
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.
jw, is it possible to parametrize this and the other test with the pytest.mark.parametrize() decorator?
codecov-api/services/tests/test_repo_providers.py
Line 41 in 7fc9bc5