def get_tags(names = None, ids = None): where = Filter(None) if names is not None: where = Filter("name in ('%s')" % "','".join(names)) if type(ids) == str: ids = [ str(int(x)) for x in ids.split(',') ] if ids is not None: where = Filter("tag in (%s)" % ','.join(ids)) query = Select( fields = Fields([ 'tag', 'name' ]), source = Tables('Tags'), filter = where, order = Order('name')) results = query.execute(cursor()) return [ (i.tag, i.name) for i in results ]
def recent(tags = []): query = Select( filter = Filter.recent() & Filter.tags(tags), order = Order.start_date(reverse = True)) return query.execute(cursor())
def upcoming(tags = []): query = Select( filter = Filter.upcoming() & Filter.tags(tags), order = Order.start_date()) return query.execute(cursor())
def deadlines(tags = []): query = Select( filter = Filter.upcomingDeadlines() & Filter.tags(tags), order = Order.deadline()) return query.execute(cursor())