mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-21 03:49:22 +02:00
Add timers
This commit is contained in:
parent
e265008bc8
commit
b5784a1a88
2 changed files with 106 additions and 99 deletions
|
@ -32,6 +32,7 @@ from django.contrib.auth.forms import UserChangeForm, UsernameField
|
||||||
from django_admin_multiple_choice_list_filter.list_filters import MultipleChoiceListFilter
|
from django_admin_multiple_choice_list_filter.list_filters import MultipleChoiceListFilter
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from registrar.models.utility.generic_helper import Timer
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -2027,12 +2028,14 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
return HttpResponseRedirect(reverse("domain", args=(obj.id,)))
|
return HttpResponseRedirect(reverse("domain", args=(obj.id,)))
|
||||||
|
|
||||||
def change_view(self, request, object_id):
|
def change_view(self, request, object_id):
|
||||||
# If the analyst was recently editing a domain page,
|
logger.info("Timing change_view on domain")
|
||||||
# delete any associated session values
|
with Timer():
|
||||||
if "analyst_action" in request.session:
|
# If the analyst was recently editing a domain page,
|
||||||
del request.session["analyst_action"]
|
# delete any associated session values
|
||||||
del request.session["analyst_action_location"]
|
if "analyst_action" in request.session:
|
||||||
return super().change_view(request, object_id)
|
del request.session["analyst_action"]
|
||||||
|
del request.session["analyst_action_location"]
|
||||||
|
return super().change_view(request, object_id)
|
||||||
|
|
||||||
def has_change_permission(self, request, obj=None):
|
def has_change_permission(self, request, obj=None):
|
||||||
# Fixes a bug wherein users which are only is_staff
|
# Fixes a bug wherein users which are only is_staff
|
||||||
|
|
|
@ -13,7 +13,7 @@ from django.db.models.functions import Concat, Coalesce
|
||||||
from registrar.models.public_contact import PublicContact
|
from registrar.models.public_contact import PublicContact
|
||||||
from registrar.models.user_domain_role import UserDomainRole
|
from registrar.models.user_domain_role import UserDomainRole
|
||||||
from registrar.utility.enums import DefaultEmail
|
from registrar.utility.enums import DefaultEmail
|
||||||
|
from registrar.models.utility.generic_helper import Timer
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,108 +379,112 @@ def write_csv_for_requests(
|
||||||
|
|
||||||
def export_data_type_to_csv(csv_file):
|
def export_data_type_to_csv(csv_file):
|
||||||
"""All domains report with extra columns"""
|
"""All domains report with extra columns"""
|
||||||
|
logger.info("Timing export_data_type_to_csv")
|
||||||
|
with Timer():
|
||||||
|
writer = csv.writer(csv_file)
|
||||||
|
# define columns to include in export
|
||||||
|
columns = [
|
||||||
|
"Domain name",
|
||||||
|
"Status",
|
||||||
|
"Expiration date",
|
||||||
|
"Domain type",
|
||||||
|
"Agency",
|
||||||
|
"Organization name",
|
||||||
|
"City",
|
||||||
|
"State",
|
||||||
|
"AO",
|
||||||
|
"AO email",
|
||||||
|
"Security contact email",
|
||||||
|
# For domain manager we are pass it in as a parameter below in write_body
|
||||||
|
]
|
||||||
|
|
||||||
writer = csv.writer(csv_file)
|
# Coalesce is used to replace federal_type of None with ZZZZZ
|
||||||
# define columns to include in export
|
sort_fields = [
|
||||||
columns = [
|
"organization_type",
|
||||||
"Domain name",
|
Coalesce("federal_type", Value("ZZZZZ")),
|
||||||
"Status",
|
"federal_agency",
|
||||||
"Expiration date",
|
"domain__name",
|
||||||
"Domain type",
|
]
|
||||||
"Agency",
|
filter_condition = {
|
||||||
"Organization name",
|
"domain__state__in": [
|
||||||
"City",
|
Domain.State.READY,
|
||||||
"State",
|
Domain.State.DNS_NEEDED,
|
||||||
"AO",
|
Domain.State.ON_HOLD,
|
||||||
"AO email",
|
],
|
||||||
"Security contact email",
|
}
|
||||||
# For domain manager we are pass it in as a parameter below in write_body
|
write_csv_for_domains(
|
||||||
]
|
writer, columns, sort_fields, filter_condition, should_get_domain_managers=True, should_write_header=True
|
||||||
|
)
|
||||||
# Coalesce is used to replace federal_type of None with ZZZZZ
|
|
||||||
sort_fields = [
|
|
||||||
"organization_type",
|
|
||||||
Coalesce("federal_type", Value("ZZZZZ")),
|
|
||||||
"federal_agency",
|
|
||||||
"domain__name",
|
|
||||||
]
|
|
||||||
filter_condition = {
|
|
||||||
"domain__state__in": [
|
|
||||||
Domain.State.READY,
|
|
||||||
Domain.State.DNS_NEEDED,
|
|
||||||
Domain.State.ON_HOLD,
|
|
||||||
],
|
|
||||||
}
|
|
||||||
write_csv_for_domains(
|
|
||||||
writer, columns, sort_fields, filter_condition, should_get_domain_managers=True, should_write_header=True
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def export_data_full_to_csv(csv_file):
|
def export_data_full_to_csv(csv_file):
|
||||||
"""All domains report"""
|
"""All domains report"""
|
||||||
|
|
||||||
writer = csv.writer(csv_file)
|
logger.info("Timing def export_data_full_to_csv")
|
||||||
# define columns to include in export
|
with Timer():
|
||||||
columns = [
|
writer = csv.writer(csv_file)
|
||||||
"Domain name",
|
# define columns to include in export
|
||||||
"Domain type",
|
columns = [
|
||||||
"Agency",
|
"Domain name",
|
||||||
"Organization name",
|
"Domain type",
|
||||||
"City",
|
"Agency",
|
||||||
"State",
|
"Organization name",
|
||||||
"Security contact email",
|
"City",
|
||||||
]
|
"State",
|
||||||
# Coalesce is used to replace federal_type of None with ZZZZZ
|
"Security contact email",
|
||||||
sort_fields = [
|
]
|
||||||
"organization_type",
|
# Coalesce is used to replace federal_type of None with ZZZZZ
|
||||||
Coalesce("federal_type", Value("ZZZZZ")),
|
sort_fields = [
|
||||||
"federal_agency",
|
"organization_type",
|
||||||
"domain__name",
|
Coalesce("federal_type", Value("ZZZZZ")),
|
||||||
]
|
"federal_agency",
|
||||||
filter_condition = {
|
"domain__name",
|
||||||
"domain__state__in": [
|
]
|
||||||
Domain.State.READY,
|
filter_condition = {
|
||||||
Domain.State.DNS_NEEDED,
|
"domain__state__in": [
|
||||||
Domain.State.ON_HOLD,
|
Domain.State.READY,
|
||||||
],
|
Domain.State.DNS_NEEDED,
|
||||||
}
|
Domain.State.ON_HOLD,
|
||||||
write_csv_for_domains(
|
],
|
||||||
writer, columns, sort_fields, filter_condition, should_get_domain_managers=False, should_write_header=True
|
}
|
||||||
)
|
write_csv_for_domains(
|
||||||
|
writer, columns, sort_fields, filter_condition, should_get_domain_managers=False, should_write_header=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def export_data_federal_to_csv(csv_file):
|
def export_data_federal_to_csv(csv_file):
|
||||||
"""Federal domains report"""
|
"""Federal domains report"""
|
||||||
|
logger.info("Timing def export_data_federal_to_csv")
|
||||||
writer = csv.writer(csv_file)
|
with Timer():
|
||||||
# define columns to include in export
|
writer = csv.writer(csv_file)
|
||||||
columns = [
|
# define columns to include in export
|
||||||
"Domain name",
|
columns = [
|
||||||
"Domain type",
|
"Domain name",
|
||||||
"Agency",
|
"Domain type",
|
||||||
"Organization name",
|
"Agency",
|
||||||
"City",
|
"Organization name",
|
||||||
"State",
|
"City",
|
||||||
"Security contact email",
|
"State",
|
||||||
]
|
"Security contact email",
|
||||||
# Coalesce is used to replace federal_type of None with ZZZZZ
|
]
|
||||||
sort_fields = [
|
# Coalesce is used to replace federal_type of None with ZZZZZ
|
||||||
"organization_type",
|
sort_fields = [
|
||||||
Coalesce("federal_type", Value("ZZZZZ")),
|
"organization_type",
|
||||||
"federal_agency",
|
Coalesce("federal_type", Value("ZZZZZ")),
|
||||||
"domain__name",
|
"federal_agency",
|
||||||
]
|
"domain__name",
|
||||||
filter_condition = {
|
]
|
||||||
"organization_type__icontains": "federal",
|
filter_condition = {
|
||||||
"domain__state__in": [
|
"organization_type__icontains": "federal",
|
||||||
Domain.State.READY,
|
"domain__state__in": [
|
||||||
Domain.State.DNS_NEEDED,
|
Domain.State.READY,
|
||||||
Domain.State.ON_HOLD,
|
Domain.State.DNS_NEEDED,
|
||||||
],
|
Domain.State.ON_HOLD,
|
||||||
}
|
],
|
||||||
write_csv_for_domains(
|
}
|
||||||
writer, columns, sort_fields, filter_condition, should_get_domain_managers=False, should_write_header=True
|
write_csv_for_domains(
|
||||||
)
|
writer, columns, sort_fields, filter_condition, should_get_domain_managers=False, should_write_header=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_default_start_date():
|
def get_default_start_date():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue