Created
November 28, 2015 23:46
-
-
Save anonymous/ec859d61e29cd97ca962 to your computer and use it in GitHub Desktop.
Codemotion Ranking 2015
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import codecs | |
import sys | |
UTF8Writer = codecs.getwriter('utf8') | |
sys.stdout = UTF8Writer(sys.stdout) | |
import requests | |
ratings = [] | |
agendaUrl = 'https://www.koliseo.com/codemotion/codemotion-madrid/r4p/5685252034920448/agenda' | |
data = requests.get(agendaUrl).json() | |
for day in data['days']: | |
for track in day['tracks']: | |
for slot in track['slots']: | |
if ('contents' in slot) and (slot['contents']['type'] == 'TALK') and ('feedback' in slot['contents']): | |
ratingAverage = slot['contents']['feedback']['ratingAverage'] | |
entriesCount = slot['contents']['feedback']['entriesCount'] | |
title = slot['contents']['title'] | |
ratings.append((title , ratingAverage, entriesCount)) | |
ratingAverage = sum(map(lambda x: x[1], ratings))/len(ratings) | |
ratings = map(lambda x: (x[0], (x[1]*x[2]+ratingAverage)/(x[2]+1)*2), ratings) | |
ratings.sort(key=lambda tup: tup[1]) | |
ratings.reverse() | |
for index, rating in enumerate(ratings): | |
print str(index+1) + ' - ('+ str(rating[1])[:4] + ') ' + rating[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment