def add(cls, follower, following, weight=1): """ Returns 0 if it """ cursor = dbi.execute( "INSERT IGNORE INTO analytics_follow (follower,following,weight) VALUES(%s,%s,%s)" ,(follower,following,weight) ) return (cursor.lastrowid!=0)
def remove_comment(cls, usr, content): dbi.execute( "UPDATE analytics_content SET comments=comments-1 WHERE content=%s" ,(content,) )
def add_invite(cls, follower, following): cls.assert_exists(follower, following) dbi.execute( "UPDATE analytics_follow SET invites = invites+1 WHERE follower=%s and following=%s" ,(follower, following) )
def remove_comment(cls, follower, following): dbi.execute( "UPDATE analytics_follow SET comments = comments-1 WHERE follower=%s and following=%s" ,(follower, following) )
def remove(cls, follower, following): cursor = dbi.execute( "DELETE FROM analytics_follow WHERE follower=%s and following=%s" ,(follower,following) ) return (cursor.rowcount!=0)
def remove_comment(cls, usr, content, tabloid): dbi.execute( "UPDATE analytics_tabloidentry SET comments=comments-1 WHERE tabloid=%s and content=%s"(tabloid, content) )
def remove_view(cls, usr, content, tabloid): dbi.execute("UPDATE analytics_tabloidentry SET views=views-1 WHERE tabloid=%s and content=%s"(tabloid, content))
def add(cls, usr, content): dbi.execute( "INSERT INTO analytics_usr_seen (usr,content) VALUES(%s,%s) " ,(usr, content) )
def remove_invite(cls, usr, tabloid): dbi.execute( "UPDATE analytics_tabloid SET invites=invites-1 WHERE tabloid=%s" ,(tabloid,) )
def add_invite(cls, usr, tabloid): cls.assert_exists(tabloid) dbi.execute( "UPDATE analytics_tabloid SET invites=invites+1 WHERE tabloid=%s" ,(tabloid,) )
def get_owner(cls, tabloid): row = dbi.execute("SELECT usr FROM analytics_tabloid WHERE tabloid=%s",(tabloid,)).fetchone() if row is not None: return row["usr"] else: return None
def remove_view(cls, usr, tabloid): dbi.execute( "UPDATE analytics_tabloid SET views=views+1 WHERE tabloid=%s" ,(tabloid,) )
def add_view(cls, usr, tabloid): cls.assert_exists(tabloid) dbi.execute( "UPDATE analytics_tabloid SET views=views+1 WHERE tabloid=%s" ,(tabloid,) )
def add(cls, usr, tabloid): dbi.execute( "INSERT INTO analytics_tabloid (tabloid,usr) VALUES(%s,%s)" ,(tabloid,usr) )
def add_time_spent(cls, usr, content): cls.assert_exists(content) dbi.execute( "UPDATE analytics_content SET time_spent=time_spent+%s WHERE content=%s" ,(content,time_spent) )
def remove_time_spent(cls, usr, content, time_spent): dbi.execute( "UPDATE analytics_content_usr SET time_spent=time_spent-%s WHERE usr=%s, content=%s" ,(time_spent, usr,content,) )
def remove(cls, usr, content): dbi.execute( "DELETE FROM analytics_usr_seen WHERE usr=%s AND content=%s" ,(usr, content) )
def add_content(cls, usr, tabloid): cls.assert_exists(tabloid) dbi.execute( "UPDATE analytics_tabloid SET contents=contents+1 WHERE tabloid=%s" ,(tabloid,) )
def remove(cls, usr, content, tabloid): cursor = dbi.execute("DELETE FROM analytics_tabloidentry WHERE tabloid=%s AND content=%s ", (tabloid, content)) return cursor.rowcount != 0
def remove_content(cls, usr, tabloid): dbi.execute( "UPDATE analytics_tabloid SET contents=contents-1 WHERE tabloid=%s" ,(tabloid,) )
def add_comment(cls, usr, content, tabloid): cls.assert_exists(content, tabloid) dbi.execute( "UPDATE analytics_tabloidentry SET comments=comments+1 WHERE tabloid=%s and content=%s"(tabloid, content) )
def add_markread(cls, usr, content): dbi.execute( "INSERT INTO analytics_usr_content (user, content, markread) VALUES(%s,%s,%s) " " ON DUPLICATE KEY UPDATE markread=%s " , (usr, content, 1, 1) )
def add(cls, usr, content, tabloid): cursor = dbi.execute( "INSERT IGNORE INTO analytics_tabloidentry (tabloid,usr,content,category) VALUES(%s,%s,%s,%s)", (tabloid, usr, content, category), ) return cursor.lastrowid != 0
def remove_markread(cls, usr, content): dbi.execute( " UPDATE analytics_usr_content SET markread=%s WHERE usr=%s AND content=%s " , (0, usr, content) )
def add_comment(cls, follower, following): cls.assert_exists(follower, following) dbi.execute( "UPDATE analytics_follow SET comments = comments+1 WHERE follower=%s and following=%s" ,(follower, following) )
def add_share(cls, usr, content): dbi.execute( "INSERT INTO analytics_usr_content (user, content, shares) VALUES(%s,%s,%s) " " ON DUPLICATE KEY UPDATE shares=%s " , (usr, content, 1, 1) )
def remove_share(cls, usr, content): dbi.execute( " UPDATE analytics_usr_content SET shares=%s WHERE usr=%s AND content=%s " , (0, usr, content) )
def add_time_spent(cls, usr, content, time_spent): dbi.execute( "INSERT INTO analytics_content_usr (usr,content,time_spent) VALUES(%s,%s,%s) " " SET time_spent=time_spent+%s " ,(usr,content,time_spent,time_spent) )
def remove_invite(cls, follower, following): dbi.execute( "UPDATE analytics_follow SET invites = invites-1 WHERE follower=%s and following=%s" ,(follower, following) )
def add_comment(cls, usr, content): cls.assert_exists(content) dbi.execute( "UPDATE analytics_content SET comments=comments+1 WHERE content=%s" ,(content,) )