mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 12:38:36 +02:00
Merge branch 'main' into nl/3181-labels-for-investigator-and-senior-official
This commit is contained in:
commit
8def6e5ed7
1 changed files with 25 additions and 19 deletions
|
@ -315,7 +315,7 @@ class DomainRequestFixture:
|
||||||
cls._create_domain_requests(users)
|
cls._create_domain_requests(users)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _create_domain_requests(cls, users): # noqa: C901
|
def _create_domain_requests(cls, users, total_requests=None): # noqa: C901
|
||||||
"""Creates DomainRequests given a list of users."""
|
"""Creates DomainRequests given a list of users."""
|
||||||
total_domain_requests_to_make = len(users) # 100000
|
total_domain_requests_to_make = len(users) # 100000
|
||||||
|
|
||||||
|
@ -323,10 +323,18 @@ class DomainRequestFixture:
|
||||||
# number of entries.
|
# number of entries.
|
||||||
# (Prevents re-adding more entries to an already populated database,
|
# (Prevents re-adding more entries to an already populated database,
|
||||||
# which happens when restarting Docker src)
|
# which happens when restarting Docker src)
|
||||||
domain_requests_already_made = DomainRequest.objects.count()
|
total_existing_requests = DomainRequest.objects.count()
|
||||||
|
|
||||||
domain_requests_to_create = []
|
domain_requests_to_create = []
|
||||||
if domain_requests_already_made < total_domain_requests_to_make:
|
if total_requests and total_requests <= total_existing_requests:
|
||||||
|
total_domain_requests_to_make = total_requests - total_existing_requests
|
||||||
|
if total_domain_requests_to_make >= 0:
|
||||||
|
DomainRequest.objects.filter(
|
||||||
|
id__in=list(DomainRequest.objects.values_list("pk", flat=True)[:total_domain_requests_to_make])
|
||||||
|
).delete()
|
||||||
|
if total_domain_requests_to_make == 0:
|
||||||
|
return
|
||||||
|
|
||||||
for user in users:
|
for user in users:
|
||||||
for request_data in cls.DOMAINREQUESTS:
|
for request_data in cls.DOMAINREQUESTS:
|
||||||
# Prepare DomainRequest objects
|
# Prepare DomainRequest objects
|
||||||
|
@ -341,9 +349,7 @@ class DomainRequestFixture:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
|
|
||||||
num_additional_requests_to_make = (
|
num_additional_requests_to_make = total_domain_requests_to_make - len(domain_requests_to_create)
|
||||||
total_domain_requests_to_make - domain_requests_already_made - len(domain_requests_to_create)
|
|
||||||
)
|
|
||||||
if num_additional_requests_to_make > 0:
|
if num_additional_requests_to_make > 0:
|
||||||
for _ in range(num_additional_requests_to_make):
|
for _ in range(num_additional_requests_to_make):
|
||||||
random_user = random.choice(users) # nosec
|
random_user = random.choice(users) # nosec
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue