-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-query-schedule
- Loading branch information
Showing
12 changed files
with
249 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Restyled | ||
|
||
on: | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
restyled: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- uses: restyled-io/actions/setup@v4 | ||
- id: restyler | ||
uses: restyled-io/actions/run@v4 | ||
with: | ||
fail-on-differences: true | ||
|
||
- if: | | ||
!cancelled() && | ||
steps.restyler.outputs.success == 'true' && | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
base: ${{ steps.restyler.outputs.restyled-base }} | ||
branch: ${{ steps.restyler.outputs.restyled-head }} | ||
title: ${{ steps.restyler.outputs.restyled-title }} | ||
body: ${{ steps.restyler.outputs.restyled-body }} | ||
labels: "restyled" | ||
reviewers: ${{ github.event.pull_request.user.login }} | ||
delete-branch: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"""fix_hash | ||
Revision ID: 9e8c841d1a30 | ||
Revises: 7205816877ec | ||
Create Date: 2024-10-05 18:55:35.730573 | ||
""" | ||
import logging | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.sql import table | ||
from sqlalchemy import select | ||
|
||
from redash.query_runner import BaseQueryRunner, get_query_runner | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '9e8c841d1a30' | ||
down_revision = '7205816877ec' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def update_query_hash(record): | ||
should_apply_auto_limit = record['options'].get("apply_auto_limit", False) if record['options'] else False | ||
query_runner = get_query_runner(record['type'], {}) if record['type'] else BaseQueryRunner({}) | ||
query_text = record['query'] | ||
|
||
parameters_dict = {p["name"]: p.get("value") for p in record['options'].get('parameters', [])} if record.options else {} | ||
if any(parameters_dict): | ||
print(f"Query {record['query_id']} has parameters. Hash might be incorrect.") | ||
|
||
return query_runner.gen_query_hash(query_text, should_apply_auto_limit) | ||
|
||
|
||
def upgrade(): | ||
conn = op.get_bind() | ||
|
||
metadata = sa.MetaData(bind=conn) | ||
queries = sa.Table("queries", metadata, autoload=True) | ||
data_sources = sa.Table("data_sources", metadata, autoload=True) | ||
|
||
joined_table = queries.outerjoin(data_sources, queries.c.data_source_id == data_sources.c.id) | ||
|
||
query = select([ | ||
queries.c.id.label("query_id"), | ||
queries.c.query, | ||
queries.c.query_hash, | ||
queries.c.options, | ||
data_sources.c.id.label("data_source_id"), | ||
data_sources.c.type | ||
]).select_from(joined_table) | ||
|
||
for record in conn.execute(query): | ||
new_hash = update_query_hash(record) | ||
print(f"Updating hash for query {record['query_id']} from {record['query_hash']} to {new_hash}") | ||
conn.execute( | ||
queries.update() | ||
.where(queries.c.id == record['query_id']) | ||
.values(query_hash=new_hash)) | ||
|
||
|
||
def downgrade(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ force-exclude = ''' | |
|
||
[tool.poetry] | ||
name = "redash" | ||
version = "24.09.0-dev" | ||
version = "24.10.0-dev" | ||
description = "Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data." | ||
authors = ["Arik Fraimovich <[email protected]>"] | ||
# to be added to/removed from the mailing list, please reach out to Arik via the above email or Discord | ||
|
@@ -29,7 +29,7 @@ authlib = "0.15.5" | |
backoff = "2.2.1" | ||
blinker = "1.6.2" | ||
click = "8.1.3" | ||
cryptography = "42.0.8" | ||
cryptography = "43.0.1" | ||
disposable-email-domains = ">=0.0.52" | ||
flask = "2.3.2" | ||
flask-limiter = "3.3.1" | ||
|
@@ -65,7 +65,7 @@ pyyaml = "6.0.1" | |
redis = "4.6.0" | ||
regex = "2023.8.8" | ||
requests = "2.32.3" | ||
restrictedpython = "6.2" | ||
restrictedpython = "7.3" | ||
rq = "1.16.1" | ||
rq-scheduler = "0.13.1" | ||
semver = "2.8.1" | ||
|
@@ -130,7 +130,7 @@ python-rapidjson = "1.20" | |
requests-aws-sign = "0.1.5" | ||
sasl = ">=0.1.3" | ||
simple-salesforce = "0.74.3" | ||
snowflake-connector-python = "3.12.0" | ||
snowflake-connector-python = "3.12.3" | ||
td-client = "1.0.0" | ||
thrift = ">=0.8.0" | ||
thrift-sasl = ">=0.1.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from unittest.mock import MagicMock, patch | ||
|
||
from redash import rq_redis_connection | ||
from redash.monitor import rq_job_ids | ||
|
||
|
||
def test_rq_job_ids_uses_rq_redis_connection(): | ||
mock_queue = MagicMock() | ||
mock_queue.job_ids = [] | ||
|
||
mock_registry = MagicMock() | ||
mock_registry.get_job_ids.return_value = [] | ||
|
||
with patch("redash.monitor.Queue") as mock_Queue, patch( | ||
"redash.monitor.StartedJobRegistry" | ||
) as mock_StartedJobRegistry: | ||
mock_Queue.all.return_value = [mock_queue] | ||
mock_StartedJobRegistry.return_value = mock_registry | ||
|
||
rq_job_ids() | ||
|
||
mock_Queue.all.assert_called_once_with(connection=rq_redis_connection) | ||
mock_StartedJobRegistry.assert_called_once_with(queue=mock_queue) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters