mirror of
https://github.com/codl/forget
synced 2025-01-13 07:53:32 +01:00
add last_delete back into account
This commit is contained in:
parent
4da2412421
commit
1502f783db
26
migrations/versions/6fd1f5b43824_add_last_delete_back.py
Normal file
26
migrations/versions/6fd1f5b43824_add_last_delete_back.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""add last_delete back
|
||||
|
||||
Revision ID: 6fd1f5b43824
|
||||
Revises: d97fa46b5560
|
||||
Create Date: 2017-08-29 17:22:00.747220
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6fd1f5b43824'
|
||||
down_revision = 'd97fa46b5560'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('accounts', sa.Column('last_delete', sa.DateTime(), nullable=True))
|
||||
op.create_index(op.f('ix_accounts_last_delete'), 'accounts', ['last_delete'], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_accounts_last_delete'), table_name='accounts')
|
||||
op.drop_column('accounts', 'last_delete')
|
2
model.py
2
model.py
@ -93,12 +93,14 @@ class Account(TimestampMixin, RemoteIDMixin):
|
||||
|
||||
last_fetch = db.Column(db.DateTime, server_default='epoch', index=True)
|
||||
last_refresh = db.Column(db.DateTime, server_default='epoch', index=True)
|
||||
last_delete = db.Column(db.DateTime, index=True)
|
||||
next_delete = db.Column(db.DateTime, server_default='epoch', index=True)
|
||||
|
||||
def touch_fetch(self):
|
||||
self.last_fetch = db.func.now()
|
||||
|
||||
def touch_delete(self):
|
||||
self.last_delete = db.func.now()
|
||||
# if it's been more than 1 delete cycle ago that we've deleted a post,
|
||||
# reset next_delete to be 1 cycle away
|
||||
if(datetime.now() - self.next_delete > self.policy_delete_every):
|
||||
|
Loading…
Reference in New Issue
Block a user