mirror of https://github.com/zulip/zulip.git
models: Rename UserTopic.date_muted to last_updated.
This is a follow-up to #19388. We will in the future allow patch requests to change the visibility of an existing topic, so `last_updated` is better name for this field. This commit does not affect the API or events in any way, but only the database.
This commit is contained in:
parent
ea6a40661c
commit
2aea944a7e
|
@ -277,7 +277,7 @@ ANALYTICS_TABLES = {
|
|||
DATE_FIELDS: Dict[TableName, List[Field]] = {
|
||||
"zerver_attachment": ["create_time"],
|
||||
"zerver_message": ["last_edit_time", "date_sent"],
|
||||
"zerver_mutedtopic": ["date_muted"],
|
||||
"zerver_mutedtopic": ["last_updated"],
|
||||
"zerver_realm": ["date_created"],
|
||||
"zerver_stream": ["date_created"],
|
||||
"zerver_useractivity": ["last_visit"],
|
||||
|
|
|
@ -21,10 +21,10 @@ def get_topic_mutes(
|
|||
rows = query.values(
|
||||
"stream__name",
|
||||
"topic_name",
|
||||
"date_muted",
|
||||
"last_updated",
|
||||
)
|
||||
return [
|
||||
(row["stream__name"], row["topic_name"], datetime_to_timestamp(row["date_muted"]))
|
||||
(row["stream__name"], row["topic_name"], datetime_to_timestamp(row["last_updated"]))
|
||||
for row in rows
|
||||
]
|
||||
|
||||
|
@ -71,7 +71,7 @@ def add_topic_mute(
|
|||
stream_id=stream_id,
|
||||
recipient_id=recipient_id,
|
||||
topic_name=topic_name,
|
||||
date_muted=date_muted,
|
||||
last_updated=date_muted,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.5 on 2021-07-29 11:47
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0347_realm_emoji_animated"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name="usertopic",
|
||||
old_name="date_muted",
|
||||
new_name="last_updated",
|
||||
),
|
||||
]
|
|
@ -2198,10 +2198,10 @@ class UserTopic(models.Model):
|
|||
stream: Stream = models.ForeignKey(Stream, on_delete=CASCADE)
|
||||
recipient: Recipient = models.ForeignKey(Recipient, on_delete=CASCADE)
|
||||
topic_name: str = models.CharField(max_length=MAX_TOPIC_NAME_LENGTH)
|
||||
# The default value for date_muted is a few weeks before tracking
|
||||
# The default value for last_updated is a few weeks before tracking
|
||||
# of when topics were muted was first introduced. It's designed
|
||||
# to be obviously incorrect so that users can tell it's backfilled data.
|
||||
date_muted: datetime.datetime = models.DateTimeField(
|
||||
# to be obviously incorrect so that one can tell it's backfilled data.
|
||||
last_updated: datetime.datetime = models.DateTimeField(
|
||||
default=datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
|
||||
)
|
||||
|
||||
|
@ -2214,7 +2214,7 @@ class UserTopic(models.Model):
|
|||
db_table = "zerver_mutedtopic"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"<UserTopic: ({self.user_profile.email}, {self.stream.name}, {self.topic_name}, {self.date_muted})>"
|
||||
return f"<UserTopic: ({self.user_profile.email}, {self.stream.name}, {self.topic_name}, {self.last_updated})>"
|
||||
|
||||
|
||||
class MutedUser(models.Model):
|
||||
|
|
|
@ -69,13 +69,13 @@ class MutedTopicsTests(ZulipTestCase):
|
|||
mute_topic_for_user(hamlet)
|
||||
user_ids = stream_topic_target.user_ids_muting_topic()
|
||||
self.assertEqual(user_ids, {hamlet.id})
|
||||
hamlet_date_muted = UserTopic.objects.filter(user_profile=hamlet)[0].date_muted
|
||||
hamlet_date_muted = UserTopic.objects.filter(user_profile=hamlet)[0].last_updated
|
||||
self.assertTrue(timezone_now() - hamlet_date_muted <= timedelta(seconds=100))
|
||||
|
||||
mute_topic_for_user(cordelia)
|
||||
user_ids = stream_topic_target.user_ids_muting_topic()
|
||||
self.assertEqual(user_ids, {hamlet.id, cordelia.id})
|
||||
cordelia_date_muted = UserTopic.objects.filter(user_profile=cordelia)[0].date_muted
|
||||
cordelia_date_muted = UserTopic.objects.filter(user_profile=cordelia)[0].last_updated
|
||||
self.assertTrue(timezone_now() - cordelia_date_muted <= timedelta(seconds=100))
|
||||
|
||||
def test_add_muted_topic(self) -> None:
|
||||
|
|
Loading…
Reference in New Issue