def count_other_channel_patterns(team, channel_id): sql = """ select count(*) from clippingsbot.team_patterns where team_id = :team_id and channel_id != :channel_id """ return db.scalar(sql, team_id=team['team_id'], channel_id=channel_id)
def save(pattern): sql = """ insert into clippingsbot.patterns (pattern) values (lower(:pattern)) on conflict(lower(pattern)) do update set pattern = lower(:pattern) returning pattern_id """ return db.scalar(sql, pattern=pattern)
def save(data): sql = """ insert into clippingsbot.teams ( team_id, access_token, user_id, team_name, scope ) values ( :team_id, :access_token, :user_id, :team_name, :scope ) on conflict (team_id) do update set scope = excluded.scope, access_token = excluded.access_token, user_id = excluded.user_id, team_name = excluded.team_name returning team_id """ return db.scalar(sql, **data)
def save(pattern, mention): sql = """ insert into clippingsbot.mentions ( pattern_id, feed, title, comments_url, link_url ) values ( :pattern_id, :feed, :title, :comments_url, :link_url ) on conflict (pattern_id, feed, comments_url) do nothing returning 1 """ return db.scalar(sql, pattern_id=pattern['pattern_id'], feed=mention['feed'], title=mention['title'], comments_url=mention['comments_url'], link_url=mention['link_url'])
def count_patterns(team): sql = """ select count(*) from clippingsbot.team_patterns where team_id = :team_id """ return db.scalar(sql, team_id=team['team_id'])