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

[ENG-4438] Add Spam Reversal Metric Numbers #10352

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
109 changes: 108 additions & 1 deletion osf/metrics/reporters/spam_count.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from osf.models import OSFUser
from osf.models import (
OSFUser,
Node,
Registration,
Preprint
)

from osf.metrics.reports import SpamSummaryReport
from ._base import MonthlyReporter
Expand Down Expand Up @@ -33,6 +38,40 @@ def report(self, report_yearmonth):
created__lt=next_month,
node__type='osf.node',
).count(),
node_flagged_reversed=Node.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).distinct().count(),
node_flagged_reversed_akismet=Node.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='akismet'
).distinct().count(),
node_flagged_reversed_oopspam=Node.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='oopspam'
).distinct().count(),
node_flagged_reversed_both=Node.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='both'
Johnetordoff marked this conversation as resolved.
Show resolved Hide resolved
).distinct().count(),
# Registration Log entries
registration_confirmed_spam=NodeLog.objects.filter(
action=NodeLog.CONFIRM_SPAM,
Expand All @@ -52,6 +91,40 @@ def report(self, report_yearmonth):
created__lt=next_month,
node__type='osf.registration',
).count(),
registration_flagged_reversed=Registration.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).distinct().count(),
registration_flagged_reversed_akismet=Registration.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='akismet'
).distinct().count(),
registration_flagged_reversed_oopspam=Registration.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='oopspam'
).distinct().count(),
registration_flagged_reversed_both=Registration.objects.filter(
logs__action=NodeLog.FLAG_SPAM
).filter(
logs__action=NodeLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='both'
).distinct().count(),
# Preprint Log entries
preprint_confirmed_spam=PreprintLog.objects.filter(
action=PreprintLog.CONFIRM_SPAM,
Expand All @@ -68,6 +141,40 @@ def report(self, report_yearmonth):
created__gt=target_month,
created__lt=next_month,
).count(),
preprint_flagged_reversed=Preprint.objects.filter(
logs__action=PreprintLog.FLAG_SPAM
).filter(
logs__action=PreprintLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).distinct().count(),
preprint_flagged_reversed_akismet=Preprint.objects.filter(
logs__action=PreprintLog.FLAG_SPAM
).filter(
logs__action=PreprintLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='akismet'
).distinct().count(),
preprint_flagged_reversed_oopspam=Preprint.objects.filter(
logs__action=PreprintLog.FLAG_SPAM
).filter(
logs__action=PreprintLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='oopspam'
).distinct().count(),
preprint_flagged_reversed_both=Preprint.objects.filter(
logs__action=PreprintLog.FLAG_SPAM
).filter(
logs__action=PreprintLog.CONFIRM_HAM,
logs__created__gt=target_month,
logs__created__lt=next_month,
).filter(
spam_data__who_flagged='both'
).distinct().count(),
# New Users marked as Spam/Ham
user_marked_as_spam=OSFUser.objects.filter(
spam_status=SpamStatus.SPAM,
Expand Down