revision logic revisited
This commit is contained in:
@@ -14,6 +14,7 @@ from admin_links import cmd_remove
|
||||
from admin_links import cmd_rename
|
||||
from admin_links import cmd_unban
|
||||
from admin_links import cmd_validate_import
|
||||
from admin_links import cmd_fix_revision
|
||||
from admin_users import cmd_user_rename
|
||||
from admin_users import cmd_users
|
||||
|
||||
@@ -76,6 +77,9 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
p_validate = sub.add_parser("validate-import")
|
||||
p_validate.set_defaults(func=cmd_validate_import)
|
||||
|
||||
p_fix_rev = sub.add_parser("fix-revision")
|
||||
p_fix_rev.set_defaults(func=cmd_fix_revision)
|
||||
|
||||
p_user_rename = sub.add_parser("user-rename")
|
||||
p_user_rename.add_argument("user")
|
||||
p_user_rename.add_argument("site")
|
||||
|
||||
@@ -205,6 +205,19 @@ def cmd_validate_import(_: argparse.Namespace) -> None:
|
||||
print(" OK")
|
||||
|
||||
|
||||
def cmd_fix_revision(_: argparse.Namespace) -> None:
|
||||
with db.connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE links
|
||||
SET requires_revision = 0
|
||||
WHERE enabled = 1 OR banned_at IS NULL
|
||||
"""
|
||||
)
|
||||
conn.commit()
|
||||
print("ok")
|
||||
|
||||
|
||||
def _fzf_select(lines: list[str], multi: bool) -> list[str]:
|
||||
if not lines:
|
||||
return []
|
||||
|
||||
@@ -170,6 +170,15 @@ def add_link(
|
||||
""",
|
||||
(user_name, url_original, url_norm, site),
|
||||
)
|
||||
if tombstone:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE links
|
||||
SET requires_revision = 0
|
||||
WHERE id = ?
|
||||
""",
|
||||
(cur.lastrowid,),
|
||||
)
|
||||
add_history(
|
||||
conn,
|
||||
user_name=user_name,
|
||||
@@ -198,7 +207,7 @@ def set_enabled(
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE links
|
||||
SET enabled = 1, disabled_at = NULL, updated_at = CURRENT_TIMESTAMP
|
||||
SET enabled = 1, disabled_at = NULL, requires_revision = 0, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
""",
|
||||
(row["id"],),
|
||||
@@ -252,7 +261,7 @@ def set_banned(
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE links
|
||||
SET banned_at = NULL, banned_reason = NULL, updated_at = CURRENT_TIMESTAMP
|
||||
SET banned_at = NULL, banned_reason = NULL, requires_revision = 0, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
""",
|
||||
(row["id"],),
|
||||
|
||||
Reference in New Issue
Block a user