Last active
August 29, 2015 14:17
-
-
Save shiplunc/38d895470afffe63f7fb to your computer and use it in GitHub Desktop.
Generate Publishers list by month
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
from datetime import datetime | |
from analytics import tasks | |
from analytics.reporting import getty_reporter as gr | |
from theplatform.newscred.models import User | |
import calendar | |
import sys | |
def get_publisher_of_month(credentials, year, month): | |
_, end_day = calendar.monthrange(year, month) | |
start_date = datetime(year, month, 1, 0, 0, 0) | |
end_date = datetime(year, month, end_day, 23, 59, 59) | |
usage_reporter = gr.GettyUsageReporter(credentials, start_date, end_date) | |
return usage_reporter.get_publisher_list() | |
if __name__ == '__main__': | |
publishers = get_publisher_of_month(tasks.ThinkStockCredentials(), | |
int(sys.argv[1]), | |
int(sys.argv[2])) | |
for access_key, count in publishers: | |
users = User.objects.filter(access_key__in=[access_key]) | |
for user in users: | |
print "%s\t%40s\t%s" % (user.access_key, user.name, count) |
The problem was found on actually PPI usage. Not sure about the CPV usage. Jenn S. can confirm that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scratch that, seems like the changes to the class removed that feature.