Skip to content

Commit

Permalink
fix(migrate_analytics): fix migrate_to_pg command (#4139)
Browse files Browse the repository at this point in the history
  • Loading branch information
gagantrivedi authored Jun 12, 2024
1 parent 7e0c9fd commit c0f373a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion api/app_analytics/migrate_to_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def migrate_feature_evaluations(migrate_till: int = 30) -> None:
for i in range(migrate_till):
range_start = f"-{i+1}d"
range_stop = f"-{i}d"
query = f"from (bucket: {read_bucket}) |> range(start: {range_start}, stop: {range_stop})"
query = (
f'from (bucket: "{read_bucket}") '
f"|> range(start: {range_start}, stop: {range_stop}) "
f'|> filter(fn: (r) => r._measurement == "feature_evaluation")'
)

result = query_api.query(query)

Expand Down
18 changes: 15 additions & 3 deletions api/tests/unit/app_analytics/test_migrate_to_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,25 @@ def test_migrate_feature_evaluations(mocker: MockerFixture) -> None:
mock_query_api.assert_has_calls(
[
mocker.call.query(
f"from (bucket: {read_bucket}) |> range(start: -1d, stop: -0d)"
(
f'from (bucket: "{read_bucket}") '
f"|> range(start: -1d, stop: -0d) "
f'|> filter(fn: (r) => r._measurement == "feature_evaluation")'
)
),
mocker.call.query(
f"from (bucket: {read_bucket}) |> range(start: -2d, stop: -1d)"
(
f'from (bucket: "{read_bucket}") '
f"|> range(start: -2d, stop: -1d) "
f'|> filter(fn: (r) => r._measurement == "feature_evaluation")'
)
),
mocker.call.query(
f"from (bucket: {read_bucket}) |> range(start: -3d, stop: -2d)"
(
f'from (bucket: "{read_bucket}") '
f"|> range(start: -3d, stop: -2d) "
f'|> filter(fn: (r) => r._measurement == "feature_evaluation")'
)
),
]
)

0 comments on commit c0f373a

Please sign in to comment.