Skip to content

Commit

Permalink
add manage.py queries rehash cli command to rehash queries
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr authored and justinclift committed Oct 25, 2024
1 parent 4633fe2 commit baaf3c5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions redash/cli/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
manager = AppGroup(help="Queries management commands.")


@manager.command(name="rehash")
def rehash():
from redash import models

for q in models.Query.query.all():
old_hash = q.query_hash
q.update_query_hash()
new_hash = q.query_hash

if old_hash != new_hash:
print(f"Query {q.id} has changed hash from {old_hash} to {new_hash}")
models.db.session.add(q)

models.db.session.commit()


@manager.command(name="add_tag")
@argument("query_id")
@argument("tag")
Expand Down

0 comments on commit baaf3c5

Please sign in to comment.