Skip to content

Commit

Permalink
feat: adding missing indexes to notifications (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
nutrina authored Nov 8, 2024
1 parent 03483fb commit 0813612
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.6 on 2024-11-08 08:57

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("passport_admin", "0008_lastscheduledrun"),
]

operations = [
migrations.AlterField(
model_name="notificationstatus",
name="is_deleted",
field=models.BooleanField(db_index=True, default=False),
),
migrations.AlterField(
model_name="notificationstatus",
name="is_read",
field=models.BooleanField(db_index=True, default=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.2.6 on 2024-11-08 09:02

from django.db import migrations, models

import account.models


class Migration(migrations.Migration):
dependencies = [
("passport_admin", "0009_alter_notificationstatus_is_deleted_and_more"),
]

operations = [
migrations.AlterField(
model_name="notification",
name="created_at",
field=models.DateField(auto_now_add=True, db_index=True),
),
migrations.AlterField(
model_name="notification",
name="eth_address",
field=account.models.EthAddressField(
blank=True, db_index=True, max_length=42, null=True
),
),
migrations.AlterField(
model_name="notification",
name="expires_at",
field=models.DateField(blank=True, db_index=True, null=True),
),
migrations.AlterField(
model_name="notification",
name="is_active",
field=models.BooleanField(db_index=True, default=False),
),
]
12 changes: 6 additions & 6 deletions api/passport_admin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ class Notification(models.Model):
type = models.CharField(
max_length=50, choices=NOTIFICATION_TYPES, default="custom", db_index=True
)
is_active = models.BooleanField(default=False)
is_active = models.BooleanField(default=False, db_index=True)

link = models.CharField(max_length=255, null=True, blank=True)
link_text = models.CharField(max_length=255, null=True, blank=True)
content = models.TextField()
created_at = models.DateField(auto_now_add=True)
expires_at = models.DateField(null=True, blank=True)
created_at = models.DateField(auto_now_add=True, db_index=True)
expires_at = models.DateField(null=True, blank=True, db_index=True)
eth_address = EthAddressField(
null=True, blank=True
null=True, blank=True, db_index=True
) # account/ eth address for which the notification is created. If null then it is a global notification wgich will be shown to all users.
community = models.ForeignKey(
Community,
Expand All @@ -92,9 +92,9 @@ class Notification(models.Model):

class NotificationStatus(models.Model):
notification = models.ForeignKey(Notification, on_delete=models.CASCADE)
is_read = models.BooleanField(default=False)
is_read = models.BooleanField(default=False, db_index=True)
is_deleted = models.BooleanField(
default=False
default=False, db_index=True
) # is dismissed => should not longer be shown to the user
eth_address = EthAddressField(
db_index=True
Expand Down

0 comments on commit 0813612

Please sign in to comment.