Completed processing of blueprints data

* Update blueprints with number of mentions (emails, commits, reviews)
 * Improved understandability of record processor tests (significantly refactored)
 * Extracted LP specific functions into launchpad_utils
 * Refactored activity template in UI

Implements bp metric-by-bugs-blueprints

Change-Id: I9008a84ef1960e54be6e61f0ef3d69cd2cc1d9e4
This commit is contained in:
Ilya Shakhat
2013-09-17 21:26:01 +04:00
parent 193d285019
commit 47f26a2f29
10 changed files with 943 additions and 403 deletions

View File

@@ -13,10 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import httplib
import urlparse
from stackalytics.openstack.common import log as logging
from stackalytics.processor import launchpad_utils
from stackalytics.processor import utils
@@ -27,18 +25,6 @@ LINK_FIELDS = ['owner', 'drafter', 'starter', 'completer',
DATE_FIELDS = ['date_created', 'date_completed', 'date_started']
def _module_exists(module):
uri = 'https://api.launchpad.net/devel/%s' % module
parsed_uri = urlparse.urlparse(uri)
conn = httplib.HTTPConnection(parsed_uri.netloc)
conn.request('GET', parsed_uri.path)
res = conn.getresponse()
LOG.debug('Checked uri: %(uri)s, status: %(status)s',
{'uri': uri, 'status': res.status})
conn.close()
return res.status != 404
def _link_to_launchpad_id(link):
return link[link.find('~') + 1:]
@@ -47,30 +33,22 @@ def log(repo):
module = repo['module']
LOG.debug('Retrieving list of blueprints for module: %s', module)
if not _module_exists(module):
if not launchpad_utils.lp_module_exists(module):
LOG.debug('Module %s not exist at Launchpad', module)
return
uri = 'https://api.launchpad.net/devel/%s/all_specifications' % module
while True:
LOG.debug('Reading chunk from uri %s', uri)
chunk = utils.read_json_from_uri(uri)
if 'next_collection_link' not in chunk:
break
uri = chunk['next_collection_link']
for record in launchpad_utils.lp_blueprint_generator(module):
for field in LINK_FIELDS:
link = record[field + '_link']
if link:
record[field] = _link_to_launchpad_id(link)
del record[field + '_link']
for field in DATE_FIELDS:
date = record[field]
if date:
record[field] = utils.iso8601_to_timestamp(date)
for record in chunk['entries']:
for field in LINK_FIELDS:
link = record[field + '_link']
if link:
record[field] = _link_to_launchpad_id(link)
del record[field + '_link']
for field in DATE_FIELDS:
date = record[field]
if date:
record[field] = utils.iso8601_to_timestamp(date)
record['module'] = module
record['module'] = module
LOG.debug('New blueprint: %s', record)
yield record
LOG.debug('New blueprint: %s', record)
yield record