Skip to content

Commit 24253bd

Browse files
authored
Build: don't trigger build if the project is spam (#11976)
Use the DONT_SERVE_DOCS threshold to decide whether or not the build for this project should be triggered/skipped. This should avoid project already marked as spam to re-trigger builds and try to be re-classified as non-spam.
1 parent 5dc0b3c commit 24253bd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

readthedocs/projects/querysets.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Project model QuerySet classes."""
2+
from django.conf import settings
23
from django.db import models
34
from django.db.models import Count, OuterRef, Prefetch, Q, Subquery
45

@@ -74,6 +75,7 @@ def is_active(self, project):
7475
7576
* the Project shouldn't be marked as skipped.
7677
* any of the project's owners shouldn't be banned.
78+
* the project shouldn't have a high spam score.
7779
* the organization associated to the project should not be disabled.
7880
7981
:param project: project to be checked
@@ -82,9 +84,22 @@ def is_active(self, project):
8284
:returns: whether or not the project is active
8385
:rtype: bool
8486
"""
87+
spam_project = False
8588
any_owner_banned = any(u.profile.banned for u in project.users.all())
8689
organization = project.organizations.first()
87-
if project.skip or any_owner_banned or (organization and organization.disabled):
90+
91+
if "readthedocsext.spamfighting" in settings.INSTALLED_APPS:
92+
from readthedocsext.spamfighting.utils import spam_score # noqa
93+
94+
if spam_score(project) > settings.RTD_SPAM_THRESHOLD_DONT_SERVE_DOCS:
95+
spam_project = True
96+
97+
if (
98+
project.skip
99+
or any_owner_banned
100+
or (organization and organization.disabled)
101+
or spam_project
102+
):
88103
return False
89104

90105
return True

0 commit comments

Comments
 (0)