Cache the status tags and fix the tag for images that were pushed from a build.

This commit is contained in:
jakedt 2014-03-05 14:35:11 -05:00
parent 270a62b8c1
commit 638dbb3d8d
2 changed files with 21 additions and 13 deletions

View file

@ -20,6 +20,7 @@ logger = logging.getLogger(__name__)
web = Blueprint('web', __name__)
STATUS_TAGS = app.config['STATUS_TAGS']
@web.route('/', methods=['GET'], defaults={'path': ''})
@web.route('/organization/<path:path>', methods=['GET'])
@ -211,7 +212,6 @@ def build_status_badge(namespace, repository):
abort(404)
# Lookup the tags for the repository.
tags = model.list_repository_tags(namespace, repository)
# Lookup the current/recent build.
status = 'none'
@ -220,16 +220,14 @@ def build_status_badge(namespace, repository):
if build.phase == 'error':
status = 'failed'
elif build.phase == 'complete':
pass
status = 'ready'
else:
status = 'building'
else:
tags = model.list_repository_tags(namespace, repository)
if list(tags):
status = 'ready'
with open(os.path.join(app.root_path, 'buildstatus', status + '.svg')) as f:
svg = f.read()
response = make_response(svg)
response = make_response(STATUS_TAGS[status])
response.content_type = 'image/svg+xml'
return response