Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small correction to welcome message logic #431

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions services/notification/notifiers/comment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,20 @@ async def build_message(self, comparison: Comparison) -> List[str]:
)

def should_see_project_coverage_cta(self):
if not self.repository.private:
# public repos
"""
Why was this check added? We changed our default behavior on 5/1/2024.
Change explained on issue 1078
"""
introduction_date = datetime(2024, 5, 1, 0, 0, 0).replace(tzinfo=timezone.utc)
nora-codecov marked this conversation as resolved.
Show resolved Hide resolved

if (
not self.repository.private
and self.repository.owner.createstamp
and self.repository.owner.createstamp > introduction_date
):
# public repos, only if they signed up after introduction date
return True

introduction_date = datetime(2024, 5, 1, 0, 0, 0).replace(tzinfo=timezone.utc)
if (
not (
self.repository.owner.plan == BillingPlan.team_monthly.value
Expand Down
20 changes: 20 additions & 0 deletions services/notification/notifiers/tests/unit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5538,6 +5538,26 @@ async def test_should_see_project_coverage_cta_public_repo(
)
dbsession.flush()

notifier = CommentNotifier(
repository=sample_comparison.head.commit.repository,
title="title",
notifier_yaml_settings={"layout": "reach, diff, flags, files, footer"},
notifier_site_settings=True,
current_yaml={},
)
result = await notifier.build_message(sample_comparison)
assert PROJECT_COVERAGE_CTA not in result

after_introduction_date = datetime(2024, 6, 1, 0, 0, 0).replace(
tzinfo=timezone.utc
)
sample_comparison.head.commit.repository.owner.createstamp = (
after_introduction_date
)

dbsession.add(sample_comparison.head.commit.repository.owner)
dbsession.flush()

notifier = CommentNotifier(
repository=sample_comparison.head.commit.repository,
title="title",
Expand Down
Loading