mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Merge pull request #2144 from cisagov/za/1988-investigate-indexes
Ticket #1988: Investigate indexes
This commit is contained in:
commit
f468e6cd6e
10 changed files with 184 additions and 23 deletions
|
@ -0,0 +1,131 @@
|
|||
# Generated by Django 4.2.10 on 2024-05-28 14:40
|
||||
|
||||
from django.db import migrations, models
|
||||
import phonenumber_field.modelfields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("registrar", "0095_user_middle_name_user_title"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="contact",
|
||||
name="email",
|
||||
field=models.EmailField(blank=True, max_length=320, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="contact",
|
||||
name="first_name",
|
||||
field=models.CharField(blank=True, null=True, verbose_name="first name"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="contact",
|
||||
name="last_name",
|
||||
field=models.CharField(blank=True, null=True, verbose_name="last name"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="contact",
|
||||
name="phone",
|
||||
field=phonenumber_field.modelfields.PhoneNumberField(blank=True, max_length=128, null=True, region=None),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="domaininformation",
|
||||
name="organization_name",
|
||||
field=models.CharField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="domaininformation",
|
||||
name="zipcode",
|
||||
field=models.CharField(blank=True, max_length=10, null=True, verbose_name="zip code"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="domainrequest",
|
||||
name="organization_name",
|
||||
field=models.CharField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="domainrequest",
|
||||
name="zipcode",
|
||||
field=models.CharField(blank=True, max_length=10, null=True, verbose_name="zip code"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="transitiondomain",
|
||||
name="first_name",
|
||||
field=models.CharField(
|
||||
blank=True, help_text="First name / given name", null=True, verbose_name="first name"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="transitiondomain",
|
||||
name="organization_name",
|
||||
field=models.CharField(blank=True, help_text="Organization name", null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="transitiondomain",
|
||||
name="zipcode",
|
||||
field=models.CharField(blank=True, help_text="Zip code", max_length=10, null=True, verbose_name="zip code"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="user",
|
||||
name="phone",
|
||||
field=phonenumber_field.modelfields.PhoneNumberField(
|
||||
blank=True, help_text="Phone", max_length=128, null=True, region=None
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="verifiedbystaff",
|
||||
name="email",
|
||||
field=models.EmailField(max_length=254),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="contact",
|
||||
index=models.Index(fields=["user"], name="registrar_c_user_id_4059c4_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="contact",
|
||||
index=models.Index(fields=["email"], name="registrar_c_email_bde2de_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domain",
|
||||
index=models.Index(fields=["name"], name="registrar_d_name_5b1956_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domain",
|
||||
index=models.Index(fields=["state"], name="registrar_d_state_84c134_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domaininformation",
|
||||
index=models.Index(fields=["domain"], name="registrar_d_domain__88838a_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domaininformation",
|
||||
index=models.Index(fields=["domain_request"], name="registrar_d_domain__d1fba8_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domaininvitation",
|
||||
index=models.Index(fields=["status"], name="registrar_d_status_e84571_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domainrequest",
|
||||
index=models.Index(fields=["requested_domain"], name="registrar_d_request_6894eb_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domainrequest",
|
||||
index=models.Index(fields=["approved_domain"], name="registrar_d_approve_ac4c46_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="domainrequest",
|
||||
index=models.Index(fields=["status"], name="registrar_d_status_a32b59_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="user",
|
||||
index=models.Index(fields=["username"], name="registrar_u_usernam_964b1b_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="user",
|
||||
index=models.Index(fields=["email"], name="registrar_u_email_c8f2c4_idx"),
|
||||
),
|
||||
]
|
|
@ -17,6 +17,14 @@ class Contact(TimeStampedModel):
|
|||
will be updated if any updates are made to it through Login.gov.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
"""Contains meta information about this class"""
|
||||
|
||||
indexes = [
|
||||
models.Index(fields=["user"]),
|
||||
models.Index(fields=["email"]),
|
||||
]
|
||||
|
||||
user = models.OneToOneField(
|
||||
"registrar.User",
|
||||
null=True,
|
||||
|
@ -28,7 +36,6 @@ class Contact(TimeStampedModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
verbose_name="first name",
|
||||
db_index=True,
|
||||
)
|
||||
middle_name = models.CharField(
|
||||
null=True,
|
||||
|
@ -38,7 +45,6 @@ class Contact(TimeStampedModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
verbose_name="last name",
|
||||
db_index=True,
|
||||
)
|
||||
title = models.CharField(
|
||||
null=True,
|
||||
|
@ -48,13 +54,11 @@ class Contact(TimeStampedModel):
|
|||
email = models.EmailField(
|
||||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
max_length=320,
|
||||
)
|
||||
phone = PhoneNumberField(
|
||||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
def _get_all_relations(self):
|
||||
|
|
|
@ -65,6 +65,14 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
domain meets the required checks.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
"""Contains meta information about this class"""
|
||||
|
||||
indexes = [
|
||||
models.Index(fields=["name"]),
|
||||
models.Index(fields=["state"]),
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._cache = {}
|
||||
super(Domain, self).__init__(*args, **kwargs)
|
||||
|
|
|
@ -22,6 +22,16 @@ class DomainInformation(TimeStampedModel):
|
|||
the domain request once approved, so copying them that way we can make changes
|
||||
after its approved. Most fields here are copied from DomainRequest."""
|
||||
|
||||
class Meta:
|
||||
"""Contains meta information about this class"""
|
||||
|
||||
indexes = [
|
||||
models.Index(fields=["domain"]),
|
||||
models.Index(fields=["domain_request"]),
|
||||
]
|
||||
|
||||
verbose_name_plural = "Domain information"
|
||||
|
||||
StateTerritoryChoices = DomainRequest.StateTerritoryChoices
|
||||
|
||||
# use the short names in Django admin
|
||||
|
@ -111,7 +121,6 @@ class DomainInformation(TimeStampedModel):
|
|||
organization_name = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
)
|
||||
address_line1 = models.CharField(
|
||||
null=True,
|
||||
|
@ -138,7 +147,6 @@ class DomainInformation(TimeStampedModel):
|
|||
max_length=10,
|
||||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
verbose_name="zip code",
|
||||
)
|
||||
urbanization = models.CharField(
|
||||
|
@ -336,6 +344,3 @@ class DomainInformation(TimeStampedModel):
|
|||
def _get_many_to_many_fields():
|
||||
"""Returns a set of each field.name that has the many to many relation"""
|
||||
return {field.name for field in DomainInformation._meta.many_to_many} # type: ignore
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Domain information"
|
||||
|
|
|
@ -15,6 +15,13 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class DomainInvitation(TimeStampedModel):
|
||||
class Meta:
|
||||
"""Contains meta information about this class"""
|
||||
|
||||
indexes = [
|
||||
models.Index(fields=["status"]),
|
||||
]
|
||||
|
||||
# Constants for status field
|
||||
class DomainInvitationStatus(models.TextChoices):
|
||||
INVITED = "invited", "Invited"
|
||||
|
|
|
@ -25,6 +25,15 @@ logger = logging.getLogger(__name__)
|
|||
class DomainRequest(TimeStampedModel):
|
||||
"""A registrant's domain request for a new domain."""
|
||||
|
||||
class Meta:
|
||||
"""Contains meta information about this class"""
|
||||
|
||||
indexes = [
|
||||
models.Index(fields=["requested_domain"]),
|
||||
models.Index(fields=["approved_domain"]),
|
||||
models.Index(fields=["status"]),
|
||||
]
|
||||
|
||||
# https://django-auditlog.readthedocs.io/en/latest/usage.html#object-history
|
||||
# If we note any performace degradation due to this addition,
|
||||
# we can query the auditlogs table in admin.py and add the results to
|
||||
|
@ -331,7 +340,6 @@ class DomainRequest(TimeStampedModel):
|
|||
organization_name = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
address_line1 = models.CharField(
|
||||
|
@ -360,7 +368,6 @@ class DomainRequest(TimeStampedModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
verbose_name="zip code",
|
||||
db_index=True,
|
||||
)
|
||||
urbanization = models.CharField(
|
||||
null=True,
|
||||
|
|
|
@ -59,7 +59,6 @@ class TransitionDomain(TimeStampedModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
help_text="Organization name",
|
||||
db_index=True,
|
||||
)
|
||||
federal_type = models.CharField(
|
||||
max_length=50,
|
||||
|
@ -85,7 +84,6 @@ class TransitionDomain(TimeStampedModel):
|
|||
blank=True,
|
||||
help_text="First name / given name",
|
||||
verbose_name="first name",
|
||||
db_index=True,
|
||||
)
|
||||
middle_name = models.CharField(
|
||||
null=True,
|
||||
|
@ -136,7 +134,6 @@ class TransitionDomain(TimeStampedModel):
|
|||
blank=True,
|
||||
verbose_name="zip code",
|
||||
help_text="Zip code",
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -31,6 +31,17 @@ class User(AbstractUser):
|
|||
will be updated if any updates are made to it through Login.gov.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(fields=["username"]),
|
||||
models.Index(fields=["email"]),
|
||||
]
|
||||
|
||||
permissions = [
|
||||
("analyst_access_permission", "Analyst Access Permission"),
|
||||
("full_access_permission", "Full Access Permission"),
|
||||
]
|
||||
|
||||
class VerificationTypeChoices(models.TextChoices):
|
||||
"""
|
||||
Users achieve access to our system in a few different ways.
|
||||
|
@ -77,7 +88,6 @@ class User(AbstractUser):
|
|||
null=True,
|
||||
blank=True,
|
||||
help_text="Phone",
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
middle_name = models.CharField(
|
||||
|
@ -281,9 +291,3 @@ class User(AbstractUser):
|
|||
"""
|
||||
|
||||
self.check_domain_invitations_on_login()
|
||||
|
||||
class Meta:
|
||||
permissions = [
|
||||
("analyst_access_permission", "Analyst Access Permission"),
|
||||
("full_access_permission", "Full Access Permission"),
|
||||
]
|
||||
|
|
|
@ -9,7 +9,6 @@ class VerifiedByStaff(TimeStampedModel):
|
|||
email = models.EmailField(
|
||||
null=False,
|
||||
blank=False,
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
requestor = models.ForeignKey(
|
||||
|
|
|
@ -455,7 +455,6 @@ def export_data_full_to_csv(csv_file):
|
|||
|
||||
def export_data_federal_to_csv(csv_file):
|
||||
"""Federal domains report"""
|
||||
|
||||
writer = csv.writer(csv_file)
|
||||
# define columns to include in export
|
||||
columns = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue