From b4ab38ee3697055d25618bd84d237be554c8f69a Mon Sep 17 00:00:00 2001
From: ale-rt <alessandro.pisa@gmail.com>
Date: Mon, 20 Jan 2025 10:53:40 +0100
Subject: [PATCH 1/3] Pre-commit

---
 .pre-commit-config.yaml                             | 12 ++++++------
 src/recensio/plone/mails/legacy.py                  |  1 +
 src/recensio/plone/migration/import_pagePictures.py |  8 ++++++--
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0a16446..39b78a7 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,26 +1,26 @@
 exclude: "^$|src/recensio/plone/browser/bundles"
 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v4.4.0
+    rev: v5.0.0
     hooks:
       - id: check-yaml
       - id: end-of-file-fixer
       - id: trailing-whitespace
   - repo: https://github.com/asottile/pyupgrade
-    rev: v3.4.0
+    rev: v3.19.1
     hooks:
       - id: pyupgrade
         args: [--py38-plus]
   - repo: https://github.com/psf/black
-    rev: 23.3.0
+    rev: 24.10.0
     hooks:
       - id: black
   - repo: https://github.com/PyCQA/isort
-    rev: 5.12.0
+    rev: 5.13.2
     hooks:
       - id: isort
   - repo: https://github.com/PyCQA/flake8
-    rev: 6.0.0
+    rev: 7.1.1
     hooks:
       - id: flake8
   - repo: https://github.com/PyCQA/bandit
@@ -33,7 +33,7 @@ repos:
           - --confidence-level=medium
           - --skip=B608
   - repo: https://github.com/collective/zpretty
-    rev: 3.1.0a2
+    rev: 3.1.0
     hooks:
       - id: zpretty
 #  - repo: https://github.com/PyCQA/docformatter
diff --git a/src/recensio/plone/mails/legacy.py b/src/recensio/plone/mails/legacy.py
index 555f6b6..243b213 100644
--- a/src/recensio/plone/mails/legacy.py
+++ b/src/recensio/plone/mails/legacy.py
@@ -1,4 +1,5 @@
 """Contains code migrated from the old recensio packages."""
+
 from plone import api
 from Products.Five import BrowserView
 from recensio.plone import _
diff --git a/src/recensio/plone/migration/import_pagePictures.py b/src/recensio/plone/migration/import_pagePictures.py
index 5724e50..7de3fae 100644
--- a/src/recensio/plone/migration/import_pagePictures.py
+++ b/src/recensio/plone/migration/import_pagePictures.py
@@ -71,7 +71,9 @@ def handleApply(self, action):
                     )
                     with blob_path.open("rb") as f:
                         pagePictures.append(
-                            NamedBlobImage(data=f.read(), filename=f"{blob_idx+1}.gif")
+                            NamedBlobImage(
+                                data=f.read(), filename=f"{blob_idx + 1}.gif"
+                            )
                         )
                 elif isinstance(blob_path, str):
                     # Looks like, when export_page_pictures was called TTW, the
@@ -79,7 +81,9 @@ def handleApply(self, action):
                     # COLLECTIVE_EXPORTIMPORT_BLOB_HOME in that case.
                     with open(blob_path, "rb") as f:
                         pagePictures.append(
-                            NamedBlobImage(data=f.read(), filename=f"{blob_idx+1}.gif")
+                            NamedBlobImage(
+                                data=f.read(), filename=f"{blob_idx + 1}.gif"
+                            )
                         )
 
             obj.pagePictures = pagePictures

From 3001e0d4385e58d9a429c7d9acd5daee4b7b5e0d Mon Sep 17 00:00:00 2001
From: ale-rt <alessandro.pisa@gmail.com>
Date: Mon, 20 Jan 2025 10:53:57 +0100
Subject: [PATCH 2/3] Performance improvements

See https://github.com/syslabcom/scrum/issues/3067 which also shows how
this is effective
---
 CHANGES.rst                             | 4 +++-
 src/recensio/plone/viewlets/viewlets.py | 8 +++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 7d00873..ee72478 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -5,7 +5,9 @@ Changelog
 1.0.4 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Performance improvements
+  `#3067 <https://github.com/syslabcom/scrum/issues/3067>`_
+  [ale-rt]
 
 
 1.0.3 (2024-07-30)
diff --git a/src/recensio/plone/viewlets/viewlets.py b/src/recensio/plone/viewlets/viewlets.py
index bc61153..0261b04 100644
--- a/src/recensio/plone/viewlets/viewlets.py
+++ b/src/recensio/plone/viewlets/viewlets.py
@@ -79,11 +79,9 @@ def _get_toggle_link(self, uid):
 
     def _get_css_classes(self, obj):
         css_classes = []
-        reviews = [
-            obj
-            for obj in obj.objectValues()
-            if obj.portal_type in ("Review Monograph", "Review Journal")
-        ]
+        reviews = api.content.find(
+            context=obj, portal_type=["Review Monograph", "Review Journal"], depth=1
+        )
         if len(reviews) > 0:
             css_classes.append("review_container")
             if self.is_expanded(obj.UID()):

From a4750e4e0c12f677a730f18a2971d31e84a2bcbf Mon Sep 17 00:00:00 2001
From: ale-rt <alessandro.pisa@gmail.com>
Date: Mon, 20 Jan 2025 11:26:29 +0100
Subject: [PATCH 3/3] Use the standard zc.recipe.testrunner

See collective/collective.xmltestreport#28
---
 buildout.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildout.cfg b/buildout.cfg
index 1aaa8cf..bd58417 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -15,7 +15,7 @@ auto-checkout =
 
 
 [test]
-recipe = collective.xmltestreport
+recipe = zc.recipe.testrunner
 defaults = ['--auto-color', '--auto-progress', '-s', 'recensio.plone']
 eggs =
     Products.CMFPlone