Compare commits
No commits in common. "38e16f92e820696949d407bc174e8f6ab251b58c" and "15e68b88e8c1e58ff41f558bce7eeb3b19ff3c77" have entirely different histories.
38e16f92e8
...
15e68b88e8
@ -1,14 +0,0 @@
|
|||||||
from server import db
|
|
||||||
import time
|
|
||||||
from database.models import Device
|
|
||||||
|
|
||||||
def cleanDevices():
|
|
||||||
allDevs = db.session.query(Device)
|
|
||||||
devices = allDevs.filter(Device.lastConnection <= int(round(time.time())) - 60*60*24*30).all()
|
|
||||||
devices += allDevs.filter(Device.lastConnection == None)
|
|
||||||
for device in devices:
|
|
||||||
print(device.deviceName)
|
|
||||||
db.session.delete(device)
|
|
||||||
|
|
||||||
db.session.commit()
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
"""empty message
|
|
||||||
|
|
||||||
Revision ID: 121eab3835ee
|
|
||||||
Revises: e5ef5e4a807b
|
|
||||||
Create Date: 2020-07-17 08:03:36.947158
|
|
||||||
|
|
||||||
"""
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision = '121eab3835ee'
|
|
||||||
down_revision = 'e5ef5e4a807b'
|
|
||||||
branch_labels = None
|
|
||||||
depends_on = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.add_column('device', sa.Column('lastConnection', sa.BigInteger(), nullable=True))
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.drop_column('device', 'lastConnection')
|
|
||||||
# ### end Alembic commands ###
|
|
@ -61,7 +61,6 @@ class Device(db.Model):
|
|||||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
||||||
deviceName = db.Column(db.String(64), unique=True)
|
deviceName = db.Column(db.String(64), unique=True)
|
||||||
connection = db.Column(db.Boolean)
|
connection = db.Column(db.Boolean)
|
||||||
lastConnection = db.Column(db.BigInteger)
|
|
||||||
|
|
||||||
class Calendar(db.Model):
|
class Calendar(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Python standard libraries
|
# Python standard libraries
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import time
|
|
||||||
|
|
||||||
# Third-party libraries
|
# Third-party libraries
|
||||||
import flask
|
import flask
|
||||||
@ -205,7 +204,6 @@ def downloader(device):
|
|||||||
if request_device.user_id == None:
|
if request_device.user_id == None:
|
||||||
return jsonify(kind="unregistered")
|
return jsonify(kind="unregistered")
|
||||||
|
|
||||||
request_device.lastConnection=int(round(time.time()))
|
|
||||||
request_device.connection=True
|
request_device.connection=True
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
request_user = db.session.query(User).filter(User.id==request_device.user_id).first()
|
request_user = db.session.query(User).filter(User.id==request_device.user_id).first()
|
||||||
@ -235,7 +233,6 @@ def generateDeviceFingerprint():
|
|||||||
if not db.session.query(Device).filter(Device.deviceName==fingerprint).first():
|
if not db.session.query(Device).filter(Device.deviceName==fingerprint).first():
|
||||||
# Save as new Device
|
# Save as new Device
|
||||||
device = Device(deviceName=fingerprint, connection=False)
|
device = Device(deviceName=fingerprint, connection=False)
|
||||||
device.lastConnection = int(round(time.time()))
|
|
||||||
db.session.add(device)
|
db.session.add(device)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user