diff --git a/server.py b/server.py index 8368fb3..a8cd467 100755 --- a/server.py +++ b/server.py @@ -39,6 +39,9 @@ subscriber_map = redis_server_map.pubsub(ignore_subscribe_messages=True) subscriber_map.psubscribe(cfg.get('RedisMap', 'channelDisp')) subscriber_lastContrib = redis_server_log.pubsub(ignore_subscribe_messages=True) subscriber_lastContrib.psubscribe(cfg.get('RedisLog', 'channelLastContributor')) +subscriber_lastAwards = redis_server_log.pubsub(ignore_subscribe_messages=True) +subscriber_lastAwards.psubscribe(cfg.get('RedisLog', 'channelLastAwards')) + eventNumber = 0 ########## @@ -300,6 +303,10 @@ def getLastContributors(): def getLastContributor(): return Response(eventStreamLastContributor(), mimetype="text/event-stream") +@app.route("/_eventStreamAwards") +def getLastStreamAwards(): + return Response(eventStreamAwards(), mimetype="text/event-stream") + def eventStreamLastContributor(): for msg in subscriber_lastContrib.listen(): content = msg['data'].decode('utf8') @@ -311,6 +318,17 @@ def eventStreamLastContributor(): to_return['epoch'] = epoch yield 'data: {}\n\n'.format(json.dumps(to_return)) +def eventStreamAwards(): + for msg in subscriber_lastAwards.listen(): + content = msg['data'].decode('utf8') + contentJson = json.loads(content) + lastContribJson = json.loads(contentJson['log']) + org = lastContribJson['org'] + to_return = contributor_helper.getContributorFromRedis(org) + epoch = lastContribJson['epoch'] + to_return['epoch'] = epoch + yield 'data: {}\n\n'.format(json.dumps(to_return)) + @app.route("/_getTopContributor") def getTopContributor(suppliedDate=None): if suppliedDate is None: diff --git a/static/js/contrib.js b/static/js/contrib.js index 51fe2cb..452bd28 100644 --- a/static/js/contrib.js +++ b/static/js/contrib.js @@ -344,6 +344,18 @@ function addLastContributor(datatable, data, update) { } } +function addAwards(datatableAwards, json) { + var date = new Date(json.epoch*1000); + var to_add = [ + date.toTimeString().slice(0,-15) +' '+ date.toLocaleDateString(), + getOrgRankIcon(json.orgRank, 60), + createImg(json.logo_path, 32), + createOrgLink(json.org), + createHonorImg(json.honorBadge, 20), + ]; + datatableAwards.row.add(to_add); +} + function updateProgressBar(org) { if(currOrg != org) return; @@ -461,8 +473,10 @@ function updateProgressHeader(org) { $.getJSON( url_getHonorBadges+'?org='+org, function( data ) { for(var i=0; i -
- - - {% for item in org_honor_badge_title_list %} - - - - - {% endfor %} - -
-
- -
-
{{ item[1] }}
-
@@ -187,7 +171,7 @@ {% for item in org_honor_badge_title_list %} -
+
@@ -490,6 +474,7 @@ var url_getLastContributor = "{{ url_for('getLastContributors') }}"; var url_getLatestAwards = "{{ url_for('getLatestAwards') }}"; var url_eventStreamLastContributor = "{{ url_for('getLastContributor') }}"; + var url_eventStreamAwards = "{{ url_for('getLastStreamAwards') }}"; var url_getAllOrg = "{{ url_for('getAllOrg') }}"; var url_getOrgRank = "{{ url_for('getOrgRank') }}"; var url_getContributionOrgStatus = "{{ url_for('getContributionOrgStatus') }}";