Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3011 - The "Request growth" report is missing data - [backup] #3271

Merged
merged 10 commits into from
Jan 8, 2025
18 changes: 16 additions & 2 deletions src/registrar/fixtures/fixtures_requests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import timedelta
from datetime import datetime, timedelta
from django.utils import timezone
import logging
import random
Expand Down Expand Up @@ -126,7 +126,21 @@ def _set_non_foreign_key_fields(cls, request: DomainRequest, request_dict: dict)
# TODO for a future ticket: Allow for more than just "federal" here
request.generic_org_type = request_dict["generic_org_type"] if "generic_org_type" in request_dict else "federal"
if request.status != "started":
request.last_submitted_date = fake.date()
# Generate fake data for first_submitted_date and last_submitted_date
# First generate a random date set to be later than 2020 (or something)
# (if we just use fake.date() we might get years like 1970 or earlier)
earliest_date_allowed = datetime(2020, 1, 1).date()
end_date = datetime.today().date() # Today's date (latest allowed date)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore you had to pick 2020.... shakes head

days_range = (end_date - earliest_date_allowed).days
first_submitted_date = earliest_date_allowed + timedelta(days=random.randint(0, days_range))

# Generate a random positive offset to ensure last_submitted_date is later
offset_days = random.randint(1, 30) # Ensures at least 1 day difference
last_submitted_date = first_submitted_date + timedelta(days=offset_days)

# Convert back to strings before assigning
request.first_submitted_date = first_submitted_date.strftime("%Y-%m-%d")
request.last_submitted_date = last_submitted_date.strftime("%Y-%m-%d")
request.federal_type = (
request_dict["federal_type"]
if "federal_type" in request_dict
Expand Down
3 changes: 1 addition & 2 deletions src/registrar/utility/csv_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ def get_columns(cls):
"Domain request",
"Domain type",
"Federal type",
"Submitted at",
"First submitted date",
]

@classmethod
Expand All @@ -1976,7 +1976,6 @@ def get_filter_conditions(cls, start_date=None, end_date=None, **kwargs):
start_date_formatted = format_start_date(start_date)
end_date_formatted = format_end_date(end_date)
return Q(
status=DomainRequest.DomainRequestStatus.SUBMITTED,
last_submitted_date__lte=end_date_formatted,
last_submitted_date__gte=start_date_formatted,
)
Expand Down
Loading