def get_network_viz_data(): counts = stats.get_questionnaire_counts() viz_data = [] for qid, s in counts.items(): area_info = { 'name': QUESTIONNAIRES_BY_ID[qid]['name'], 'total': s['learn'] + s['explain'] + s['connect'] + s['do'] } area_info.update(skills_to_percentages(s)) viz_data.append(area_info) viz_data = sorted(viz_data, key=lambda area_info: area_info['total'], reverse=True) return viz_data
def network(): ''' View the network. ''' counts = stats.get_questionnaire_counts() viz_data = [] for qid, s in counts.items(): total = s['learn'] + s['explain'] + s['connect'] + s['do'] area_info = { 'name': QUESTIONNAIRES_BY_ID[qid]['name'], 'total': total } for skill_level in ['learn', 'explain', 'connect', 'do']: percentage = 0.0 if total > 0: percentage = float(s[skill_level]) / total area_info[skill_level] = int(percentage * 100) viz_data.append(area_info) viz_data = sorted(viz_data, key=lambda area_info: area_info['total'], reverse=True) return render_template('network.html', viz_data=viz_data)