in treeherder/webapp/api/bug_creation.py [0:0]
def get_queryset(self):
"""
Gets a set of bug suggestions for this job
"""
path = self.request.query_params.get("path")
if path.startswith("org.mozilla."):
path = (path.split("#"))[0]
path = (path.split("."))[-1]
path = path.replace("\\", "/")
# Drop parameters
path = (path.split("?"))[0]
file = (path.split("/"))[-1]
file_name_parts = file.split(".")
file_without_extension = file_name_parts[0] + ("." if len(file_name_parts) > 1 else "")
queryset = (
FilesBugzillaMap.objects.select_related("bugzilla_component")
.filter(path__endswith=path)
.exclude(path__startswith="testing/web-platform/meta/")
.values("bugzilla_component__product", "bugzilla_component__component")
.distinct()
)
if len(queryset) == 0:
# E.g. web-platform-tests ("wpt") can use test files generated from
# other files which just have different file extensions.
path_without_extension = (path.rsplit("/", 1))[0] + "/" + file_without_extension
queryset = (
FilesBugzillaMap.objects.select_related("bugzilla_component")
.filter(path__contains=path_without_extension)
.exclude(path__startswith="testing/web-platform/meta/")
.values("bugzilla_component__product", "bugzilla_component__component")
.distinct()
)
if len(queryset) > 0:
return self.filter_product_component(queryset)
queryset = (
FilesBugzillaMap.objects.select_related("bugzilla_component")
.filter(file_name=file)
.values("bugzilla_component__product", "bugzilla_component__component")
.distinct()
)
if len(queryset) > 0:
return self.filter_product_component(queryset)
queryset = (
FilesBugzillaMap.objects.select_related("bugzilla_component")
.filter(file_name__startswith=file_without_extension)
.values("bugzilla_component__product", "bugzilla_component__component")
.distinct()
)
return self.filter_product_component(queryset)