File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ flake8
2+ git+https://github.com/Commonists/pageview-api.git
Original file line number Diff line number Diff line change 11""" Surface image content gap. """
2- __version__ = 1.1
2+ __version__ = 1.2
Original file line number Diff line number Diff line change 66from ConfigParser import RawConfigParser
77import logging
88
9- import requests
109import mwclient
1110
1211import contentgap
1312import report
1413import mwtemplate
1514
15+ import pageviewapi .period
16+
1617# Constants
1718LOGGER_NAME = 'sicglog'
1819WIKIPEDIA_URL = '{0}.wikipedia.org'
1920PROTOCOL = 'https'
2021USER_AGENT = 'Bot based on mwclient'
21- GROK_SE_URL = "http://stats.grok.se/json/{0:s}/latest{1:d}/{2:s}"
22- GROK_MISSING_DAILY_VIEWS = "grok.se invalid result, missing daily_views"
2322MAX_TIME_WITHOUT_UPDATE = 600
2423
2524ARTICLE_NAMESPACE = 0
@@ -53,22 +52,13 @@ def latest90(article):
5352
5453 Returns:
5554 int: sum of daily views.
56-
57- Raises:
58- MissingDailyViewsException: if daily_views are missing from response.
5955 """
60- articlename = article .name .encode ('utf-8' )
61- url = GROK_SE_URL .format (article .site .site ['lang' ],
62- 90 ,
63- articlename )
64- LOG .info ('Fetching views on grok.se %s' , url )
65- result = requests .get (url ).json ()
66- if 'daily_views' in result :
67- views = sum ([result ['daily_views' ][d ]
68- for d in result ['daily_views' ]])
69- return views
70- else :
71- raise MissingDailyViewsException (GROK_MISSING_DAILY_VIEWS )
56+ project = '{lang}.wikipedia' .format (lang = article .site .site ['lang' ])
57+ return pageviewapi .period .sum_last (project ,
58+ article .name .encode ('utf-8' ),
59+ last = 90 ,
60+ access = 'all-access' ,
61+ agent = 'all-agents' )
7262
7363
7464def searcharticles (category , depth = 0 ):
Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ envlist = flake8
33skipsdist = True
44
55[testenv:flake8]
6- deps = flake8
6+ deps =
7+ -r{toxinidir}/requirements.txt
78commands = flake8
89
910[flake8]
You can’t perform that action at this time.
0 commit comments