-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add private spam metrics report with preprint inclusion
- Loading branch information
Uditi Mehta
authored and
Uditi Mehta
committed
Nov 4, 2024
1 parent
1c35276
commit 0a32b02
Showing
6 changed files
with
70 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from osf.metrics.reports import MonthlyReport | ||
from osf.external.oopspam.client import OOPSpamClient | ||
from osf.external.askismet.client import AkismetClient | ||
|
||
class PrivateSpamMetricsReporter(MonthlyReport): | ||
report_name = 'Private Spam Metrics' | ||
|
||
def report(self, report_yearmonth): | ||
target_month = report_yearmonth.target_month() | ||
next_month = report_yearmonth.next_month() | ||
|
||
oopspam_client = OOPSpamClient() | ||
akismet_client = AkismetClient() | ||
|
||
node_oopspam_flagged = oopspam_client.get_flagged_count(target_month, next_month, category='node') | ||
node_oopspam_hammed = oopspam_client.get_hammed_count(target_month, next_month, category='node') | ||
node_akismet_flagged = akismet_client.get_flagged_count(target_month, next_month, category='node') | ||
node_akismet_hammed = akismet_client.get_hammed_count(target_month, next_month, category='node') | ||
|
||
preprint_oopspam_flagged = oopspam_client.get_flagged_count(target_month, next_month, category='preprint') | ||
preprint_oopspam_hammed = oopspam_client.get_hammed_count(target_month, next_month, category='preprint') | ||
preprint_akismet_flagged = akismet_client.get_flagged_count(target_month, next_month, category='preprint') | ||
preprint_akismet_hammed = akismet_client.get_hammed_count(target_month, next_month, category='preprint') | ||
|
||
return [self.create_report( | ||
report_yearmonth=str(report_yearmonth), | ||
node_oopspam_flagged=node_oopspam_flagged, | ||
node_oopspam_hammed=node_oopspam_hammed, | ||
node_akismet_flagged=node_akismet_flagged, | ||
node_akismet_hammed=node_akismet_hammed, | ||
preprint_oopspam_flagged=preprint_oopspam_flagged, | ||
preprint_oopspam_hammed=preprint_oopspam_hammed, | ||
preprint_akismet_flagged=preprint_akismet_flagged, | ||
preprint_akismet_hammed=preprint_akismet_hammed, | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters