Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- links = {}
- cursor = DBM.cursor()
- cursor.execute("select comment_link_id, link_uri, sum((1-(unix_timestamp(now())-unix_timestamp(comment_date))/43200)) as x from comments, links where link_status = 'published' and link_date > date_sub(now(), interval 24 hour) and comment_link_id = link_id and comment_date > date_sub(now(), interval 12 hour) group by comment_link_id order by x desc limit 15")
- for row in cursor:
- values = {}
- values['uri'] = row[1]
- values['c'] = row[2]
- values['w'] = 0
- links[row[0]] = values
- cursor.execute("select link_id, link_uri, sum((1-(unix_timestamp(now())-unix_timestamp(vote_date))/43200)) as x from votes, links where link_status = 'published' and link_date > date_sub(now(), interval 24 hour) and vote_type='links' and vote_link_id = link_id and vote_date > date_sub(now(), interval 12 hour) and vote_user_id > 0 and vote_value > 7 group by vote_link_id order by x desc limit 15")
- for row in cursor:
- if row[0] in links:
- links[row[0]]['v'] = row[2]
- links[row[0]]['w'] = links[row[0]]['v'] + 2 * links[row[0]]['c']
- cursor.close()
- sorted_ids = sorted(links, cmp=lambda x,y: cmp(links[y]['w'], links[x]['w']))
- for id in sorted_ids:
- if links[id]['w'] > 0:
- print links[id]['uri'], links[id]['w']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement