def get_org_id_to_login(): from data import users print("Generating id->login mappings...") return { user['id']: user['login'] for user in users() if user['type'] == 'ORG' }
def get(self, _username): _users = users() data = _users.query.filter_by(username=_username).first() youtubeChannel = data.serializeYouTubeChannel() return getYouTubeChannelVideos(youtubeChannel)
def get(self): _users = users() data = _users.query.filter_by(active=True).all() youTubeChannels = [e.serializeYouTubeChannel() for e in data] return getAllRecentYouTubeChannelVideos(youTubeChannels)
def get_locations(): print("Generating locations...") locations = defaultdict(set) for user in users(): if user['location']: locations[user['location']].add(user['id']) return locations
def generate_graph(prune, output): graph = snap.TNGraph.New() # If we aren't pruning edges, then we need the whole graph. if not prune: print("Adding users...") for user in users(): graph.AddNode(user['id']) print("Adding follow edges...") for follow in followers(): # If source or destination don't exist, then we need to create them. src, dst = follow['user_id'], follow['follower_id'] if not graph.IsNode(src): graph.AddNode(src) if not graph.IsNode(dst): graph.AddNode(dst) graph.AddEdge(src, dst) print("Nodes:", graph.GetNodes()) print("Edges:", graph.GetEdges()) FOut = snap.TFOut(output) graph.Save(FOut) FOut.Flush()
def get_companies(): print("Generating companies...") companies = defaultdict(set) for user in users(): if user['company'] != None: companies[user['company'].lower()].add(user['id']) return companies
def get(self): _users = users(); hermits = _users.query.filter_by(active = True).all() listHermits = [e.serializeChannels() for e in hermits] activeTwitchLivestreamStatus = getTwitchDataAll(listHermits) return activeTwitchLivestreamStatus
def get(self): _users = users() data = _users.query.order_by(_users.name).all() hermitData = [e.serialize() for e in data] youTubeData = getYouTubeChannelDataAll(hermitData) organizedData = sorted(youTubeData, key=lambda k: k['name'].lower()) return organizedData
def get(self, _username): _users = users() data = _users.query.filter_by(username=_username).first() hermitData = data.serialize() if hermitData: youtubeChannelData = getYouTubeChannelDataUser(hermitData) return youtubeChannelData else: abort(404, message='User not found in database')
def get(self, _username): _users = users() data = _users.query.filter_by(username=_username).first() hermitData = data.serializeChannels() if hermitData: twitchChannelLive = getTwitchDataUser(hermitData) return twitchChannelLive else: abort(404, message='User not found in database')
def get(self, _username): _users = users() _socials = socials() data = _users.query.filter_by(username=_username).first() if not data: abort(404, message='User not found in database') serialized = data.serializeHermitCode() hermitCode = serialized['hermitCode'] _socialData = _socials.query.filter_by(hermit_code=hermitCode).all() finalSocialData = [e.serialize() for e in _socialData] return finalSocialData
#!/usr/bin/env python3 import click import os, sys sys.path.append( os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) from data import users from collections import Counter if __name__ == "__main__": locations = Counter(user['location'] for user in users() if user['location'] != None) for i, (location, size) in enumerate(locations.most_common(100)): print(i + 1, "&", location, "&", size, "\\\\")
def get_user_id_to_login(): from data import users print("Generating id->login mappings...") return {user['id']: user['login'] for user in users()}
def get_user_to_location(): print("Generating user to location mapping...") return { user['id']: user['location'] for user in users() if user['location'] != None }
def get_user_to_company(): print("Generating user to company mapping...") return { user['id']: user['company'] for user in users() if user['company'] != None }
from data import followers, users from collections import Counter from itertools import islice if __name__ == "__main__": print("Generating id->login mappings...") id_to_login = {user['id']: user['login'] for user in users()} print("Counting followers...") counter = Counter() counter.update(record['follower_id'] for record in followers()) print("Top 100 most followed users:") print([(id_to_login[id], followers) for (id, followers) in counter.most_common(100)])
log("to: " + username) log("---") log(debug_content) reddit.send_pm(subject, total_content, username, account) if __name__ == '__main__': account = reddit.connect() db = data.connect() most_recent_time = data.get_most_recent_time() interval = 30 while True: reddit.update_users(db, account) global_sub_list = data.subreddits(db) subs = data.subreddits(db) user_list = data.users(db) if global_sub_list: try: posts_by_subreddit = reddit.fetch_posts(subs, account) except: print("Error fetching posts.") posts_by_subreddit_by_users = {} most_recent_time, posts_by_subreddit = get_new_posts( posts_by_subreddit, most_recent_time) for user in user_list: new_posts_by_subreddit = apply_filters(posts_by_subreddit, user[1], user[0], db) try: posts_by_subreddit_by_users[ user[0]] += new_posts_by_subreddit except:
graph = snap.TNGraph.Load(FIn) nodes = set([959479]) for i in range(2): NodeVec = snap.TIntV() snap.GetNodesAtHop(graph, 959479, i, NodeVec, False) for item in NodeVec: nodes.add(item) sg_nodes = snap.TIntV() for node in nodes: sg_nodes.Add(node) subgraph = snap.GetSubGraph(graph, sg_nodes) labels = snap.TIntStrH() for node in nodes: labels[node] = "UNKNOWN" for user in users(): if user['id'] in nodes: labels[user['id']] = user['login'] snap.DrawGViz(subgraph, snap.gvlDot, "graph.png", "githubpy Neighborhood", labels) # ni = graph.GetNI(58) # followers = [ni.GetInNId(i) for i in range(ni.GetInDeg())] # followees = [ni.GetOutNId(i) for i in range(ni.GetOutDeg())] # print(followers, followees)