Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

models: Rename UserTopic.date_muted to last_updated.

Abhijeet Prasad Bodas2aea944a7e40
diff --git a/zerver/lib/export.py b/zerver/lib/export.py
index 5bb10e11985..1bcbcb00930 100644
--- a/zerver/lib/export.py
+++ b/zerver/lib/export.py
@@ -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"],
diff --git a/zerver/lib/topic_mutes.py b/zerver/lib/topic_mutes.py
index 9025e8c1947..112eaec301a 100644
--- a/zerver/lib/topic_mutes.py
+++ b/zerver/lib/topic_mutes.py
@@ -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,
)
diff --git a/zerver/migrations/0348_rename_date_muted_usertopic_last_updated.py b/zerver/migrations/0348_rename_date_muted_usertopic_last_updated.py
new file mode 100644
index 00000000000..19e7d16a163
--- /dev/null
+++ b/zerver/migrations/0348_rename_date_muted_usertopic_last_updated.py
@@ -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",
+ ),
+ ]
diff --git a/zerver/models.py b/zerver/models.py
index c368f7e230b..fbb8d2210d6 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -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):
diff --git a/zerver/tests/test_muting_topics.py b/zerver/tests/test_muting_topics.py
index 48753c38e82..f71a87a518e 100644
--- a/zerver/tests/test_muting_topics.py
+++ b/zerver/tests/test_muting_topics.py
@@ -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: