Move tracking online users to redis

This commit is contained in:
Jeremy Zhang
2018-01-21 03:14:25 +00:00
parent 6b1c6179d1
commit 2c949d911b
9 changed files with 66 additions and 36 deletions

View File

@ -7,14 +7,7 @@ class AuthenticatedUsers(db.Model):
id = db.Column(db.Integer, primary_key=True) # Auto increment id
guild_id = db.Column(db.String(255), nullable=False) # Guild pretaining to the authenticated user
client_id = db.Column(db.String(255), nullable=False) # Client ID of the authenticated user
last_timestamp = db.Column(db.TIMESTAMP, nullable=False) # The timestamp of when the user has last sent the heartbeat
def __init__(self, guild_id, client_id):
self.guild_id = guild_id
self.client_id = client_id
self.last_timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
def bumpTimestamp(self):
self.last_timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
db.session.commit()
return self.last_timestamp
self.client_id = client_id