mirror of
https://github.com/minetest/contentdb.git
synced 2024-09-07 22:56:44 +02:00
Delete inactive user accounts after 12 hours
This commit is contained in:
parent
0486eb76c0
commit
bc371f1ef3
@ -3,3 +3,4 @@ data*
|
||||
uploads
|
||||
*.pyc
|
||||
__pycache__
|
||||
env
|
||||
|
@ -13,6 +13,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from logging import Filter
|
||||
|
||||
import flask
|
||||
@ -67,24 +68,28 @@ celery = make_celery(app)
|
||||
CELERYBEAT_SCHEDULE = {
|
||||
'topic_list_import': {
|
||||
'task': 'app.tasks.forumtasks.importTopicList',
|
||||
'schedule': crontab(minute=1, hour=1),
|
||||
'schedule': crontab(minute=1, hour=1), # 0101
|
||||
},
|
||||
'package_score_update': {
|
||||
'task': 'app.tasks.pkgtasks.updatePackageScores',
|
||||
'schedule': crontab(minute=10, hour=1),
|
||||
'schedule': crontab(minute=10, hour=1), # 0110
|
||||
},
|
||||
'check_for_updates': {
|
||||
'task': 'app.tasks.importtasks.check_for_updates',
|
||||
'schedule': crontab(minute=10, hour=1),
|
||||
'schedule': crontab(minute=10, hour=1), # 0110
|
||||
},
|
||||
'send_pending_notifications': {
|
||||
'task': 'app.tasks.emails.send_pending_notifications',
|
||||
'schedule': crontab(minute='*/5'),
|
||||
'schedule': crontab(minute='*/5'), # every 5 minutes
|
||||
},
|
||||
'send_notification_digests': {
|
||||
'task': 'app.tasks.emails.send_pending_digests',
|
||||
'schedule': crontab(minute=0, hour=14),
|
||||
}
|
||||
'schedule': crontab(minute=0, hour=14), # 1400
|
||||
},
|
||||
'delete_inactive_users': {
|
||||
'task': 'app.tasks.users.delete_inactive_users',
|
||||
'schedule': crontab(minute=15), # every hour at quarter past
|
||||
},
|
||||
}
|
||||
celery.conf.beat_schedule = CELERYBEAT_SCHEDULE
|
||||
|
||||
|
26
app/tasks/usertasks.py
Normal file
26
app/tasks/usertasks.py
Normal file
@ -0,0 +1,26 @@
|
||||
# ContentDB
|
||||
# Copyright (C) 2021 rubenwardy
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import datetime
|
||||
from app.models import User
|
||||
from app.tasks import celery
|
||||
|
||||
|
||||
@celery.task()
|
||||
def delete_inactive_users():
|
||||
threshold = datetime.datetime.now() - datetime.timedelta(hours=12)
|
||||
User.query.filter(User.is_active==False, User.packages==None, User.created_at<=threshold).delete()
|
Loading…
Reference in New Issue
Block a user