Skip to content

Commit

Permalink
small correction to welcome message logic (#431)
Browse files Browse the repository at this point in the history
* add should_see_project_coverage_cta to _create_welcome_message

* explicit return

* need to check createstamp on private repos as well

* Add docstring to help future us
  • Loading branch information
nora-codecov authored May 6, 2024
1 parent 2485119 commit 5be9dcb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
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)

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

0 comments on commit 5be9dcb

Please sign in to comment.