def communities(self, offset=0, limit=40): from smarttypes.model.twitter_community import TwitterCommunity communities = TwitterCommunity.get_by_name_value( 'reduction_id', self.id, self.postgres_handle) communities = sorted(communities, key=lambda k: k.community_score, reverse=True) return communities[offset:offset + limit]
thumb_filepath = 'io/%s_thumb.png' % root_user.screen_name plot_graph(g, layout, filepath, size_tup=(600, 600)) #need to adjust vs['size'] if i want to do this #plot_graph(g, layout, thumb_filepath, size_tup=(50, 50)) if not smarttypes.config.IS_PROD: os.system('cp io/%s*.png /home/timmyt/projects/smarttypes/smarttypes/static/images/maps/.' % root_user.screen_name) else: os.system('scp io/%s*.png cottie:/home/timmyt/projects/smarttypes/smarttypes/static/images/maps/.' % root_user.screen_name) print 'save to disk' twitter_reduction = TwitterReduction.create_reduction(root_user.id, postgres_handle) postgres_handle.connection.commit() for community_idx, values_dict in community_stats.items(): #params: #reduction_id, index, center_coordinate, member_ids, #global_pagerank, community_pagerank, hybrid_pagerank if community_idx > 0: TwitterCommunity.create_community(twitter_reduction.id, community_idx, values_dict['center_coordinate'], values_dict['member_ids'], values_dict['global_pagerank'], values_dict['community_pagerank'], values_dict['hybrid_pagerank'], postgres_handle) postgres_handle.connection.commit() TwitterCommunity.mk_tag_clouds(twitter_reduction.id, postgres_handle) postgres_handle.connection.commit() #how long print datetime.now() - start_time
tru.user_id = member_ids[i] tru.coordinates = Point(coordinates[i][0], coordinates[i][1]) tru.pagerank = global_pagerank[i] tru.hybrid_pagerank = hybrid_pagerank[i] reduction_users.append(tru.save()) postgres_handle.connection.commit() print "save communities" communities = [] for i in range(len(vertex_clustering)): member_idxs = vertex_clustering[i] if i != 0: print "community: %s, community_score: %s, members: %s" % (i, community_score[member_idxs][0], len(member_idxs)) community = TwitterCommunity.create_community(reduction.id, i, member_idxs, member_ids[member_idxs].tolist(), MultiPoint(coordinates[member_idxs]), community_score[member_idxs][0], community_pagerank[member_idxs].tolist(), postgres_handle) communities.append(community) postgres_handle.connection.commit() else: print 'community 0 has %s members' % len(member_idxs) #render tiles os.system('python render_tiles.py') #how long print datetime.now() - start_time
tru.reduction_id = reduction.id tru.user_id = member_ids[i] tru.coordinates = Point(coordinates[i][0], coordinates[i][1]) tru.pagerank = global_pagerank[i] tru.hybrid_pagerank = hybrid_pagerank[i] reduction_users.append(tru.save()) postgres_handle.connection.commit() print "save communities" communities = [] for i in range(len(vertex_clustering)): member_idxs = vertex_clustering[i] if i != 0: print "community: %s, community_score: %s, members: %s" % ( i, community_score[member_idxs][0], len(member_idxs)) community = TwitterCommunity.create_community( reduction.id, i, member_idxs, member_ids[member_idxs].tolist(), MultiPoint(coordinates[member_idxs]), community_score[member_idxs][0], community_pagerank[member_idxs].tolist(), postgres_handle) communities.append(community) postgres_handle.connection.commit() else: print 'community 0 has %s members' % len(member_idxs) #render tiles os.system('python render_tiles.py') #how long print datetime.now() - start_time
def communities(self, offset=0, limit=40): from smarttypes.model.twitter_community import TwitterCommunity communities = TwitterCommunity.get_by_name_value("reduction_id", self.id, self.postgres_handle) communities = sorted(communities, key=lambda k: k.community_score, reverse=True) return communities[offset : offset + limit]