Permalink
Browse files

added workaround to annotate through 3 field levels only in the inclu…

…ded case
  • Loading branch information...
1 parent e8a9e1f commit 0ec0d6b18cc72fbe9000c0ea1a444060040c9135 @camd camd committed Apr 10, 2013
Showing with 34 additions and 13 deletions.
  1. +7 −0 docs/releasenotes.rst
  2. +21 −7 moztrap/model/library/api.py
  3. +6 −6 moztrap/settings/default.py
@@ -2,6 +2,13 @@ Release Notes
=============
+Version 1.4.5.4
+---------------
+*still beta
+
+* **Scalability fixes around editing huge test suites**
+
+
Version 1.4.5
-------------
*release date - 3/28/2013*
@@ -328,7 +328,12 @@ class CaseSelectionResource(BaseSelectionResource):
productversion = fields.ForeignKey(
ProductVersionResource, "productversion")
tags = fields.ToManyField(TagResource, "tags", full=True)
- created_by = fields.ForeignKey(UserResource, "created_by", full=True, null=True)
+ created_by = fields.ForeignKey(
+ UserResource,
+ "created_by",
+ full=True,
+ null=True,
+ )
class Meta:
queryset = CaseVersion.objects.filter(latest=True).select_related(
@@ -351,9 +356,20 @@ class Meta:
ordering = ["case"]
- # def build_filters(self, filters=None):
- #
- # .order_by("case__suitecases__order")
+
+ def apply_filters(self, request, applicable_filters,
+ applicable_excludes={}):
+ """
+ Workaround to add annotation of order only where we need it.
+ There is a bug that you can't annotate through 3 levels.
+ """
+ req = super(CaseSelectionResource, self).apply_filters(request,
+ applicable_filters,
+ applicable_excludes)
+ if not len(applicable_excludes):
+ return req.annotate(case_order=Max("case__suitecases__order"))
+ else:
+ return req
def dehydrate(self, bundle):
"""Add some convenience fields to the return JSON."""
@@ -364,9 +380,7 @@ def dehydrate(self, bundle):
bundle.data["product"] = {"id": unicode(case.product_id)}
if "case__suites" in bundle.request.GET.keys():
- bundle.data["order"] = case.suitecases.get(
- suite_id=int(bundle.request.GET["case__suites"])
- ).order
+ bundle.data["order"] = bundle.obj.case_order
else:
bundle.data["order"] = None
@@ -16,9 +16,9 @@
except NameError:
HMAC_KEYS = {"default": SECRET_KEY}
-LOGGING["handlers"]["null"] = {
- 'level': 'DEBUG',
- 'class': 'django.utils.log.NullHandler',
- }
-
-LOGGING["root"] = {"handlers": ["null"]}
+# LOGGING["handlers"]["null"] = {
+# 'level': 'DEBUG',
+# 'class': 'django.utils.log.NullHandler',
+# }
+#
+# LOGGING["root"] = {"handlers": ["null"]}

0 comments on commit 0ec0d6b

Please sign in to comment.