-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodels.py
More file actions
55 lines (45 loc) · 2.11 KB
/
models.py
File metadata and controls
55 lines (45 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Models per docs/Schema.md section 5: Boost Mailing List Tracker.
Sender identity is stored as a soft reference to cppa_user_tracker.MailingListProfile.pk
(column sender_id). Resolve profiles via cppa_user_tracker.services.
"""
from django.core.validators import MinValueValidator
from django.db import models
class MailingListName(models.TextChoices):
"""Boost mailing list names; values match the list address used in API URLs (fetcher.BOOST_LIST_URLS)."""
BOOST_ANNOUNCE = "boost-announce@lists.boost.org", "Boost Announce"
BOOST_USERS = "boost-users@lists.boost.org", "Boost Users"
BOOST = "boost@lists.boost.org", "Boost"
class MailingListMessage(models.Model):
"""Mailing list message (sender_profile_id, msg_id, subject, content, list_name, sent_at)."""
sender_profile_id = models.BigIntegerField(
db_column="sender_id",
db_index=True,
validators=[MinValueValidator(1)],
help_text="cppa_user_tracker.MailingListProfile primary key (soft reference).",
)
msg_id = models.CharField(max_length=255, unique=True, db_index=True)
parent_id = models.CharField(max_length=255, blank=True, db_index=True)
thread_id = models.CharField(max_length=255, blank=True, db_index=True)
subject = models.CharField(max_length=1024, blank=True)
content = models.TextField(blank=True)
list_name = models.CharField(
max_length=255,
choices=MailingListName.choices,
db_index=True,
)
sent_at = models.DateTimeField(null=True, blank=True, db_index=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = "boost_mailing_list_tracker_mailinglistmessage"
ordering = ["-sent_at"]
verbose_name = "Mailing list message"
verbose_name_plural = "Mailing list messages"
constraints = [
models.CheckConstraint(
check=models.Q(sender_profile_id__gte=1),
name="boost_mailing_list_tracker_sender_profile_id_gte_1",
),
]
def __str__(self):
return f"{self.list_name}: {self.subject[:60]}" if self.subject else self.msg_id