From ec6fdd92d4bed45ba079eb2d784b144db755f8cf Mon Sep 17 00:00:00 2001 From: Aditya Bansal Date: Mon, 10 Jul 2017 19:25:15 +0530 Subject: [PATCH] models: Add long_term_idle/last_active_message_id to UserProfile. In this commit we are adding two new fields to the UserProfile table. These fields are the: long_term_idle: For storing a bool value representing status of user being online in long time where 'long' will have a specific definition. last_active_message_id: For storing the message id which was last updated into the UserMessage table for a particular user. --- zerver/migrations/0089_auto_20170710_1353.py | 25 ++++++++++++++++++++ zerver/models.py | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 zerver/migrations/0089_auto_20170710_1353.py diff --git a/zerver/migrations/0089_auto_20170710_1353.py b/zerver/migrations/0089_auto_20170710_1353.py new file mode 100644 index 0000000000..11e3fb203f --- /dev/null +++ b/zerver/migrations/0089_auto_20170710_1353.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.2 on 2017-07-10 13:53 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('zerver', '0088_remove_referral_and_invites'), + ] + + operations = [ + migrations.AddField( + model_name='userprofile', + name='last_active_message_id', + field=models.IntegerField(null=True), + ), + migrations.AddField( + model_name='userprofile', + name='long_term_idle', + field=models.BooleanField(db_index=True, default=False), + ), + ] diff --git a/zerver/models.py b/zerver/models.py index 13cfb770f4..d27a7c6351 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -561,6 +561,7 @@ class UserProfile(ModelReprMixin, AbstractBaseUser, PermissionsMixin): date_joined = models.DateTimeField(default=timezone_now) # type: datetime.datetime is_mirror_dummy = models.BooleanField(default=False) # type: bool bot_owner = models.ForeignKey('self', null=True, on_delete=models.SET_NULL) # type: Optional[UserProfile] + long_term_idle = models.BooleanField(default=False, db_index=True) # type: bool USERNAME_FIELD = 'email' MAX_NAME_LENGTH = 100 @@ -577,6 +578,7 @@ class UserProfile(ModelReprMixin, AbstractBaseUser, PermissionsMixin): realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm api_key = models.CharField(max_length=API_KEY_LENGTH) # type: Text tos_version = models.CharField(null=True, max_length=10) # type: Optional[Text] + last_active_message_id = models.IntegerField(null=True) # type: int ### Notifications settings. ###