Esempio n. 1
0
def get_topic(val): 
	"get topic" 
	d = op.get_all('HASH_TAGS') 
	result = {} 
	for k,v in d:	 
		if k.lower().find(val.lower()) != -1:
#			print k, v , v['uid'] 
			result[k] = v
	return result
Esempio n. 2
0
def get_people(val,uid): 
	"get people" 
	d = op.get('FOLLOWING',uid)
	result1 = {}
	if 'status' not in d.keys():
		e = op.multi_get('USERS',d.keys())
		for k in e.keys():	 
			if e[k]['username'].lower().find(val.lower()) != -1:
				result1[k] = e[k]['username']

	d = op.get_all('USERNAME') 
	result = {} 
	for k,v in d:	 
		if k.lower().find(val.lower()) != -1:
			if v['uid'] not in result1:
				result[v['uid']] = k
	return result1,result
Esempio n. 3
0
def current_trends():
        print "inside trends"
        etime = long(time.time())
        reference_t = (etime - (etime % 86400)) + time.altzone
#        reference_t = long(midnight) - long(86400*1e6)
        result = op.get_all('HASH_TAGS')
        count={}
        for k,v in result:
                count[k] = 0
                for key,val in v.items():
			print key,val
                        val1 = str(key).split(":")
			print val1[0]
                        timestamp = val1[0]
                        if float(timestamp) >= float(reference_t):
                                count[k] = count[k] + 1
        sorted_trends = sorted(count.iteritems(), key=operator.itemgetter(1),reverse=True)
        current_trends = sorted_trends[:10]
        print current_trends
        return current_trends
Esempio n. 4
0
def delete_tweet(tweetid,uid) :
	"to delete a tweet"
	val = op.get('TWEETS',tweetid)
	op.remove_row('TWEETS', tweetid)
	key = str(val['timestamp']) + ":" + uid
	op.remove_column('USERLINE', uid, [key])				#delete from timeline and userline
	op.remove_column('TIMELINE', uid, [key])
	print "during delete " + key
	for followerID in op.get('FOLLOWER', uid):
		print followerID
		if 'status' != followerID:
			op.remove_column('TIMELINE', followerID, [key])		#delete from followers timeline

	d = op.get('FAVORITE_IS', tweetid)					#delete from favourites list
	op.remove_row('FAVORITE_IS', tweetid)
	for key in d:
		v = str(d[key])
		op.remove_column('FAVORITE_OF',key,[v])
	d = op.get_all('HASH_TAGS')
        for k,v in d:
                for key,val in v.items():
                        if 'status' != key:
                                if str(tweetid) == str(val):
                                        op.remove_column('HASH_TAGS',k,[key])