← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/launchpad:fix-editing-of-oci-recipes into launchpad:master

 

Jürgen Gmach has proposed merging ~jugmac00/launchpad:fix-editing-of-oci-recipes into launchpad:master.

Commit message:
Do not snapshot OCIrecipe collection fields



Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/470715

As these fields contain more than 1000 items in production, the
shortlist limit kicked in to prevent further issues.

We skipped snapshotting for similar build types, so let's do the same
with OPCIrecipes.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad:fix-editing-of-oci-recipes into launchpad:master.
diff --git a/lib/lp/oci/browser/tests/test_ocirecipe.py b/lib/lp/oci/browser/tests/test_ocirecipe.py
index 60ecc0d..3fde7a4 100644
--- a/lib/lp/oci/browser/tests/test_ocirecipe.py
+++ b/lib/lp/oci/browser/tests/test_ocirecipe.py
@@ -43,6 +43,7 @@ from lp.oci.interfaces.ocirecipe import (
     OCI_RECIPE_ALLOW_CREATE,
     CannotModifyOCIRecipeProcessor,
     IOCIRecipeSet,
+    IOCIRecipeView,
 )
 from lp.oci.interfaces.ocirecipejob import IOCIRecipeRequestBuildsJobSource
 from lp.oci.interfaces.ociregistrycredentials import IOCIRegistryCredentialsSet
@@ -70,7 +71,11 @@ from lp.testing import (
 )
 from lp.testing.dbuser import dbuser
 from lp.testing.layers import DatabaseFunctionalLayer, LaunchpadFunctionalLayer
-from lp.testing.matchers import MatchesPickerText, MatchesTagText
+from lp.testing.matchers import (
+    DoesNotSnapshot,
+    MatchesPickerText,
+    MatchesTagText,
+)
 from lp.testing.pages import (
     extract_text,
     find_main_content,
@@ -1474,6 +1479,21 @@ class TestOCIRecipeView(BaseTestOCIRecipeView):
             **kwargs,
         )
 
+    def test_avoids_problematic_snapshots(self):
+        """Do not snapshot fields with too many items."""
+        self.assertThat(
+            self.factory.makeOCIRecipe(),
+            DoesNotSnapshot(
+                [
+                    "builds",
+                    "completed_builds",
+                    "completed_builds_without_build_request",
+                    "pending_builds",
+                ],
+                IOCIRecipeView,
+            ),
+        )
+
     def makeBuild(self, recipe=None, date_created=None, **kwargs):
         if recipe is None:
             recipe = self.makeOCIRecipe()
diff --git a/lib/lp/oci/interfaces/ocirecipe.py b/lib/lp/oci/interfaces/ocirecipe.py
index 0fbb391..1f589b2 100644
--- a/lib/lp/oci/interfaces/ocirecipe.py
+++ b/lib/lp/oci/interfaces/ocirecipe.py
@@ -328,50 +328,58 @@ class IOCIRecipeView(Interface):
         :return: Sequence of `IDistroArchSeries` instances.
         """
 
-    builds = CollectionField(
-        title=_("Completed builds of this OCI recipe."),
-        description=_(
-            "Completed builds of this OCI recipe, sorted in descending "
-            "order of finishing."
-        ),
-        # Really IOCIRecipeBuild, patched in _schema_circular_imports.
-        value_type=Reference(schema=Interface),
-        required=True,
-        readonly=True,
+    builds = doNotSnapshot(
+        CollectionField(
+            title=_("Completed builds of this OCI recipe."),
+            description=_(
+                "Completed builds of this OCI recipe, sorted in descending "
+                "order of finishing."
+            ),
+            # Really IOCIRecipeBuild, patched in _schema_circular_imports.
+            value_type=Reference(schema=Interface),
+            required=True,
+            readonly=True,
+        )
     )
 
-    completed_builds = CollectionField(
-        title=_("Completed builds of this OCI recipe."),
-        description=_(
-            "Completed builds of this OCI recipe, sorted in descending "
-            "order of finishing."
-        ),
-        # Really IOCIRecipeBuild, patched in _schema_circular_imports.
-        value_type=Reference(schema=Interface),
-        readonly=True,
+    completed_builds = doNotSnapshot(
+        CollectionField(
+            title=_("Completed builds of this OCI recipe."),
+            description=_(
+                "Completed builds of this OCI recipe, sorted in descending "
+                "order of finishing."
+            ),
+            # Really IOCIRecipeBuild, patched in _schema_circular_imports.
+            value_type=Reference(schema=Interface),
+            readonly=True,
+        )
     )
 
-    completed_builds_without_build_request = CollectionField(
-        title=_("Completed builds of this OCI recipe."),
-        description=_(
-            "Completed builds of this OCI recipe, sorted in descending "
-            "order of finishing that do no have a corresponding "
-            "build request"
-        ),
-        # Really IOCIRecipeBuild, patched in _schema_circular_imports.
-        value_type=Reference(schema=Interface),
-        readonly=True,
+    completed_builds_without_build_request = doNotSnapshot(
+        CollectionField(
+            title=_("Completed builds of this OCI recipe."),
+            description=_(
+                "Completed builds of this OCI recipe, sorted in descending "
+                "order of finishing that do no have a corresponding "
+                "build request"
+            ),
+            # Really IOCIRecipeBuild, patched in _schema_circular_imports.
+            value_type=Reference(schema=Interface),
+            readonly=True,
+        )
     )
 
-    pending_builds = CollectionField(
-        title=_("Pending builds of this OCI recipe."),
-        description=_(
-            "Pending builds of this OCI recipe, sorted in descending "
-            "order of creation."
-        ),
-        # Really IOCIRecipeBuild, patched in _schema_circular_imports.
-        value_type=Reference(schema=Interface),
-        readonly=True,
+    pending_builds = doNotSnapshot(
+        CollectionField(
+            title=_("Pending builds of this OCI recipe."),
+            description=_(
+                "Pending builds of this OCI recipe, sorted in descending "
+                "order of creation."
+            ),
+            # Really IOCIRecipeBuild, patched in _schema_circular_imports.
+            value_type=Reference(schema=Interface),
+            readonly=True,
+        )
     )
 
     push_rules = exported(

Follow ups