Skip to content

Commit

Permalink
Merge branch 'master' into version-check
Browse files Browse the repository at this point in the history
  • Loading branch information
justinclift authored Nov 6, 2024
2 parents a91a07a + 49277d2 commit f1eae11
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redash-client",
"version": "24.10.0-dev",
"version": "24.11.0-dev",
"description": "The frontend part of Redash.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -55,7 +55,7 @@
"d3": "^3.5.17",
"debug": "^3.2.7",
"dompurify": "^2.0.17",
"elliptic": "^6.5.7",
"elliptic": "^6.6.0",
"font-awesome": "^4.7.0",
"history": "^4.10.1",
"hoist-non-react-statics": "^3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ force-exclude = '''

[tool.poetry]
name = "redash"
version = "24.10.0-dev"
version = "24.11.0-dev"
description = "Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data."
authors = ["Arik Fraimovich <arik@redash.io>"]
# to be added to/removed from the mailing list, please reach out to Arik via the above email or Discord
Expand Down
2 changes: 1 addition & 1 deletion redash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from redash.destinations import import_destinations
from redash.query_runner import import_query_runners

__version__ = "24.10.0-dev"
__version__ = "24.11.0-dev"


if os.environ.get("REMOTE_DEBUG"):
Expand Down
15 changes: 12 additions & 3 deletions redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ def groups(self):


def should_schedule_next(previous_iteration, now, interval, time=None, day_of_week=None, failures=0):
# if previous_iteration is None, it means the query has never been run before
# so we should schedule it immediately
if previous_iteration is None:
return True
# if time exists then interval > 23 hours (82800s)
# if day_of_week exists then interval > 6 days (518400s)
if time is None:
Expand Down Expand Up @@ -602,6 +606,11 @@ def outdated_queries(cls):
if query.schedule.get("disabled"):
continue

# Skip queries that have None for all schedule values. It's unclear whether this
# something that can happen in practice, but we have a test case for it.
if all(value is None for value in query.schedule.values()):
continue

if query.schedule["until"]:
schedule_until = pytz.utc.localize(datetime.datetime.strptime(query.schedule["until"], "%Y-%m-%d"))

Expand All @@ -613,7 +622,7 @@ def outdated_queries(cls):
)

if should_schedule_next(
retrieved_at or now,
retrieved_at,
now,
query.schedule["interval"],
query.schedule["time"],
Expand Down Expand Up @@ -959,9 +968,9 @@ def get_by_id_and_org(cls, object_id, org):
return super(Alert, cls).get_by_id_and_org(object_id, org, Query)

def evaluate(self):
data = self.query_rel.latest_query_data.data
data = self.query_rel.latest_query_data.data if self.query_rel.latest_query_data else None

if data["rows"] and self.options["column"] in data["rows"][0]:
if data and data["rows"] and self.options["column"] in data["rows"][0]:
op = OPERATORS.get(self.options["op"], lambda v, t: False)

if "selector" not in self.options:
Expand Down
7 changes: 7 additions & 0 deletions tests/models/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def test_evaluates_correctly_with_max_selector(self):
alert.options["selector"] = "max"
self.assertEqual(alert.evaluate(), Alert.UNKNOWN_STATE)

def test_evaluate_alerts_without_query_rel(self):
query = self.factory.create_query(latest_query_data_id=None)
alert = self.factory.create_alert(
query_rel=query, options={"selector": "first", "op": "equals", "column": "foo", "value": "1"}
)
self.assertEqual(alert.evaluate(), Alert.UNKNOWN_STATE)


class TestNextState(TestCase):
def test_numeric_value(self):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@ def test_enqueues_query_only_once(self):

self.assertEqual(list(models.Query.outdated_queries()), [query2])

def test_enqueues_scheduled_query_without_latest_query_data(self):
"""
Queries with a schedule but no latest_query_data will still be reported by Query.outdated_queries()
"""
query = self.factory.create_query(
schedule=self.schedule(interval="60"),
data_source=self.factory.create_data_source(),
)

outdated_queries = models.Query.outdated_queries()
self.assertEqual(query.latest_query_data, None)
self.assertEqual(len(outdated_queries), 1)
self.assertIn(query, outdated_queries)

def test_enqueues_query_with_correct_data_source(self):
"""
Queries from different data sources will be reported by
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5533,10 +5533,10 @@ elementary-circuits-directed-graph@^1.0.4:
dependencies:
strongly-connected-components "^1.0.1"

elliptic@^6.0.0, elliptic@^6.5.4, elliptic@^6.5.7:
version "6.5.7"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.7.tgz#8ec4da2cb2939926a1b9a73619d768207e647c8b"
integrity sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==
elliptic@^6.0.0, elliptic@^6.5.4, elliptic@^6.6.0:
version "6.6.0"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.0.tgz#5919ec723286c1edf28685aa89261d4761afa210"
integrity sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==
dependencies:
bn.js "^4.11.9"
brorand "^1.1.0"
Expand Down

0 comments on commit f1eae11

Please sign in to comment.