def sendUserPostData(email): """Send data for posts chart for the specified user's email.""" database_helper.connectToDatabase() numberOfPostsByUser = database_helper.getNumberOfPostsByUserOnWall(email, email) data = [{'value': numberOfPostsByUser, 'color': '#9DE0AD', 'label': email}] topTwo = database_helper.getTopTwoNumberOfPostsOnWallByOthers(email) numberOfPostsOnWall = database_helper.getNumberOfPostsOnWall(email) colors = ['#45ADA8', '#4F7A79'] colorIndex = 0 # Loop through the two top posters on the user's wall and assign them a color form the colors list. for writer in topTwo: data.append({'value': writer[1], 'color': colors[colorIndex], 'label': writer[0]}) colorIndex += 1 if webSockets.has_key(email): webSockets[email].send(json.dumps({'type': 'messageCounter', 'data': data}))
def sendUserPostTotalData(email): """Send number of total posts for the specified user's email.""" database_helper.connectToDatabase() numberOfPostsOnWall = database_helper.getNumberOfPostsOnWall(email) if webSockets.has_key(email): webSockets[email].send(json.dumps({'type': 'messageCounterTotal', 'data': numberOfPostsOnWall}))