From c5c9fbf71ede704a629d0cd90a25e10667585115 Mon Sep 17 00:00:00 2001 From: Quirin Pamp Date: Mon, 20 Nov 2023 09:21:06 +0100 Subject: [PATCH 1/2] Fix messy import statements [noissue] --- pulp_deb/app/models/repository.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pulp_deb/app/models/repository.py b/pulp_deb/app/models/repository.py index 699982eca..3c531b6c9 100644 --- a/pulp_deb/app/models/repository.py +++ b/pulp_deb/app/models/repository.py @@ -1,13 +1,12 @@ from django.db import models -from pulpcore.plugin.models import BaseModel, Repository + +from pulpcore.plugin.models import BaseModel, Content, Repository from pulpcore.plugin.repo_version_utils import ( remove_duplicates, validate_version_paths, validate_duplicate_content, ) -from pulpcore.plugin.models import Content - from pulp_deb.app.models import ( AptReleaseSigningService, AptRemote, From 3de2554351678a6494f21a025b240c3310561926 Mon Sep 17 00:00:00 2001 From: Quirin Pamp Date: Mon, 20 Nov 2023 09:22:43 +0100 Subject: [PATCH 2/2] Use batch_qs from pulpcore [noissue] --- pulp_deb/app/models/repository.py | 20 +------------------- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/pulp_deb/app/models/repository.py b/pulp_deb/app/models/repository.py index 3c531b6c9..fa2ed458f 100644 --- a/pulp_deb/app/models/repository.py +++ b/pulp_deb/app/models/repository.py @@ -6,6 +6,7 @@ validate_version_paths, validate_duplicate_content, ) +from pulpcore.plugin.util import batch_qs from pulp_deb.app.models import ( AptReleaseSigningService, @@ -194,22 +195,3 @@ def handle_duplicate_packages(new_version): log.warning(message.format(pulp_type)) new_version.remove_content(package_qs_duplicates) new_version.remove_content(prc_qs_duplicates) - - -# The following helper function is copy and pasted from pulpcore. As soon as -# https://github.com/pulp/pulpcore/issues/4607 is ready, we should replace it with an import! -def batch_qs(qs, batch_size=1000): - """ - Returns a queryset batch in the given queryset. - - Usage: - # Make sure to order your querset - article_qs = Article.objects.order_by('id') - for qs in batch_qs(article_qs): - for article in qs: - print article.body - """ - total = qs.count() - for start in range(0, total, batch_size): - end = min(start + batch_size, total) - yield qs[start:end] diff --git a/requirements.txt b/requirements.txt index fd7d8e464..4864d274f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # All things django and asyncio are deliberately left to pulpcore # Example transitive requirements: asgiref, asyncio, aiohttp -pulpcore>=3.40.1,<3.55 +pulpcore>=3.41.0,<3.55 python-debian>=0.1.44,<0.2.0 python-gnupg>=0.5,<0.6 jsonschema>=4.6,<5.0