remove
This commit is contained in:
0
battleship/management/commands/__init__.py
Normal file
0
battleship/management/commands/__init__.py
Normal file
15
battleship/management/commands/remove.py
Normal file
15
battleship/management/commands/remove.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from datetime import timedelta
|
||||
from time import sleep
|
||||
|
||||
from django.core.management import BaseCommand
|
||||
from django.utils import timezone
|
||||
|
||||
from battleship.models import Game
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
while True:
|
||||
print('deleting old games')
|
||||
Game.objects.filter(last_move_ts__lte=timezone.now() - timedelta(days=1)).delete()
|
||||
sleep(60 * 60 * 24)
|
||||
Reference in New Issue
Block a user