Permalink
Browse files

Removed Author FK on addon for faster updates.

Signed-off-by: Dries007 <admin@dries007.net>
  • Loading branch information...
dries007 committed Nov 17, 2018
1 parent 7baed58 commit e59c37db2eb390d46dfe0252688d11cb913ee8c1
Showing with 6 additions and 5 deletions.
  1. +3 −2 app/models/__init__.py
  2. +1 −1 app/tasks/__init__.py
  3. +2 −2 app/tasks/task_helpers.py
@@ -283,7 +283,8 @@ class AddonModel(db.Model):
name = db.Column(db.String, nullable=True)
game_id = db.Column(db.Integer, nullable=True) # todo: make FK with relation
# Easy to store & useful data
primary_author_name = db.Column(db.String, db.ForeignKey(AuthorModel.name, onupdate='cascade', ondelete='cascade'), nullable=True)
# primary_author_name = db.Column(db.String, db.ForeignKey(AuthorModel.name, onupdate='cascade', ondelete='cascade'), nullable=True)
primary_author_name = db.Column(db.String, nullable=True)
category_list = db.Column(db.String, nullable=True)
slug = db.Column(db.String, nullable=True)
downloads = db.Column(db.BigInteger, nullable=True)
@@ -310,7 +311,7 @@ class AddonModel(db.Model):
files = db.relationship(FileModel, backref='addon', foreign_keys=[FileModel.addon_id], lazy='dynamic')
attachments = db.relationship(AttachmentModel, backref='addon', lazy='dynamic')
# default_file = db.relationship(FileModel, foreign_keys=[default_file_id], lazy='select')
primary_author = db.relationship(AuthorModel, foreign_keys=[primary_author_name], backref='primary_addons', lazy='select')
# primary_author = db.relationship(AuthorModel, foreign_keys=[primary_author_name], backref='primary_addons', lazy='select')
authors = db.relationship(AuthorModel, secondary=author_addon_table, backref='addons', lazy='dynamic')
categories = db.relationship(CategoryModel, secondary=category_addon_table, backref='addons', lazy='dynamic')

@@ -101,7 +101,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs):
sender.add_periodic_task(45 * 60, p_fill_incomplete_addons.s())

sender.add_periodic_task(6 * 60 * 60, p_update_all_files.s())
sender.add_periodic_task(24 * 60 * 60, p_find_hidden_addons.s())
# sender.add_periodic_task(7 * 24 * 60 * 60, p_find_hidden_addons.s())

sender.add_periodic_task(crontab(minute='0'), p_keep_history.s())

@@ -53,8 +53,8 @@ def request_addons_by_id(ids: [int]):
if x:
x.status = AddonStatusEnum.Deleted
db.session.commit()
else:
redis_store.sadd('cursemeta-periodic-failedById', id_)
# else:
# redis_store.sadd('cursemeta-periodic-failedById', id_)
except:
logger.exception('Error setting deleted on {}'.format(id_))
else:

0 comments on commit e59c37d

Please sign in to comment.