Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaevg committed Apr 21, 2024
1 parent afd068c commit 6d25e56
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,8 @@
"posthog_survey"."start_date",
"posthog_survey"."end_date",
"posthog_survey"."updated_at",
"posthog_survey"."archived"
"posthog_survey"."archived",
"posthog_survey"."responses_limit"
FROM "posthog_survey"
WHERE "posthog_survey"."linked_flag_id" = 2
'''
Expand Down
1 change: 1 addition & 0 deletions posthog/api/test/__snapshots__/test_survey.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"posthog_survey"."end_date",
"posthog_survey"."updated_at",
"posthog_survey"."archived",
"posthog_survey"."responses_limit",
"posthog_featureflag"."id",
"posthog_featureflag"."key",
"posthog_featureflag"."name",
Expand Down
1 change: 1 addition & 0 deletions posthog/api/test/test_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ def test_can_list_surveys(self):
"archived": False,
"start_date": None,
"end_date": None,
"responses_limit": None,
}
],
}
Expand Down
5 changes: 2 additions & 3 deletions posthog/tasks/stop_surveys_reached_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ def stop_surveys_reached_target() -> None:
all_surveys = Survey.objects.exclude(responses_limit__isnull=True).only(
"id", "responses_limit", "team_id", "created_at"
)
if not all_surveys:
return

for team_id, team_surveys in groupby(all_surveys, lambda survey: survey.team_id):
all_surveys_sorted = sorted(all_surveys, key=lambda survey: survey.team_id)
for team_id, team_surveys in groupby(all_surveys_sorted, lambda survey: survey.team_id):
team_surveys_list = list(team_surveys)
surveys_ids = [survey.id for survey in team_surveys_list]
earliest_survey_start_date = min([survey.created_at for survey in team_surveys_list])
Expand Down
6 changes: 3 additions & 3 deletions posthog/tasks/test/test_stop_surveys_reached_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ def test_stop_surveys_with_enough_responses(self) -> None:
created_by=self.user,
linked_flag=self.flag,
responses_limit=1,
created_at=now() - relativedelta(hours=12),
created_at=now(),
),
Survey.objects.create(
name="2",
team=self.team1,
created_by=self.user,
linked_flag=self.flag,
responses_limit=1,
created_at=now() - relativedelta(hours=12),
created_at=now(),
),
Survey.objects.create(
name="3",
team=self.team2,
created_by=self.user,
linked_flag=self.flag,
responses_limit=1,
created_at=now() - relativedelta(hours=12),
created_at=now(),
),
]

Expand Down

0 comments on commit 6d25e56

Please sign in to comment.