mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-28 22:59:03 -06:00
Add flags to skip potentially problematic queries
This commit is contained in:
@@ -109,6 +109,16 @@ class Command(BaseCommand):
|
||||
default=1,
|
||||
help="How many custom field instances per document (default: 1)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--skip-tags",
|
||||
action="store_true",
|
||||
help="Skip tag document_count benchmarks (useful for large datasets on Postgres)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--skip-custom-fields",
|
||||
action="store_true",
|
||||
help="Skip custom field document_count benchmarks",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--reuse-existing",
|
||||
action="store_true",
|
||||
@@ -121,6 +131,9 @@ class Command(BaseCommand):
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# keep options for downstream checks
|
||||
self.options = options
|
||||
|
||||
document_total = options["documents"]
|
||||
owner_ratio = options["owner_ratio"]
|
||||
unowned_ratio = options["unowned_ratio"]
|
||||
@@ -457,13 +470,19 @@ class Command(BaseCommand):
|
||||
iterations=iterations,
|
||||
fn=lambda: Document.objects.count(),
|
||||
)
|
||||
self._time_tag_counts(iterations=iterations, prefix=prefix, user=target_user)
|
||||
self._time_custom_field_counts(
|
||||
iterations=iterations,
|
||||
prefix=prefix,
|
||||
user=target_user,
|
||||
superuser=superuser,
|
||||
)
|
||||
if not self.options.get("skip_tags"):
|
||||
self._time_tag_counts(
|
||||
iterations=iterations,
|
||||
prefix=prefix,
|
||||
user=target_user,
|
||||
)
|
||||
if not self.options.get("skip_custom_fields"):
|
||||
self._time_custom_field_counts(
|
||||
iterations=iterations,
|
||||
prefix=prefix,
|
||||
user=target_user,
|
||||
superuser=superuser,
|
||||
)
|
||||
|
||||
def _count_with_values_list(self, user) -> int:
|
||||
qs = get_objects_for_user_owner_aware(
|
||||
|
||||
Reference in New Issue
Block a user