Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiedemaria committed Aug 13, 2024
1 parent cc58f35 commit 89321ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# CURRENT_TIMESTAMP only has second precision for sqlite, so if we create runs and backfills without any delay
# the resulting list is a chunk of runs and then a chunk of backfills when ordered by time. Adding a small
# delay between creating a run and a backfill makes the resulting list more interwoven
CREATE_DELAY = 0.5
CREATE_DELAY = 1


def _create_run(graphql_context) -> DagsterRun:
Expand Down Expand Up @@ -99,6 +99,24 @@ def gql_context_with_runs_and_backfills(self, class_scoped_graphql_context):
return class_scoped_graphql_context

def test_get_runs_feed(self, gql_context_with_runs_and_backfills):
result = execute_dagster_graphql(
gql_context_with_runs_and_backfills.create_request_context(),
GET_RUNS_FEED_QUERY,
variables={
"limit": 25,
"cursor": None,
},
)
prev_run_time = None
id_to_timestamp_mapping = {}
for res in result.data["runsFeedOrError"]["results"]:
id_to_timestamp_mapping[res["runId"]] = res["creationTime"]
if prev_run_time:
assert res["creationTime"] <= prev_run_time
prev_run_time = res["creationTime"]

print(id_to_timestamp_mapping)

result = execute_dagster_graphql(
gql_context_with_runs_and_backfills.create_request_context(),
GET_RUNS_FEED_QUERY,
Expand All @@ -113,11 +131,15 @@ def test_get_runs_feed(self, gql_context_with_runs_and_backfills):

assert len(result.data["runsFeedOrError"]["results"]) == 10
prev_run_time = None
id_to_timestamp_mapping = {}
for res in result.data["runsFeedOrError"]["results"]:
id_to_timestamp_mapping[res["runId"]] = res["creationTime"]
if prev_run_time:
assert res["creationTime"] <= prev_run_time
prev_run_time = res["creationTime"]

print(id_to_timestamp_mapping)

assert result.data["runsFeedOrError"]["hasMore"]
old_cursor = result.data["runsFeedOrError"]["cursor"]
assert old_cursor is not None
Expand All @@ -131,12 +153,19 @@ def test_get_runs_feed(self, gql_context_with_runs_and_backfills):
},
)

id_to_timestamp_mapping = {}
for res in result.data["runsFeedOrError"]["results"]:
id_to_timestamp_mapping[res["runId"]] = res["creationTime"]

assert len(result.data["runsFeedOrError"]["results"]) == 10
for res in result.data["runsFeedOrError"]["results"]:
if prev_run_time:
assert res["creationTime"] <= prev_run_time
prev_run_time = res["creationTime"]

print(id_to_timestamp_mapping)
# assert False

assert not result.data["runsFeedOrError"]["hasMore"]

def test_get_runs_feed_inexact_limit(self, gql_context_with_runs_and_backfills):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,9 @@ def get_backfills(
)
query = query.where(BulkActionsTable.c.id < cursor_query)
if created_after:
query = query.where(
BulkActionsTable.c.timestamp > created_after.replace(tzinfo=None).timestamp()
)
query = query.where(BulkActionsTable.c.timestamp > created_after)
if created_before:
query = query.where(
BulkActionsTable.c.timestamp < created_before.replace(tzinfo=None).timestamp()
)
query = query.where(BulkActionsTable.c.timestamp < created_before)
if limit:
query = query.limit(limit)
query = query.order_by(BulkActionsTable.c.id.desc())
Expand Down

0 comments on commit 89321ea

Please sign in to comment.