added command to fix legacy property issues

This commit is contained in:
Aaron Kimbre 2022-04-02 16:33:23 -05:00
parent f8d5928c86
commit 70aed00d97
2 changed files with 27 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import os
from flask import Flask, url_for, g, redirect, render_template
from flask import Flask, url_for, g, redirect
from functools import wraps
from flask_assets import Environment
from webassets import Bundle
@ -12,7 +12,14 @@ from flask_wtf.csrf import CSRFProtect
from flask_apscheduler import APScheduler
from app.luclient import register_luclient_jinja_helpers
from app.commands import init_db, init_accounts, load_property, gen_image_cache, gen_model_cache
from app.commands import (
init_db,
init_accounts,
load_property,
gen_image_cache,
gen_model_cache,
fix_clone_ids
)
from app.models import Account, AccountInvitation, AuditLog
import logging
@ -90,6 +97,7 @@ def create_app():
app.cli.add_command(load_property)
app.cli.add_command(gen_image_cache)
app.cli.add_command(gen_model_cache)
app.cli.add_command(fix_clone_ids)
register_logging(app)
register_settings(app)

View File

@ -47,6 +47,23 @@ def init_accounts():
return
@click.command("fix_clone_ids")
@with_appcontext
def fix_clone_ids():
"""Fix incorrect prop_clone_id's"""
properties = Property.query.all()
count = 0
for prop in properties:
char = CharacterInfo.query.filter(CharacterInfo.id == prop.owner_id).first()
if char.prop_clone_id != prop.clone_id:
count += 1
prop.clone_id = char.prop_clone_id
prop.save()
print(f"Fixed {count} props")
return
@click.command("load_property")
@click.argument('zone')
@click.argument('player')